-
Notifications
You must be signed in to change notification settings - Fork 22
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
v3.x.x and 2.x.x Gives Duplicate status update events with auto_update or websockets enabled #145
Comments
I have been having difficulties with this for a few days now. I have one light that gives errors quite often, and so have implemented a retry mechanism. However, there is a problem.
This triggers a
However the status value is incorrect. this is because when you send the So, if you send a With the new Asyncronous library, I can actually see no use for the hint mechanism at all. Either the light turns on/off and the status gets updated when it responds, or it doesn't, in which case the status is correct not to change. I have disabled the hint update mechanism in Are there some circumstances where the hint mechanism is needed? say the light does actually change, but you get a communications error, so you assume the command worked? Just wondering what the hint mechanism is for. I would suggest removing the hint mechanism in favor of real-time updates. |
Thanks for the input. Sorry I haven't had much time to dig in to this yet, but I hope to in the next few weeks. I will play with turning off the hint again. I tried it on the original take of v2, but I hated that the toggles would 'bounce' in Home Assistant's Lovelace interface. Hopefully things are a bit quicker in V3, but I may also just try reworking the hint mechanics all together to provide an internal 'pending' status that doesn't trigger the events. |
Expanding on this... The biggest reason I think that hint was added by @rmkraus originally would be interface lag. You click a toggle, it should go to ON, but the status hasn't updated back from the ISY so the interface moves it back to OFF, then the ISY updates the status so it turns to ON. This is the 'bounce' I mentioned above. This does have its pitfalls for when the ISY doesn't actually do what you commanded and your interface is out of sync. This would be easier if the ISY's response to the REST command told you if the end device actually responded to the command, then you could just watch for the response, and update accordingly. However an This is where I think there's some room for a pending status/command timeout structure to take the place of the hint. Basically we'd assume the status changes on a successful command to the ISY ( |
I actually implemented a retry mechanism. You send the command, and add it to a pending_commands dictionary. If the change state event comes in, the state is published and the command removed from the pending_command dict. If the state has not updated after 5 seconds, the command is resent. There are 5 retries before I give up.
Nick Waterton P.Eng
Sent from my iPhone
On Dec 18, 2020, at 8:20 PM, shbatm <notifications@github.com> wrote:
Are there some circumstances where the hint mechanism is needed?
Expanding on this... The biggest reason I think that hint was added by @rmkraus<https://github.com/rmkraus> originally would be interface lag. You click a toggle, it should go to ON, but the status hasn't updated back from the ISY so the interface moves it back to OFF, then the ISY updates the status so it turns to ON. This is the 'bounce' I mentioned above.
This does have its pitfalls for when the ISY doesn't actually do what you commanded and your interface is out of sync.
This would be easier if the ISY's response to the REST command told you if the end device actually responded to the command, then you could just watch for the response, and update accordingly. However an 200 OK response just tells you the ISY accepted the command and is processing it/sending it the devices.
This is where I think there's some room for a pending status/command timeout structure to take the place of the hint. Basically we'd assume the status changes, but do a better job of watching for communication errors reported by the ISY, and revert the status if it failed.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#145 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ACYJIZ6UWVXMESXLJHONUNLSVP5S5ANCNFSM4UQWYYVQ>.
Unsubscribe from GE's commercial electronic messages: http://sc.ge.com/*casl-unsubscribe
Désabonner des messages électroniques commerciaux de GE: http://sc.ge.com/*lcap-desabonnement
|
I'll take a look at your branch when I get time to play around. An expanded command queue with retries for both REST call and comms errors is a good idea. |
I’ll post it somewhere, I don’t think it’s up yet, I just subclass pyisy.
Nick Waterton P.Eng
Sent from my iPhone
On Dec 18, 2020, at 8:36 PM, shbatm <notifications@github.com> wrote:
I'll take a look at your branch when I get time to play around.
An expanded command queue with retries for both REST call and comms errors is a good idea.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#145 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ACYJIZ6WCILIG2X2MVF7K5TSVP7Q3ANCNFSM4UQWYYVQ>.
Unsubscribe from GE's commercial electronic messages: http://sc.ge.com/*casl-unsubscribe
Désabonner des messages électroniques commerciaux de GE: http://sc.ge.com/*lcap-desabonnement
|
My implementation is here https://github.com/NickWaterton/ISY_MQTT/tree/main As I say it just subclasses pyisy (but in my copy of pyisy the hint mechanism is disabled) |
@NickWaterton - I opened a new PR for the V3.x fix, which just removes the hint feature entirely and relies on the ISY sending an update in the event stream (or a manual @bdraco - We talked about this a while back on Discord. Seems like a net zero effect in Home Assistant, Lovelace now has debounce on the UI toggles so everything seems to work fine without the hint. If a command fails from the ISY to the end device, the toggle will eventually (~3s) fall back to the old status (similar to my Zigbee2mqtt devices when they fail). Let me know if you think the subsequent communication error should be elevated to an exception to generate a toast message, right now it's just an error and an |
If the action the user is performing fails, we should raise an exception to feed back to the UI. If the action fails later we don't really have a way to feed it back to the user except logging. I think its fine to remove the optimistic state change since the websocket is fast enough to deliver the event back to the state machine. |
XREF: shbatm/hacs-isy994#85 |
Thanks for the pointer to this discussion. It does seem like the retry mechanism that you're discussing would help with the issue that I'm seeing, but unrelated to the issue above. The typical case for me is that turning on a bunch of lights causes the ISY to sporadically respond with "404" (not found) errors via REST, resulting in the light not being turned on and the error mentioned in that issue. It's been happening forever with no indication that UDI will change the behavior, and it seems like an inappropriate error message to indicate that the Insteon network is "busy" (as UDI has diagnosed). In any case, I look forward to having commands retried if they fail. |
This looks to be true of the 2.x version as well, but I'm on 3.x.x.
When
auto_update
is enabled, oruse_websocket
is enabled, you get two notifications for every command sent. This doesn't happens withoutauto_update
enabled, because thenode.status
is not updated with thehint
.When you send a command eg
node.turn_on()
, and you are subscribed tostatus_events
for that node, you get twochanged
events triggered.This is because the
turn_on()
command updates thenode.status
with thehint
value, which triggers a notify event fromnodebase.py
:Then you get a second trigger when the actual device changes to the new state, and you get an ST notification, which triggers a
node.update_state
This triggers another notification event, because updating
node.status
does not updatenode._formatted
, soupdate_state
findsstate.formatted != self._formatted
isTrue
and triggers anotherstatus_events.notify
.I believe the error in in
node.py
async def update
which is supposed to updateself._status
notself.status
.ie:
Which works as expected.
The text was updated successfully, but these errors were encountered: