Skip to content

Instantly share code, notes, and snippets.

@shermozle
Created December 7, 2021 05:50
Show Gist options
  • Save shermozle/a514b19735f1e9382506fa693ca494d6 to your computer and use it in GitHub Desktop.
Save shermozle/a514b19735f1e9382506fa693ca494d6 to your computer and use it in GitHub Desktop.
blueprint:
name: Solar Light
description: Change the colour of a lamp based on the amount of power being imported or exported from the
domain: automation
input:
net_current_consumption:
name: Net current consumption sensor
description: Negative for exporting, positive for importing
selector:
entity:
domain: sensor
target_light:
name: Light
description: The light you wish to use as the indicator
selector:
target:
entity:
domain: light
trigger:
- platform: state
entity_id: !input net_current_consumption
action:
- variables:
spot_price: "{{ trigger.to_state.attributes.spot_per_kwh }}"
customer_price: "{{ trigger.to_state.attributes.per_kwh }}"
low_price: !input importing
high_price: !input exporting
- service: light.turn_on
target: !input target_light
data:
color_name: >
{% if net_current_consumption > 0 %}
red
{% if net_current_consumption <= 0 %}
green
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment