Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch states not preserved after HA restart, all switches turn on #973

Closed
MaxVonEvil opened this issue Jul 6, 2023 · 11 comments · Fixed by #971
Closed

Switch states not preserved after HA restart, all switches turn on #973

MaxVonEvil opened this issue Jul 6, 2023 · 11 comments · Fixed by #971

Comments

@MaxVonEvil
Copy link

Version of the custom_component: 1.4.0

 Logger: homeassistant.util.logging
Source: util/logging.py:168
First occurred: 18:07:25 (32 occurrences)
Last logged: 18:17:45

    Exception in handle_entity_update when dispatching 'nodered_entity_f3597401.3f5758_7e9f13ec224fa3d8': ({'type': 'nodered/entity', 'server_id': 'f3597401.3f5758', 'node_id': '7e9f13ec224fa3d8', 'state': 'Ok', 'attributes': {}, 'id': 1094},) Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 590, in state numerical_value = int(value) ^^^^^^^^^^ ValueError: invalid literal for int() with base 10: 'Ok' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/config/custom_components/nodered/__init__.py", line 146, in handle_entity_update self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 742, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 809, in _async_write_ha_state state = self._stringify_state(available) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 748, in _stringify_state if (state := self.state) is None: ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 594, in state raise ValueError( ValueError: Sensor sensor.smartups_battery_life has device class 'None', state class 'measurement' unit 'None' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'Ok' (<class 'str'>)
    Exception in handle_entity_update when dispatching 'nodered_entity_f3597401.3f5758_7e9f13ec224fa3d8': ({'type': 'nodered/entity', 'server_id': 'f3597401.3f5758', 'node_id': '7e9f13ec224fa3d8', 'state': 'Ok', 'attributes': {}, 'id': 1124},) Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 590, in state numerical_value = int(value) ^^^^^^^^^^ ValueError: invalid literal for int() with base 10: 'Ok' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/config/custom_components/nodered/__init__.py", line 146, in handle_entity_update self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 742, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 809, in _async_write_ha_state state = self._stringify_state(available) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 748, in _stringify_state if (state := self.state) is None: ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 594, in state raise ValueError( ValueError: Sensor sensor.smartups_battery_life has device class 'None', state class 'measurement' unit 'None' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'Ok' (<class 'str'>)
    Exception in handle_entity_update when dispatching 'nodered_entity_f3597401.3f5758_7e9f13ec224fa3d8': ({'type': 'nodered/entity', 'server_id': 'f3597401.3f5758', 'node_id': '7e9f13ec224fa3d8', 'state': 'Ok', 'attributes': {}, 'id': 1154},) Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 590, in state numerical_value = int(value) ^^^^^^^^^^ ValueError: invalid literal for int() with base 10: 'Ok' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/config/custom_components/nodered/__init__.py", line 146, in handle_entity_update self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 742, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 809, in _async_write_ha_state state = self._stringify_state(available) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 748, in _stringify_state if (state := self.state) is None: ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 594, in state raise ValueError( ValueError: Sensor sensor.smartups_battery_life has device class 'None', state class 'measurement' unit 'None' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'Ok' (<class 'str'>)
    Exception in handle_entity_update when dispatching 'nodered_entity_f3597401.3f5758_7e9f13ec224fa3d8': ({'type': 'nodered/entity', 'server_id': 'f3597401.3f5758', 'node_id': '7e9f13ec224fa3d8', 'state': 'Ok', 'attributes': {}, 'id': 1193},) Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 590, in state numerical_value = int(value) ^^^^^^^^^^ ValueError: invalid literal for int() with base 10: 'Ok' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/config/custom_components/nodered/__init__.py", line 146, in handle_entity_update self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 742, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 809, in _async_write_ha_state state = self._stringify_state(available) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 748, in _stringify_state if (state := self.state) is None: ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 594, in state raise ValueError( ValueError: Sensor sensor.smartups_battery_life has device class 'None', state class 'measurement' unit 'None' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'Ok' (<class 'str'>) 

Describe the bug

After upgrading about 3 days ago to Node Red Compagnion 1.4.0 I noticed that after HA restart, any switches defined in Node-red would turn on. Others would become unresponsive, as if something is broken between HA and NodeRed, specifically if you try to turn off a switch node-red it would fail and revert to the on-state.

HA details:
Home Assistant 2023.7.0
Supervisor 2023.07.1
Operating System 10.3
Frontend 20230705.0 - latest

@zachowj
Copy link
Owner

zachowj commented Jul 6, 2023

What is the node type for the node that has the id 7e9f13ec224fa3d8?

@goofy1988
Copy link

I have a similar issue. After Update to newest Version and reboot every NodeRed Switch is in On Position.

@MaxVonEvil
Copy link
Author

@zachowj it's a switch type, they all are. Although I can't be 100% sure, it seems other entity types, such as sensors are not affected by this.

Since the issue started I've had to convert a few critical entities such as Irrigation to HA Helper Toggle entitites (input_boolean), but I'm holding out for a solution on the rest. As it seems there's at least one other person experiencing it too, I hope we can provide you with the info you need to address this, thanks.

@Pihlflykt
Copy link

Pihlflykt commented Jul 6, 2023

Same issue here since about a day back. All switches are turned On after reboot of HA.
Edit: I can still control the switches after reboot, hence I manually have to turn them off.

@zachowj
Copy link
Owner

zachowj commented Jul 6, 2023

@MaxVonEvil While in NR you can use the “Search flows” command and enter the id 7e9f13ec224fa3d8 and it will show you the nodes that match. I'm 99% certain those errors are from a sensor node.

The switch node code hasn't changed in 10 months, maybe something changed on the HA side. I'll have to see if I can replicate it.

@zachowj zachowj transferred this issue from zachowj/hass-node-red Jul 6, 2023
@zachowj zachowj closed this as completed in 3cbe491 Jul 6, 2023
@MaxVonEvil
Copy link
Author

@MaxVonEvil While in NR you can use the “Search flows” command and enter the id 7e9f13ec224fa3d8 and it will show you the nodes that match. I'm 99% certain those errors are from a sensor node.

You are right, that was actually a sensor node. As stated those still seem to work.

The switch node code hasn't changed in 10 months, maybe something changed on the HA side. I'll have to see if I can replicate it.

Thanks, it's unfortunatly not the first time and likely not the last time HA's unintentionally broken an integration with an underlying change. I'll unfortunately have to continue to covert 30-something switches to input_boolean. Yay.

@zachowj
Copy link
Owner

zachowj commented Jul 6, 2023

@MaxVonEvil it's fixed in 0.51.1

@MaxVonEvil
Copy link
Author

@zachowj Pardon, not sure which component that refers to?

@zachowj
Copy link
Owner

zachowj commented Jul 7, 2023

node-red-contrib-home-assistant-websocket

@MaxVonEvil
Copy link
Author

Got it. Updated and confirmed it's working again. Thanks for the help!

@goofy1988
Copy link

goofy1988 commented Jul 7, 2023

-----update now available----

----Done/fixed
Nice to hear that there is a fix. Ive tried to manually update the websocket nodes in the node red paletteanager but there is still only version 0.51.0. Can i do an update over the terminal or how can i force an update? A restart of node red and HA still only show the .0 version.

Thanks for your help
---Done/fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants