nielsfaber / scheduler-component

Custom component for HA that enables the creation of scheduler entities
GNU General Public License v3.0
655 stars 41 forks source link

Add the ability to use sensor.smartphone_next_alarm as trigger #154

Closed Ro4cHii closed 2 years ago

Ro4cHii commented 2 years ago

Checklist

Proposal

Hey there,

I would really love to see the feature of using your smartphone's "next alarm sensor" - as provided by the official Home Assistant app for Android (and I guess iOS, too) - as a trigger for schedules (similiar to the sunrise/sunset trigger).

Additional info

In the panel where you can specify the trigger time, display a second (alarm) button next to the "sunrise/-set" button in case a sensor with device_class=timestamp has been included in the scheduler options.

Sample

entity_id: sensor.huawei_next_alarm

nielsfaber commented 2 years ago

I don't consider this as a good addition. The essence of scheduler is that you use it to pick the time on which you want to trigger a job. If you want to trigger an action based on the state of another entity, there is no added value of using scheduler compared to a normal HA automation (other than the card being a GUI for maintaining your automations). I don't want to go this route.

Ro4cHii commented 2 years ago

What a pity! I think this would be a really cool feature (especially to have it in the GUI). Personally, I would use it on a daily basis to control the position of my roller shutters. Since there are often days where you don't wake up on the exact same time, the benefit of the trigger time simply adapting to my alarm clock would be huge. In terms of functionality, (at least I think) it shouldn't differ too much from the sunrise/-set feature which is also a flexible point of time.

But of course I can understand if you do not want to implement this feature. Maybe you have a better idea to unify such an undertaking in a common GUI! (since I really love the scheduler card with its possibilities)?

Kind regards

nielsfaber commented 2 years ago

You might be able to achieve what you want by 'faking' the sun entity: https://github.com/nielsfaber/scheduler-component/blob/7575b89142a601229f4faa158633937b032d1fd8/custom_components/scheduler/const.py#L22

If you replace that line with a (templated) binary_sensor entity, you can use your own (alarm clock) time for sunrise and sunset. Note that the binary_sensor needs to have the next_rising and next_setting attributes (same as the sun.sun entity) for defining the sunrise/sunset timestamps.

Otherwise I think your request is very specific and not worth the effort involved, I'm sorry.

calisro commented 2 years ago

Couldn't this really be just a condition of the schedule and let it re-evaluate till true? condition would be a sensor or similar for the entity_id: sensor.huawei_next_alarm

Ro4cHii commented 1 year ago

The more I think about it, the more I still miss this feature. Faking the sun entity doesn't sound feasible to me since I also use that one and would destroy its functionality.

Out of curiosity: Would you accept a pull-request I were to add this feature on my own?