Trigger: for looking for a float... (Newbie question)

OK, one of the issues I have with yaml now is I know enough to be dangerous, but I don’t know enough to figure out if an error lies with my coding or with the program.

My issue is this… I am trying to program a user-selectable delay in powering off the bathroom fans, but I want to end timer with a bit of flourish. Instead of just powering down, I want to give the user a bit of a warning… [Off(2s)-on(10s)-off(1)-on(1)-off(1)-on(1)-off(1)]. But, I am getting an error that my for: command is looking for a float.

If I skip the fancy ending, I can simply change my mode (off of single), and use a delay in the action that works fine (using the same {{ }} command - so I’m sure the variable/entity is set up properly). So, what gives here? Is it a problem of mine, or a problem with the system? (The minutes:30 works fine, but if I comment that out and leave in the “math” part it breaks)

- id: 'KidsBathroomFanPower'
  alias: Kids Bathroom Fan Power
  description: ''
  trigger:
  - platform: device
    type: turned_on
    device_id: 9f016329303fd99319c8b74f2344b2
    entity_id: switch.kids_bathroom_fan
    domain: switch
    for:
      hours: 0
      #minutes: "{{ states('input_number.kids_bathroom_fan_timer')|float }}"
      minutes: 30
      seconds: 0
  condition: []
  action:
  - type: turn_off
    device_id: 9f016329303fd99319c8b74f2344b2
    entity_id: switch.kids_bathroom_fan
    domain: switch
  - delay: 00:00:02
  - type: turn_on
    device_id: 9f016329303fd99319c8b74f2344b2
    entity_id: switch.kids_bathroom_fan
    domain: switch
  - delay: 00:00:10
  - type: turn_off
    device_id: 9f016329303fd99319c8b74f2344b2
    entity_id: switch.kids_bathroom_fan

You cannot use templates with device triggers. Use a state trigger.

1 Like

Almost Certain it will be your coding
:rofl:

Edit: state triggers are standard, a lot of people think device triggers are a Spawn of Satan (nice bloke apparently)

100% agree there. :wink:

That being said, mf_social put me on the correct path.

id: 'KidsBathroomFanPower'
  alias: Kids Bathroom Fan Power
  description: ''
  trigger:
  - platform: state
    to: 'on'
    entity_id: switch.kids_bathroom_fan
    for:
      hours: 0
      minutes: "{{ states('input_number.kids_bathroom_fan_timer') | float }}"
      seconds: 0
  condition: []
  action:
  - type: turn_off
    device_id: 9f016329303fd99319c8b74f2344b2
    entity_id: switch.kids_bathroom_fan
    domain: switch
  - delay: 00:00:02
  - type: turn_on

looks like it will work

1 Like