SOLVED: Input datetime and input boolean automation not firing

Hi,

First post here, so apologies if posted in the wrong location.

I have an recently made my slow cooker “smart” with a TP-Link plug and have been attempting to make an “interactive” front end card with an automation behind it for turning the slow cooker on and off at user defined times.

I’m struggling with the automation though, and wondered if anyone here could help.The automation is below:

- alias: Turn on Slow Cooker
  trigger:
  - platform: template
    value_template: "{{ states('sensor.time') == (states.input_datetime.slow_cooker_on_time_input.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"
  condition:
  - condition: state
    entity_id: input_boolean.slow_cooker_on_timer_active
    state: 'on'
  action:
  - service: switch.turn_on
    entity_id: switch.slow_cooker

It is my aim that at the time in the template (pre-defined through the frontend), the slow cooker will turn on, provided that the input_boolean switch is also on. The front end card looks like this:

image

Hassio reports no errors through “Check Configuration”, so the code itself doesn’t produce errors, however also doesn’t fire the automation.

Any help is much appreciated.

Joshua

Solution was to ensure that the sensor.time was set in the sensor.yaml file so that the automation had a time for comparison. All sorted now.

Can you format your post? Also, you probably don’t need to use the timestamp for the comparison. If I recall correctly (can’t check on phone) the state of a datetime is the same as sensor.time as long as the datetime doesn’t contain a date as well as time.

Also, I Believe you need to remove the ,false on the custom timestamp because it puts your time in UTC

It looks identical to multiple automations I have comparing time to an input boolean, and they work every day for me. EDIT: the False makes it local time. True is 0GMT.

@JAD92 Make sure the automation is turned on in the states page

1 Like

Yah I’m on my phone, I wasn’t sure what the true/false did off the top of my head

1 Like

Reformatted the post as requested. I spotted it when I originally posted - had selected the wrong option in the formatting options.

I’ve also realised what I hadn’t been doing… And it is really stupid.

I hadn’t set up the time sensor in my sensor.yaml file. I had wrongly assumed that it would use the normal time platform that I’ve used as a trigger for other automations. Now the sensor is set up, and it is able to match the actual time with the defined time, it is working well.

Thanks for the help though!

1 Like

To be honest, I wish the sensor.time was in the standard config. This happens quite frequently and many people don’t realize it’s not standard.

1 Like

Sorry, can you share all the code (Automation, Configuration.yaml) that u use for this cooker timer?

Hello,
Can you please share all of your code for this?
Thank you