bosch-thermostat / home-assistant-bosch-custom-component

HA custom component for Bosch thermostats
Apache License 2.0
216 stars 45 forks source link

Fix _state value #352

Closed crussell85 closed 8 months ago

crussell85 commented 9 months ago

I used the master branch in my Home Assistant install (installed in config directory as I dont use HACS) and noticed the enabled sensors all had the values of "False" but I could see the values in the attributes of the entity.

After some debugging of sensor base.py I noticed _state was set to False as it was being set to the result of the IF check not the value of the value attribute from data

wrapping the walrus operator in brackets fixes it

pszafer commented 9 months ago

I'd have to check. I think those brackets would be removed by black formatter.

crussell85 commented 9 months ago

There might be a better fix for it, Python isn't my first language but the brackets definitely change the result. "False" was being assigned to the state of all the entities without them.

Happy for you to close this if my fix isn't formatter friendly

Cheers