#Next start and next end entity for a schedule

1 messages · Page 1 of 1 (latest)

hearty swift
#

Hi. I have a schedule that holds the info for when we have peak energy pricing. I would like to run automations with an offset to that. So for example "30 minutes before peak energy pricing goes into effect". Schedule doesn't allow this kind of trigger as far as I can see, so I'd need a time helper. I created a 'next start' and a 'next end' helper. But it looks like the only date I can get from a schedule is whatever the next change is. So the best I could come up with is an automation that runs on every change and does this:

  - action: input_datetime.set_datetime
    metadata: {}
    data:
      datetime: "{{ state_attr('schedule.peak_energy_pricing', 'next_event') }}"
    target:
      entity_id: |
        {% if is_state('schedule.peak_energy_pricing', 'on') %}
          input_datetime.peak_energy_pricing_next_end
        {% else %}
          input_datetime.peak_energy_pricing_next_start
        {% endif %}

That kind of works, but of course the issue is that if the time helpers are out of date for whatever reason, it takes a full cycle for it to be updated to the correct value again. Is there a better way to do this?

main jewel
#

You could also give it the rigger of HA start. That would only fix the next state. But as the entity hold no info other than the next event it's not possible to do more.

hearty swift
#

good point. I'll add that.

potent crater