arthurdent75 / SimpleScheduler

An Home Assistant AddOn to schedule entities on/off on weekly base
183 stars 36 forks source link

[FR] Retrigger current state while running #70

Closed Kaibob2 closed 2 years ago

Kaibob2 commented 2 years ago

Would it be possible to implement an option to re-trigger a running schedule? In other words: Looking at my cover schedule: I have a schedule which switches an input_boolean on from 08:00 until 18:00 and this triggers a quite complex automation in NodeRed respecting brightness, rain and so on. If nothing unusual happens the schedule works fine, but if I interfere manually the actual position of the covers no longer corespond to the scheduled state. This is pretty normal, but when I then decide to synchronize again there is no way doing that. I would be happy to have (for example) a service that's called trigger_schedule which expects switch.simplescheduler_xxxxxxxx_cover_yyyyy as data. When called the schedule just sends the current state for the respective schedule.

arthurdent75 commented 2 years ago

Instead of triggering the binary_input with the scheduler, create a script that do that and trigger it with the scheduler. Then, when you need to "re-trigger" you just call the same script you call from the scheduler.

Kaibob2 commented 2 years ago

That's not what I meant. I need to tell the schedule itself to emit the current state. In the example above the schedule would re-send on again if triggered at 15:00. The nodered automation (or the script) requires the on or off as input. The state depends on the time of the day. If I would trigger the script directly, I would need two different scripts. Further it's not about manual triggering by hand, but synchronizing the state of the schedules with the actual position of covers.

arthurdent75 commented 2 years ago

I still don't get it the point of that... Anyway... What you ask is something like "Execute now" for the ON and/or the OFF actions? At the moment there is no support for add this feature as a service. What I could add is the commands "Execute OFF now" and "Execute ON now" from frontend

Kaibob2 commented 2 years ago

Okay, I try to explain it even more detailed: I have several schedules, one for each cover in the house. We only look at one of them now, let's call it schedule.cover1. This schedule toggles a input_boolean (let's say input_boolean.cover1) on a weekly schedule. In this example we say it switches on at 8:00 and off at 18:00. So this is what happens:

The solution would be, to have any kind of possibility to make schedule.cover1 emit the current state again. In this example it would be like:

With only one cover it would eventually be possible to synchronize cover position and schedules by hand, but I have over 10 covers which could all be in different positions at different times of the day, so it would be nice to have the option to automate synchronization.

Maybe it's an option to update the state when enabling a schedule if a deidcated update function is over the top in your opinion.
Then I could disable and right after enable all schedules again and all covers would be in the state each schedule has at that time.

arthurdent75 commented 2 years ago

Ok, I think I understand... and I think there is a misconception on how the addon works... So I will try to explain that. Let's have an example: I have a simple schedule (pun intended 😉)
it turns ON at 08:00 AM it turns OFF at 09:00 AM

The addon every minute (at second zero) loads all the schedulers and checks if any of them needs to be turned ON or OFF So, at 08:00 it finds the ON command and executes it. Then it checks at 08:01, 08:02, and so on... until at 09:00 it finds the OFF command. So the addon at 08:30 (or any other time between the ON time and the OFF time) IS NOT AWARE of the state of the device and it DOESN'T CARE of what the state should be. It sends the command and finished its job. You could turn it off and on thousand times between 08:00 and 09:00 and the addon would not care. The addon will just send a turn_off at 09:00 (even if the device is already off)

Hope that this clarifies how it works and answers your questions.

Kaibob2 commented 2 years ago

Uhhh, I see, thanks for the clarification! Absolutely my fault not getting it right. I was using the scheduler component together with its card before and there it was an option to resend the current state. BUT now I understood the difference. The scheduler component uses timeslots in which an entity is is whether on or off. Your Addon just sends an on or off and one single time. The scheduler component was pretty nice, but lacked a weekly schedule. That's why I converted to your addon and will stay with it. I'll find a way to implement what I tried to describe above 😊