I’m attempting to create a generic binary switch blueprint based on sensor value, or rather an attribute state(?) which should toggle/set an object on or off depending on state.
It’s my first go at this and I’m struggling
Input appreciated on obvious faults.
The sensor in my case has an attribute called ‘price_level’ which can be
Very_exensive
Expensive
Normal
Cheap
Very_cheap
Ideally I want the blueprint to include a checkbox/whatnot to chose which states will set object to off (the “else on”)
blueprint:
name: Binary switch based on electricity price
description: Toggle an object ON/OFF depending on Tibbers Price levels
domain: automation
input:
sensor:
name: PriceSensor
description: This sensor will be used
selector:
entity:
domain: sensor
# Grab sensor with current price
target_light:
name: Lights
description: Object to toggle with Price Sensor
selector:
entity:
domain: light
#
trigger:
- platform: state
entity_id: !input PriceSensor
#
action:
- service: >
{% if trigger.to_state.state == "EXPENSIVE" OR "VERY_EXPENSIVE %}
light.turn_off
{% else %}
light.turn_on
{% endif %}
# If price is EXPENSIVE or VERY_EXPENSIVE - then toggle off.
# If price is NORMAL, CHEAP or VERY_CHEAP then toggle on
#
target: !input target_light