-
Notifications
You must be signed in to change notification settings - Fork 255
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Cannot read property 'states' of undefined. #337
Comments
This started happening from HA 0.110 |
Will fix that soon. They've changed something in core which make the hass object undefined while the card is created and it fucks everything up... |
You can never trust the order |
I understand, however it used to be always the case in the past and the latest release broke a lot of of cards because of that. So I see that as a breaking (big) change :) |
Well, it used to be close enough to always... but i agree, it's an unfortunate change that could have been communicated more clearly. |
I'm just wondering something then... How do you tackle the attachement to DOM when you need |
If it's really necessary and can't be fixed by restructuring, a flag could help. initial_setup() {
if(this.hass === undefined) return;
if(this._config === undefined) return;
if(!this.isConnected) return;
this.initial_setup_complete = true;
... do setup stuff ...
}
setConfig(config) {
... do stuff ...
this._config = config;
if(this.initial_setup_complete === undefined) {
this.initial_setup();
}
}
set hass(hass) {
... do stuff ...
if(this.initial_setup_complete === undefined) {
this.initial_setup();
}
}
connectedCallback() {
... you get the point ...
} |
Any news on this @RomRider :) |
Will work on it over the weekend, didn't have time lately, sorry :/ |
Here is another case to test or help reproduce this. I get the reported error using a timer:
|
@dwainscheeren, please give 3.3.6 a go an report back :) |
@parautenbach, the timer issue should also be fixed btw ;) |
Tested it for some minutes, until now no errors. So seems to be fixed. :) I report back here if not. Thanks! |
Thanks a mil for the quick release! I downloaded and installed the update and haven't seen the issue. I'll let you know should it appear again. |
Checklist
Describe the bug
Sometimes when I enter a page I get the following error
button-card.js:1638 Uncaught (in promise) TypeError: Cannot read property 'states' of undefined
It happens on this part:
this._stateObj = this._config.entity ? this._hass.states[this._config.entity] : void 0;try {
When I then keep that page open for some minutes some of the button cards suddenly starts working and show up (otherwise they are just empty/not visible).Version of the card
Version: 3.3.5
To Reproduce
It happens in different ways I use button card but an example is:
Desktop (please complete the following information):
Latest version chrome
The text was updated successfully, but these errors were encountered: