Replies: 2 comments
-
Perhaps you could break the loop by not changing the state (of the bulb or switch) if it already has the correct value? You'd have to make sure that rounding etc doesn't cause the round-trip computed desired values to differ, or add some tolerance (eg, don't change the other value if it's within 1% of the target value). |
Beta Was this translation helpful? Give feedback.
-
Yeah... I thought about that but it doesn't entirely solve the issue. For example Starting State Set Lamp 1 to on. State change triggers and it sends Switch 1 on. This in turn triggers a state change causing a on command to get sent to all the lamps.... Honestly I may just need to store the state in python. Store the on/off/brightness of each. And only set things when the state differs from what I think it should be. Basically I need a way to tell if the state update was triggered by the user or homeassistant... or internally as a "sync" between the switch and lamps. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Normally I would use something like a mutex to accomplish this (an I am trying to use task_unique, but doesn't seem to be doing what I need) so I could use a little advice. General setup is that I have 3 Smart Bulbs and an Inovelli switch (which has an LED bar to display brightness). The inovelli switch is in a smart bulb mode so the internal relay is always on and the on/off/brightness states are just virtual to work the LED bar. Currently there isn't really a good way in just zigbee to get them all tied together so I figured pyscript would be perfect.
My goal is to have it setup such that the LED bar displays the average brightness of the lamps that are on, or is off when they are all off. I want the button presses to send on off and set birghtness to ALL of the bulbs.
The way I was planning to make this work is monitor for state changes (on/off/brightness) on any of the bulbs and use that to set an on/off/brightness command to the switch.
Also monitor for on/off/brightness on the switch and then send the appropriate command to the lights.
The issue is that that creates a loop. Say you turn on lamp 1... that triggers a state change which then sends a on w/ brightness to the switch. But that triggers its own state change on the switch... etc. And it just goes back and forth.
I don't think task unique will work because the task may actually finish by the time zigbee sends the command, gets the state change back, and home assistant processes it.
Any good suggestions for how to handle this?.... Thanks.
My thought would be something like a global counter... so the first event triggers and count + 1.... then the second event triggers a count - 1.... and I only send triggers if count = 0. Something like that. But that seems janky.
Beta Was this translation helpful? Give feedback.
All reactions