I have this script level40 which is called by this automation: level40
(alias: level 40
description: ""
trigger:
- platform: time
at: "05:00:00"
condition: []
action:
- service: script.level40
data:
level: "40"
mode: single)
script: script.level40
alias: level 40
variables:
value: level
sequence:
- type: turn_on
device_id: beeb5ed9c3b3f08143dd26af5b91fb73
entity_id: 049e9fe7159959f9448c0e244ad44d70
domain: switch
enabled: true
- delay:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
enabled: true
- repeat:
until:
- condition: or
conditions:
- condition: numeric_state
entity_id: sensor.0xcc86ecfffe3ab382_power (# this is a powerplug)
below: 2
- condition: numeric_state
entity_id: sensor.sm_a546b_battery_level
above: 55 # I want to change this to above {level}. How can I make that work?
sequence:
- delay: # if I remove this my zigbee powerplug goes off-line, is there a beter way?
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
enabled: true
- type: turn_off
device_id: beeb5ed9c3b3f08143dd26af5b91fb73
entity_id: 049e9fe7159959f9448c0e244ad44d70
domain: switch
enabled: true
- service: notify.pushover
data:
message: de samsung charger goes to off at level: {{level}}
enabled: true
mode: single
icon: mdi:battery-arrow-up
https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371/3
Explain what you are trying to do in full sentences. What is the goal of this automation? What is working the way you want? What isn’t working the way you want?
alias: level 40
variables:
value: level
sequence:
- type: turn_on
device_id: beeb5ed9c3b3f08143dd26af5b91fb73
entity_id: 049e9fe7159959f9448c0e244ad44d70
domain: switch
enabled: true - delay:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
enabled: true - repeat:
until:
- condition: or
conditions:
- condition: numeric_state
entity_id: sensor.0xcc86ecfffe3ab382_power
below: 2
- condition: numeric_state
entity_id: sensor.sm_a546b_battery_level
above: level
sequence:
- delay:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
enabled: true - type: turn_off
device_id: beeb5ed9c3b3f08143dd26af5b91fb73
entity_id: 049e9fe7159959f9448c0e244ad44d70
domain: switch
enabled: true - service: notify.pushover
data:
message: de samsung oplader schakelt uit level {{level}}
enabled: true
mode: single
icon: mdi:battery-arrow-up
How can I use the variable level in this part: - condition: numeric_state
entity_id: sensor.sm_a546b_battery_level
above: level
without getting this message when I try to save the scrip
Message malformed: expected float for dictionary value @ data['sequence'][3]['repeat']['until'][0]['conditions'][1]['above']
Thank you for your help.
Please correct your formatting and follow Forum Question Guideline #8
While you can define a value_template
in a Numeric state condition, you will likely be better off using a template condition.