Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95925

Automate sleeptime in weekend with set_datetime

$
0
0

@Gaijin66 wrote:

Hello everyone,

I have an issue i can’t resolve. Also I did not find any solution in the community. I try to put the lights out at a time that the user puts in via a input_datetime. I have a seperate time in the weekend. I use the following components in configuration.yaml:

sleeptime:
  name: Bedtijd
  has_time: true
  icon: mdi:sleep
  initial: '02:00'

sleeptime_weekend:
  name: Bedtijd weekend
  has_time: true
  icon: mdi:sleep
  initial: '04:00'

I use the following code in automations:

- id: '1579458127123'
  alias: Test
  description: ''
  trigger:
  - entity_id: input_datetime.sleeptime
    platform: state
  condition:
  - condition: template
    value_template: '{{ trigger.to_state.state != trigger.from_state.state }}'
  action:
  - data_template:
      time: {{ states('input_datetime.sleeptime') | timestamp_custom('%H:%M:%S', false) }}
    entity_id: input_datetime.sleeptime_weekend
    service: input_datetime.set_datetime

{{ states(‘input_datetime.sleeptime’) | timestamp_custom(’%H:%M:%S’, false) }} gives the correct time in the template editor. However it is not accepted in the time argument of input_datetime.set_datetime.

I hope anyone can help. Thanks in advance.

Posts: 10

Participants: 4

Read full topic


Viewing all articles
Browse latest Browse all 95925

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>