How add date on this time automation?

I have an automation to turn on and off a z-wave switch according to the desired hours.
I want to add also the date and try multiple way, but it’s not working.
How can I add the date?

I have the date and time component installing
create new value:

input_datetime:
boiler_start:
name: Start Time and Date
initial: 00:00
has_date: true
has_time: true
boiler_end:
name: End Time and Date
initial: 00:00
has_date: true
has_time: true

boolen value:

turbo_boiler_timer:
initial: off

and the automation for the time (when the date is false)
- id: ‘xxxxxxx’
alias: Turbo Boiler Timer Stop
trigger:
- platform: template
value_template: ‘{{ states(’‘sensor.time’’) == (states.input_datetime.boiler_start.attributes.timestamp
| int | timestamp_custom(’’%H:%M’’, False)) }}’
condition:
- condition: state
entity_id: input_boolean.turbo_boiler_timer
state: ‘on’
action:
- data:
entity_id: switch.neo_coolcam_wall_switch_1_channel_switch
entity_id: switch.neo_coolcam_wall_switch_1_channel_switch
service: switch.turn_on

- id: 'xxxxxxx'
  alias: Turbo Boiler Timer Stop
  trigger:
  - platform: template
    value_template: '{{ states(''sensor.time'') == (states.input_datetime.boiler_end.attributes.timestamp
      | int | timestamp_custom(''%H:%M'', False)) }}'
  condition:
  - condition: state
    entity_id: input_boolean.turbo_boiler_timer
    state: 'on'
  action:
  - data:
      entity_id: switch.neo_coolcam_wall_switch_1_channel_switch
    entity_id: switch.neo_coolcam_wall_switch_1_channel_switch
    service: switch.turn_off
  - delay: 0:00:03
  - entity_id: input_boolean.turbo_boiler_timer
    service: input_boolean.turn_off

How to add the date when the date is also true ?

Take a look at how I control my Vacation Mode based on date and time - hope it helps:

input_datetime:
  ht_vacation_mode_on: 
    name: Turn Vacation Mode On When 
    has_date: true
    has_time: true
  ht_vacation_mode_off: 
    name: Turn Vacation Mode Off When
    has_date: true
    has_time: true


# Turn Vacation Mode On and Off
- alias: HT Turn Vacation Mode On
  trigger:
    platform: template
    value_template: "{{ states('sensor.date__time') == (states.input_datetime.ht_vacation_mode_on.attributes.timestamp | int | timestamp_custom('%Y-%m-%d, %H:%M', True)) }}"
  action:
    - service: input_boolean.turn_on
      data_template:
        entity_id: input_boolean.ht_vacation_mode
    - service: climate.set_temperature
      data_template:
        entity_id: climate.my_climate
        temperature: "{{ states('input_number.ht_vacation_temp') }}"


- alias: HT Turn Vacation Mode Off
  trigger:
    platform: template
    value_template: "{{ states('sensor.date__time') == (states.input_datetime.ht_vacation_mode_off.attributes.timestamp | int | timestamp_custom('%Y-%m-%d, %H:%M', True)) }}"
  action:
    - service: input_boolean.turn_off
      data_template:
        entity_id: input_boolean.ht_vacation_mode
    - service: climate.set_temperature
      data_template:
        entity_id: climate.my_climate
        temperature: "{{ states('input_number.ht_comfy_temp') }}"

You might have to replace “date__time” with “date_time” because I’m running on a relatively old version of HA.

Thanks,
I try to change to

sensor.time_date
but it’s not working, I choose the date and the time start, for the end I chose the same date and time after one minute.

I am using the same boolean for the automation, I see on your code you have two separated boolean variable.
It’s necessary to use two different boolean?

I receive an error on the date, I don’t understand why.
What can I try to fix this?

1 Like

The only boolean I use is input_boolean.ht_vacation_mode but I am using two separate input_datetime for turning vacation mode on and off.

Not sure I understand what you’re referring to.

I see, yes one boolean variable, you use the service boolean start and stop,they confuse me, because I don’t use them, I use condition to turn on the boolean instead call a service.

I try with the service call boolean to check, but the switch don’t turn on.
Maybe the date time format on the 0.88 is a little different to the old version?
The configuration check is OK, I see the automation through the gui.

When I use only the time without date, it’s working, the switch turn on/off by choosing time.

Did you also have on the date like my attached jpg the invalid date?

Maybe have you a suggestion can I try?

Let me try this in my V0.88 test environment - maybe my V0.75.3 is too much out of date.

Checked in my V0.88.0 test environment and in addition to changing date__time change to date_time I had to adjust the the ‘timestamp_custom’ parts from
timestamp_custom('%Y-%m-%d, %H:%M', True)
to
timestamp_custom('%Y-%m-%d, %H:%M', False)

Very strange this :confused:

Thanks,
I make mistake, I write time_date, I change it to date_time and add it also to the configuration sensor, now I have the date_time and the time_date in my sensor.

In the automation I use condition on the boolean, when I turn it on manually the automation is working when I turn it off the automation don’t work.
It’s just another way to use.

Thanks for your help :slightly_smiling_face:

1 Like