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
modbus_switch: honor switch:restore_mode #4122
Conversation
Hey there @martgras, mind taking a look at this pull request as it has been labeled with an integration ( |
@nagyrobi New documentation: esphome/esphome-docs#2494. Preview: https://deploy-preview-2494--esphome.netlify.app/components/switch/modbus_controller.html |
Wow. Thanks @jesserockz |
@nagyrobi please test extensively to see if it does what you want and report back. Thanks! |
Tested this PR in the v2022.12.0-dev with:
And config:
The expectation was that the board should have saved the switch state to the flash (didn't see an entry in the INFO log about that, either) and restore it after reboot. |
OK, I will check with your config and let you know |
From what I understand this patch restores the state if it was found saved in the flash. But it looks like the step needed before this, to actually save it, is missing. Just a wild guess |
Ok, it turns out the code is OK, but this feature only works if you have the
And it should start working. Magic.
With this on, you should see the following some time after a relay state has changed:
Note the After that message, you can shut down. When the device comes back online it should restore the state ( I will update the docs to warn that Regards |
new docs PR: esphome/esphome-docs#2496 |
Not working, unfortunately:
pulled the power plug... reconnected...
Switch didn't turn back on. |
What does this implement/fix?
This PR implements
switch::restore_mode
functionality for Modbus switches. It leverages the groundwork in PR #3648, so it is actually a very small change.Modbus switches can now be restored to the last on/off state as recorded by ESPHome, or started with a forced on/off state, etc.
By default, this feature is disabled so Modbus Switch will behave as it did before this PR.
Types of changes
Related issue or feature (if applicable): fixes
Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#
Test Environment
Example entry for
config.yaml
:# Example config.yaml
Checklist:
tests/
folder).If user exposed functionality or configuration variables are added/changed: