Problems with automation and input_datetime

Hello,

already searched within the forum and found some useful answers, but i am sure i miss something simple to make my automation work. Surely someone can help me poin t into the right direction.

Szenario: i would like to have a config for the time my blinds go down and up, beside one boolean switch to start/stop the automation.
To makie the following shorter, i only added the one for shutdown.

So i created my input_boolean (to start/stop automation)

input_boolean:
  auto_blinds:
    name: "Automation start stop"

In addition, added the input_datetime (time to sutdown and rollup the blinds):

input_datetime:
  blinds_on:
    name: An
    has_date: false
    has_time: true
    initial: '09:00'

After this, i added my automation:

- alias: automation_close_blinds
  trigger:
    - platform: template
      value_template: '{{ states.sensor.time.state == (states.input_datetime.blinds_on.attributes.timestamp | int | timestamp_custom("%H:%M", False)) }}'
  condition:
    condition: state
    entity_id: input_boolean.auto_blinds
    state: 'on'
  action:
    service: cover.close_cover
    entity_id:
      - cover.fibaro_system_fgrm222_roller_shutter_controller_2_level 

But my automation does not trigger.
Thanks for any hints in advance!

Regards, Ralf

I am not sure if I am the right person to answer this, but here is what I think:

timestamp_custom("%H:%M", False))

I am not sure why you used False here, but I think it is not needed. Can you explain why you used it?

Hello,

i used this as it is in the example of the input_datetime component.

Regards, Ralf

In your template:

  trigger:
    - platform: template
      value_template: '{{ states.sensor.time.state == (states.input_datetime.blinds_on.attributes.timestamp | int | timestamp_custom("%H:%M", False)) }}'

you are are giving the value “false” for the timestamp. I dont think it works like that. I am not an expert in templating, especially time and date, but as far as I know, the “false” you used, is not supposed to be there.
This template epxresses that:
“When the time matches the time I entered, then trigger the automation”, so:

  trigger:
    - platform: template
      value_template: '{{ states.sensor.time.state == (states.input_datetime.blinds_on.attributes.timestamp | int | timestamp_custom("%H:%M")) }}'

Again, I am not sure if I am right, just guessing that this “false” you used there is your problem. Try without it.

Edit: Sorry! I just read a bit lower and saw the automation examples clearly. I see what you did there.

Hello,

just found the error: the value_tenmplate was wrong. Correct and working is:

value_template: '{{ states.sensor.time.state == (states.input_datetime.blinds_on.attributes.timestamp | int | timestamp_custom("%H:%M", False)) }}'

Regards, Ralf

I don’t see any difference to your original template. What did you change?

I’m not sure what he changed but his original one should have worked regardless.

I’m guessing his date_time setup is wrong because he has it set to 9 minutes unless input_datetime only takes “HH:MM” as it’s input. That in itself seems odd because HA uses “HH:MM:SS” everywhere else.

Yep, they only take HH:MM.

weird. Oh well.

What’s weird is that you don’t use them :slight_smile:
With all your crazy good templating skills you never need to input a time in the front end?

Nope, not yet. I’d have to get my wife to start using the interface in order to fully use a control like that. I probably should just add a sensor.time and a datetime to help people here. Currently, I don’t use any templating in automations because my automations are in AppDaemon.

1 Like

Sory, my fault.

The correct teplate is (as in the example of datetime component):

value_template: "{{ states('sensor.time') == (states.input_datetime.bedroom_alarm_clock_time.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"
2 Likes