Replies: 1 comment
-
I noticed when I do this in my entity:
then I get actually my intended result of having a snackbar and a synced UI - with the added benefit of an immediate sync instead of the 2 seconds. So this seems to work fine, but I wonder if this is the intended operation and if this could affect automations in any way. Any further insight will be highly appreciated! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
While developing an integration I have noticed that it is not trivial to properly communicate an issue in a service call to the frontend. Suppose there is switch entity in the server. The async_turn_on() method talks to some device using some protocol. On this level you may run into issues preventing you from completing the call.
Following the dev docs, I tried raising an HomeAssistantError. This causes the frontend to display a nice toast whose content I can control (good!) - but at the same time the service call is aborted. The frontend's optimistic flick of the switch sticks! (bad!)
If I do not raise an exception, and of course don't modify the state in the entity, the frontend's optimistic flick of the switch is reverted after about 2 seconds. This is the well known flip-flop handling.
This discussion is decidedly NOT about that flip-flop handling. There are other places where this was discussed. What I would like to see is the combination of 1 and 2. If I got a toast AND the switch flipping back it would be perfect!
There are of course also persistent_notifications, but they seem to be bit heavy-weighted for my use case.
So - is there a reason for the current behavior? Or is there a better way to implement this for my entities?
Beta Was this translation helpful? Give feedback.
All reactions