this might be an unusual request/usage for AppDeamon, but I’m using it as bridge between KNX and my Philips HUE lights. I basically want to translate the HUE light states to KNX in order so see the current states (like on/off and color) in my switches, and I want to be able to control my HUE lights with KNX switches.
In general, I got this already working, but I’m having issues with smooth continuous state changes, like when I want to dim the light via a KNX switch. Dimming is done by long press of the KNX switch. In HA I get the according long press event and can then start the dimming process. As long as the button is pressed, the light should continue to dim. Since I only get a KNX event on long press start and button release, I need to continuously adjust the value until I get the release/stop event.
To achive this I currently use timers instead of a loop or alike. self.run_in(self.dim_light, self.DIM_DELAY, **kwargs). It does the job, but the result is anything but smooth. I want to update the state every 25ms and increase/decrease it by 5% so that I can see in the KNX switch (it has a display) the current dim value in percentage, since the HUE itself seems to have some delay. But for some reason, the dimming process from 0 to 100% doesn’t take 5 seconds like it should (20% per second) but something like 20 seconds. Does anybody have any idea what could cause this or what I might be doing wrong?
run_in schedules inside the AD loop. which runs 1 time every second
so even if you use run_in 0 it could take up to 1 second before the action is performed.
for actions that need to be that fast that wont work, and you cant get around time.sleep
allthough i have doubts about if 25 ms would work. (there are to many things that cant handle that)
but your calculations are a bit off.
25 ms for increase 5% would mean only 0.5 second from 0 to 100 and not 5 seconds.
so you want a state change every 250 ms, which can work.
sorry for bothering again, but I’m not that familiar with Python and AD. When I sleep in my AD app, wouldn’t that mean that my app can’t receive new signals? If so, I’d never receive the stop event, would I?
edit: kinda seems to work. So my KNX switches update the status pretty quickly, but the HUE events seem to queue up and be executed with quite some delay. Since the KNX and HUE update are both triggered via self.call_service() and KNX is updating as expected, I don’t think that it’s an issue of AD and it’s internal clock. So it’s likely the HUE integration or HA that causes the delay. But since I don’t feel like directly messing with the HUE protocol right now, I probably have to live with it for now.