-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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 toggle doesn't work with latest code #50010
Comments
modbus documentation |
Hey there @adamchengtkc, @janiversen, mind taking a look at this issue as its been labeled with an integration ( |
no you are missing “verify:” without that it will not read from your device but just set the state directly. |
Let me know what you find, #49910 should not affect toogling but could affect verifying. |
I will check... I created this issue to let you know about this. Maybe I will just need to update my configuration. |
Thanks for telling me, let me know if you find anything. |
I will troubleshoot during this week. All my findings will go here. You'll get an email :) |
I always wondering why it's mandatory to continuously very state of relay if there is only one master on the line. Isn't it possible to do make state verification only after the command is send during configure N seconds time-out period? Yes, I understand both use cases are possible - switch can be triggered manually. Still in installations where you need just to confirm execution of the command a request loop is an overhead - it just bring a lot of waste traffic in the modbus network. Let me explain what I mean by use case. Relay board can receive command and send it's state. Its configured as switch.
I see the state of relay requested in a loop with configured interval. The log is full of such requests:
Instead of this I propose to request state during N seconds after the change state command is sent. For example a parameter
This configuration will tell modbus component to request state of the switch 3 time each 15 seconds after the switch command send. If no response after 45 seconds then switch becomes unavailable. Stop request on first successful response. |
@rostislav-palivoda It looks to me as if you are requesting 2 new features @vzahradnik new switch doc. just went online, maybe it helps you :-) |
Oh, you reply while I was fulfilling my comment with log data and example, See my updated comment above. And yes a minor change (a) will have a great effect. Change (b) is not required - |
please raise a new issue....we do not like to have multiple issues mixed. |
Do you think its doable in the nearest future? I'm thinking about making changes in the component myself but not sure how to start. I read on forum about |
?? I am not following the community. Issues with core are raised here. |
Then I should create issue here on github? |
I am not sure what the right way is, might be that feature requests in the community are automatically copied here (the text there suggest it). I only look at “pull requests” and “issues”. |
Sorry for off topic. I'm asking because there is big warning BUGS ONLY if I try to report issue for the HA core project. :) I really appreciate if you can take care of this change. Then I'll create issue in core and delete post from community. Not sure about community feature requests propagation in to the git, looks like not. |
I'll check, maybe I just missed something. |
OK, first problem I see is that as far as I know you can't turn on 2021-05-05 13:44:43 ERROR (MainThread) [homeassistant.config] Invalid config for [modbus]: expected a dictionary for dictionary value @ data['modbus'][0]['switches'][0]['verify']. Got None. Perhaps we could modify the scheme so that it will create an empty dict if nothing is supplied. The documentation for switches:
...
- name: Switch2
...
verify: So officialy such a config (verify without optional parameters) should be supported. Or it is a typo in the documentation. Second problem is this: # switch.py, line 129
if result is False:
self._available = False
self.schedule_update_ha_state() If Also, I found out that reading values in my setup is also a problem. When I turn on I found the following in my logs but I don't know for sure if it's related: AttributeError: 'NoneType' object has no attribute 'read_coils'
2021-05-05 13:39:12 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
File "/usr/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/srv/git/Lutemi/home-assistant-core/homeassistant/components/modbus/switch.py", line 102, in <lambda>
self.hass, lambda arg: self.update(), self._scan_interval
File "/srv/git/Lutemi/home-assistant-core/homeassistant/components/modbus/switch.py", line 159, in update
result = self._read_func(self._slave, self._verify_address, 1)
File "/srv/git/Lutemi/home-assistant-core/homeassistant/components/modbus/modbus.py", line 236, in read_coils
result = self._client.read_coils(address, count, **kwargs) |
Hmm you have some nice issues.
THANKS for the analysis, I will add a PR you can test either later today or tomorrow. |
|
If you or I find a way that will be in 2021.6. about 2: what if I leave the code in turn_on/turn_off and add this to update:
(code example, not real!), because the update is called independent of verify or not...with this the switch would be unavailable for SCAN_INTERVAL seconds and then go back to Available. WDYT ?
Thanks for your help. |
Breaking news: The new Switch will NOT be in 2021.5 (as I asked for), the documentation (New modbus switch. #17516) is only on Next !! So we have time, meaning lets do this right ! I really need help how to define the schema, and would really appreciate to see an idea from you. |
It also means that you HOPEFULLY do not have problems with 2021.5.0b7 ? |
Makes sense. Today I checked the documentation, and your changes were not there. Let's start with the schema. I will try to look into it tomorrow. |
I have submitted a PR solving issue 2) and 3), but I need your opinion (see #500117). Thanks for helping. I have also raised the question on discord. Btw. are you on discord ? I am janGranada. |
I was on Discord a long time ago. But if it helps with our communication, I might re-join :) |
The problem
With latest (nightly) Modbus code I am no longer able to toggle the Modbus switch.
I believe the error is related to PR #49910. I will investigate further whether I have a non-standard configuration, or if this is really an issue with our Modbus integration.
What is version of Home Assistant Core has the issue?
core-2021.6.0.dev0
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Core
Integration causing the issue
Modbus
Link to integration documentation on our website
https://www.home-assistant.io/integrations/modbus/
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information
No response
The text was updated successfully, but these errors were encountered: