How to best represent timers/countdowns?

okey, cool - I’m trying to make it so I can generate those packages with templates so I can at least avoid having to update 6 different files for each area with a motion sensor.

I’m seeing the same issue here.
While the countdown timer works nicely in the standard UI as a badge, it fails to countdown in Lovelace.

Setup is as follows:

configuration.yaml

timer:
  countdown:
    duration: '00:20:00'

ui-lovelace.yaml

      - type: entities
        title: Timer
        entities:
          - entity: timer.countdown
            name: "Remaining Time:"

im trying to get the packages !include_dir_named packages to work by creating a packages folder and put the content of what you pasted verbatim in afiled called motionlight.yaml.

The result is this error:
expected a dictionary for dictionary value @ data['packages']['motionlight']

any idea on what can cause this ?

maybe any chance you have your config shared somewhere ?

thanks again!

okey so I accidentally deleted the first line and that gave that error…

Here is what I actually have in my file:


automation:
  - alias: Turn on winter garden when there is movement
    trigger:
    - platform: state
      entity_id: binary_sensor.presence_winter_garden
      to: 'on'
    action:
    - service: timer.start
      entity_id: timer.timer_winter_garden
    - service: homeassistant.turn_on
      entity_id: group.winter_garden_lights
  - alias: Turn off winter garden lights at end of timer
    trigger:
    - platform: event
      event_type: timer.finished
      event_data:
        entity_id: timer.timer_winter_garden
    action:
      service: homeassistant.turn_off
      entity_id: group.winter_garden_lights

timer:
  timer_winter_garden:
    duration: '00:05:00'

which gives me:

Invalid config for [automation]: required key not provided @ data['action']. Got None
required key not provided @ data['trigger']. Got None. (See ?, line ?). Please check the docs at https://home-assistant.io/components/automation/

afaics its exactly like yours…I even tried copying yours verbatim whichs gives me similar:

automation:
- alias: Turn on office lights when there is movement
  trigger:
  - platform: state
    entity_id: binary_sensor.office_presence_sensor
    to: 'on'
  action:
  - service: timer.start
    entity_id: timer.timer_office
  - service: switch.turn_on
    entity_id: group.office_light
- alias: Turn off office lights at end of timer
  trigger:
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.timer_office
  action:
    service: switch.turn_off
    entity_id: group.office_light

timer:
  timer_office:
    duration: '00:05:00'

Under action, 2 spaces are missing before “- service” and before “entity_id”
Same for the trigger entry.

i thuoght that too but even when I get things indented I keep getting same error ;/

in this I dropped the use of include_dir… (for now)

  packages: 
    pack1:
      automation:
        - alias: Turn on winter garden when there is movement
          trigger:
            - platform: state
              entity_id: binary_sensor.presence_winter_garden
              to: 'on'
          action:
            - service: timer.start
              entity_id: timer.timer_winter_garden
            - service: homeassistant.turn_on
              entity_id: group.winter_garden_lights
        - alias: Turn off winter garden lights at end of timer
          trigger:
            - platform: event
              event_type: timer.finished
              event_data:
                entity_id: timer.timer_winter_garden
          action:
            - service: homeassistant.turn_off
              entity_id: group.winter_garden_lights

      timer:
        timer_winter_garden:
          duration: '00:05:00'```

so via Invalid config for [automation]: required key not provided @ data['action'] I found that if I comment out automation: !include automations.yaml then the check passes.

no idea why that should matter since my automations.yaml is empty :slight_smile:

Your automation.yaml being empty might actually be an issue - I recall following a discussion here where linking to an empty automation file cause issues, so somebody created a dummy automation in the yaml-file:

1 Like

fyi I opened https://github.com/home-assistant/home-assistant/issues/18821 and after submitting found a bunch of other issues having related issues with timers that I linked in too.

Hopefully we can get that cleaned up :slight_smile:

1 Like