Use state for time trigger

I’m not sure if I’m using the correct procedure but I would like an action to trigger when the current time matches a set state every day. I’m getting the time state from an online REST request and storing in a state in “HH:MM:SS” format and this may or may not change each day. I would like to have an action started automatically at when the time matches the state.

I am able to manually enter the time in the trigger as something like 12:00:00 but when I do mystate.time, I get Message malformed: Invalid time specified: mystate.time for dictionary value @ data['trigger'][0]['at'] error.

Is this the correct way of going about it or should I be storing the state as something else like a sensor or something?

Template trigger, if time = time state etc.

1 Like

Great, thanks for the quick reply!

1 Like

I’ve come back to this and actually not able to get it working. Here’s what I have in my automation.yaml

- action:
  - data:
      entity_id: media_player.oj_speaker
    service: media_player.volume_up
  alias: Test Trigger
  condition: []
  id: '1518307129123'
  trigger:
  - platform: template
    value_template: '{{ states.mystate.time == states.sensor.time.state }}'

I have verified in the states that they are the same and have tried the action by running it manually and that works. But when I put it in this automation, it never seems to trigger.

I found this similar thread which seems to be trying to do something similar.

states.mystate.time.state ?

1 Like

Just got a chance to try it and that worked. thanks!

1 Like

No worries - glad you got sorted :+1: