Message malformed: expected float for dictionary value @ data['for']['minutes']

Hello,

I am trying to create an automation that turns a water valve off after a period of time. I have created a helper (input_number.water_minutes) but when I try and use the helper with minutes I get an error Message malformed: expected float for dictionary value @ data[‘for’][‘minutes’]

This is part of the config.

alias: "Turn water off after x mins "
description: ""
trigger:
  - platform: device
    type: turned_on
    device_id: d5548a4903401851d99d90987fe0547e
    entity_id: c5cfc413284dc15d0be20c50ddf29e79
    domain: switch
    for:
      hours: 0
      minutes: "{{ states('input_number.water_minutes') | int(0)}}"
      seconds: 0

Where am I going wrong?

You’re using a template in a device trigger: they don’t support that. Use a state trigger instead:

alias: "Turn water off after x mins "
description: ""
trigger:
  - platform: state
    entity_id: switch.YOUR_SWITCH_ENTITY_ID
    to: 'on'
    for:
      hours: 0
      minutes: "{{ states('input_number.water_minutes')|int(0) }}"
      seconds: 0

Always best to avoid device triggers and actions.

Brilliant! It works thanks for the help!

1 Like

Brilliant! It works thanks for the help!