Timer related question

Dear All,

please help me understand what is the problem with the following setup.
The scenario is that I want to run my AC for a while after I fall asleep but not overnight.
The original plan was to create a script that starts a timer and the AC and an automation counterpart that stops the AC when the timer finishes. This is the first time I’m using the timer component so there might be problems with my understanding.

So the timer is defined like this:

timer: 
  sleep: 
    duration: 00:30:00

The script is set up like this:

'1527807975408':
  alias: Sleeping AC
  sequence:
  - data:
      entity_id: timer.sleep
    service: timer.start
  - data:
      entity_id: climate.living_room_hvac
      operation_mode: cool
    service: climate.set_operation_mode
  - alias: ''
    data:
      message: '{{states(''timer.sleep.remaining'')}}'
      notification_id: 123
      title: Time Left
    service: persistent_notification.create

and the automation:

- id: '1527808056871'
  alias: Stop Sleeping AC
  trigger:
  - event_data:
      entity_id: timer.sleep
    event_type: timer.finished
    platform: event
  condition: []
  action:
  - data:
      entity_id: climate.living_room_hvac
      operation_mode: none
    service: climate.set_operation_mode
  - data:
      notification_id: 123
    service: persistent_notification.dismiss

I have two questions:

  1. the AC starts as it should but it does not stop, can you tell me what’s wrong?
  2. the persistent notification displays the remaining time as unknown. Any ideas why?

Thanks!!

B

Look at this bit of code from one of the configurations from the cookbook.

####################################################

Air Conditionar Self Shutdown

####################################################

  • id: AC_Self_Shut
    alias: AC Self Shutdown - Heat
    trigger:
    • platform: state
      entity_id:
      • switch.air_conditioner__heat_30
        state: ‘on’
        for: ‘02:01:00’
        action:
    • service: switch.turn_off
      data_template:
      entity_id: " {{ trigger.entity_id }} "
    • service: notify.homenicoassistant_bot
      data_template:
      message: >
      “{{ trigger.to_state.attributes.friendly_name }} just changed from {{ trigger.to_state.state }}
      to {{ trigger.from_state.state }} - AC Selfshutdown Automation - Heat 30 Mode OFF”

Sorry don’t know from whom it came so I could give him credit.