Need help for Input Datetime

My time is now 23:10
I want to perform automation on time

  1. In Configuration - Helpers - Add Helpers - Date and/or time - Create Time

  2. In automatios.yaml

- alias: Xiaomi OFF at clock
  trigger:
  - platform: template
    value_template: "{{ states('sensor.time') == (state_attr('input_datetime.time', 'timestamp') | int | timestamp_custom('%H:%M', True)) }}"
  action: 
  - entity_id: fan.xiaomi_miio_device
    service: fan.turn_off
  1. In configuration.yaml
homeassistant:
  time_zone: Asia/Yekaterinburg

sensor:
  - platform: time_date
    display_options:
      - time
      - date

time in sensor.time shows mine - 23:10 and input_datetime.time - 23:10

For Overview Creater new Card

cards:
  - entities:
      - entity: input_datetime.time
    show_icon: true
    show_name: true
    show_state: true
    theme: Backend-selected
    title: Xiaomi
    type: glance
type: horizontal-stack

It works, but the shutdown time doesnā€™t make it mine, but ā€œMy timeā€ - 5 hours. = UTC
So In order for it to turn off at my time I need to set 18:10

how can I fix this? why is he taking time out of my zone?

Simplify the trigger like : -

    trigger:
      - platform: template
        value_template: "{{ states('sensor.time') == states('input_datetime.id_switch_h1_tmeslt2_on') [0:5] }}"

Also you were using true in the timestamp custom which means utc (gmt)

This assumes has date = false
If you have date try [-8:-3]

1 Like

wow itā€™s working.
senk.
where can I view this description?

What description ?

I havenā€™t seen this before [0:5] or [-8:-3]

This is python.
It cuts the string proffered.
[0:5] (remember 0 is the first number) from the 1st character, upto but not including the 6th)
[-8:-3] is the same but progressing from the end

Iā€™m going to teach python
thanks for the help

You mean ā€˜learnā€™ python ?

A teacher, teaches and a pupil, learns

But be careful, only a subset of python commands are available to the jinja wrapped python passed to the sandbox