Input_time component for automation

It would be great to have a easy input_time component for simple automation.

Many people have done it in various forms in the topic here:

But I think it would be great to have a simple component which just shows the time and on click opens a new card (similar to the climate component) to set the time.

The value could then be used for the automation rules.

I am using the following config to generate my time based automation:

input_slider:
  auto_heat_hour:
    name: Hour
    icon: mdi:timer
    initial: 6
    min: 0
    max: 23
    step: 1
  auto_heat_min:
    name: Minutes
    icon: mdi:timer
    initial: 5
    min: 0
    max: 55
    step: 5
  auto_heat_duration:
    name: Duration minutes
    icon: mdi:timer
    initial: 50
    min: 1
    max: 120
    step: 5

sensor:
  - template:
     auto_heat_time:
        friendly_name: 'Heating start'
        value_template: '{{ "%0.02d:%0.02d" | format(states("input_slider.auto_heat_hour") | int, states("input_slider.auto_heat_min") | int) }}'
      auto_heat_duration:
        friendly_name: 'Heating duration'
        value_template: '{{ "%2d minutes" | format(states("input_slider.auto_heat_duration") | int) }}'

automation:
  - alias: "auto_heat_on enabled"
    trigger:
      platform: state
      entity_id: input_slider.auto_heat_hour, input_slider.auto_heat_min, input_slider.auto_heat_duration
    action:
    - service: homeassistant.turn_on
      data:
        entity_id:
          - automation.auto_heat_on
    - service: homeassistant.turn_on
      data:
        entity_id:
          - automation.auto_heat_off
  - alias: 'auto_heat_on'
    initial_state: True
    trigger:
      - platform: time
        minutes: '/5'
        seconds: 14
    condition:
      - condition: template
        value_template: '{{ (now().strftime("%s") | int | timestamp_custom("%H:%M")) == states.sensor.auto_heat_time.state }}'
    action:
      - service: climate.set_temperature
        data:
          entity_id: climate.ethermostaat
          temperature: 19
  - alias: 'auto_heat_off'
    initial_state: True
    trigger:
      - platform: time
        minutes: '/5'
        seconds: 14
    condition:
      - condition: template
        value_template: '{{ ((now().strftime("%s") | int - (states("input_slider.auto_heat_duration") | int) * 60) | timestamp_custom("%H:%M")) == states.sensor.auto_heat_time.state }}'
    action:
      - service: climate.set_away_mode
        data:
          entity_id: climate.ethermostaat
          away_mode: True

It shows as:

So what I would like to have is basically an input which has the value of the time accessible in timestamp format and on click you can adjust the values of the hour and minutes with the sliders. that would simplify the rules quite a bit.

4 Likes

Yes yes please. and make a dashboard widget for it too when you do it. :wink:

Very nice.thank you

Can u just post all groups and stuff for this awesome timer??

The code above is only missing the time sensor component and a group which contains all those items. So it is rather complete, I think.

So I guess it’s in 0.55 now?

I just don’t know how to actually use it. If anyone can help…?

I’m also interested how this input datetime can be used with the above climate example

Can anyone help me?

I have this automation:

- alias: 'Ochtend Verwarming'
  trigger:
    platform: state
    entity_id: input_number.morningheatinghour, input_number.morningheating_min, input_number.morningheatingduration
  action:
  - service: homeassistant.turn_on
    data:
      entity_id:
        - automation.morningheating_on
  - service: homeassistant.turn_on
    data:
      entity_id:
        - automation.morningheating_off

- alias: 'morningheating_on'
  initial_state: True
  trigger:
    - platform: time
      minutes: '/5'
      seconds: 14
  condition:
    condition: and
    conditions:
      - condition: template
        value_template: '{{ (now().strftime("%s") | int | timestamp_custom("%H:%M")) == states.sensor.morningheating_time.state }}'
      - condition: state
        entity_id: input_boolean.morningheatingstatus
        state: 'on'
  action:
    service: scene.turn_on
    entity_id: scene.Ochtend_Prog_aan

- alias: 'morningheating_off'
  initial_state: True
  trigger:
    - platform: time
      minutes: '/5'
      seconds: 14
  condition:
    condition: and
    conditions:
      - condition: template
        value_template: '{{ ((now().strftime("%s") | int - (states("input_number.morningheatingduration") | int) * 60) | timestamp_custom("%H:%M")) == states.sensor.morningheating_time.state }}'
      - condition: state
        entity_id: input_boolean.morningheatingstatus
        state: 'on'
  action:
    service: scene.turn_on
    entity_id: scene.Ochtend_Prog_uit

Second automation doesn’t trigger.

How to solve?

The conditions are only checked every 5 minutes. What are you input values?

input_number.morningheatingduration

If your set times are not a multiple of 5 the trigger will never match. You could try to set the minutes to '/1' in the trigger.

1 Like

Yes! That was it! I had 5min steps but starting at 1 min, so it was always 1 or 6 or 11 etc.

Thanks!

@daenny can you share the full corrected config please.

thanks

I use a template trigger for this instead of checking once a minute or every five minutes.

- platform: template
  value_template: '{{ states.sensor.time.state == states.sensor.chicken_door_time.state }}'