Binary Switch based on Electricity Price

I’m attempting to create a generic binary switch blueprint based on sensor value.
It’s my first go at this and I’m struggling :wink:
Input appreciated on obvious faults.

I want to retrieve an attribute from the sensor called “price_level” but I’m clearly not understanding the syntax

error:

Invalid blueprint: Only one type can be specified. Found entity, target_light for dictionary value @ data['bl
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

Hi David!

If you’re still struggling or otherwise interested, see my blueprint:

Great work!

I was about to upload but this is excellent :slight_smile:

We should consider a numeric version for absolute values aswell :slight_smile:

Nice, I am trying to achieve the following:
“If price is above averageprice*1.05 then turn OFF XX, else turn ON”.
But I cant figure out how to compare a “states” with a “state.attr” and do something.