Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save baszalmstra/546d8179792538af7427952b4cd9b28b to your computer and use it in GitHub Desktop.

Select an option

Save baszalmstra/546d8179792538af7427952b4cd9b28b to your computer and use it in GitHub Desktop.
Disable solar panels when export tariff is negative
blueprint:
name: Disable switch when export tariff is negative
description: >
Turns a switch off when the export tariff goes below 0, and back on
when the export tariff is 0 or higher.
domain: automation
input:
export_tariff_entity:
name: Export tariff entity
description: Sensor containing the current export tariff / feed-in price.
selector:
entity:
domain: sensor
controlled_switch:
name: Switch
description: Switch to turn off when the export tariff is negative.
selector:
entity:
domain: switch
trigger:
- platform: state
entity_id: !input export_tariff_entity
variables:
export_tariff_entity: !input export_tariff_entity
controlled_switch: !input controlled_switch
export_price: "{{ states(export_tariff_entity) | float(none) }}"
condition:
- condition: template
value_template: "{{ export_price is not none }}"
action:
- choose:
- conditions:
- condition: template
value_template: "{{ export_price < 0 }}"
sequence:
- service: switch.turn_off
target:
entity_id: !input controlled_switch
- conditions:
- condition: template
value_template: "{{ export_price >= 0 }}"
sequence:
- service: switch.turn_on
target:
entity_id: !input controlled_switch
mode: single
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment