Normal HA switches (e.g. for example, input_boolean) maintain their state across HA restarts (unless the initial parameter is set). This doesn't seem to be the case for switches configured in the Modbus YAML.
There is the verify functionality mentioned in the documentation. However, some Modbus devices do not support reading individual registers or coils (click). The documentation says that "...If omitted, no verification is done, but the state of the switch is set with each toggle.". Based on this, my expectation would be that the respective state is also kept across HA restarts, which doesn't seem to be the case.
This leads to confusion because after HA restart, Modbus switches suddenly have the off state (although in reality the respective Modbus slave function is on).
To summarize:
Expectation
Modbus switches (where verification is not configured) keep their state across HA restarts.
Actual result
Modbus switches (where verification is not configured) reset their state to off after HA restart.
Way to reproduce
1) Configure a Modbus switch (that does something real on the slave)
2) Turn the switch on.
3) Verify that the respective functionality on the slave is on.
4) Restart HA.
5) Check the state of the switch.
What version of Home Assistant Core has the issue?
2024.11.x
What was the last working version of Home Assistant Core?
The problem
Normal HA switches (e.g. for example,
input_boolean
) maintain their state across HA restarts (unless theinitial
parameter is set). This doesn't seem to be the case for switches configured in the Modbus YAML.There is the
verify
functionality mentioned in the documentation. However, some Modbus devices do not support reading individual registers or coils (click). The documentation says that "...If omitted, no verification is done, but the state of the switch is set with each toggle.". Based on this, my expectation would be that the respective state is also kept across HA restarts, which doesn't seem to be the case.This leads to confusion because after HA restart, Modbus switches suddenly have the
off
state (although in reality the respective Modbus slave function is on).To summarize:
Expectation
Modbus switches (where verification is not configured) keep their state across HA restarts.
Actual result
Modbus switches (where verification is not configured) reset their state to
off
after HA restart.Way to reproduce
1) Configure a Modbus switch (that does something real on the slave) 2) Turn the switch on. 3) Verify that the respective functionality on the slave is on. 4) Restart HA. 5) Check the state of the switch.
What version of Home Assistant Core has the issue?
2024.11.x
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Supervised
Integration causing the issue
Modbus
Link to integration documentation on our website
https://www.home-assistant.io/integrations/modbus/#configuring-switch-entities
Diagnostics information
No response
Example YAML snippet
Anything in the logs that might be useful for us?
No response
Additional information
No response