Skip to content

Instantly share code, notes, and snippets.

@JohanAlvedal
Last active December 5, 2023 18:00
Show Gist options
  • Save JohanAlvedal/66b21a648a1a4ca261f6f3476b3f82e3 to your computer and use it in GitHub Desktop.
Save JohanAlvedal/66b21a648a1a4ca261f6f3476b3f82e3 to your computer and use it in GitHub Desktop.
This blueprints uses the nordpool integration and lets you choose howe many hours you will define as expesive, and make a sensor block temperature based on that information.
blueprint:
name: Block heat
description: >
This blueprints uses the nordpool integration and lets you choose howe
many hours you will define as expesive, and make a sensor block temperature based on that information.
In order for this blueprint to work, the following elements must be met.
- Nordpool integration
- An outdoor sensor that has the actual outdoor temperature
- A sensor that can manipulate the outdoor temperature, for example https://www.ohmigo.io/product-page/ohmigo-ohm-on-wifi or equivalent
Sometimes you have to wait an hour for the autonation to start, if nothing else, you can manually run it.
**Version: 1.0**
domain: automation
input:
grid_area:
name: Grid Area Sensor
description: This is your grid area sensor
selector:
entity:
domain:
- sensor
integration: nordpool
multiple: false
expensive_hours:
name: Expensive Hours
description: Numbers of Expensive hours to block
default: 4
selector:
number:
min: 0
max: 24
mode: slider
step: 1.0
temperature_sensor:
name: Temperature Sensor
description: Here you select your real outside temperature sensor
selector:
entity:
domain:
- sensor
device_class:
- temperature
multiple: false
refresh_temperature_delay:
name: Cheap Hours - Refresh Controllable Temperature Delay Time
description:
This will refresh the controllable temperature sensor to mirror the outside
temperature sensor in the set time period.
default: 5
selector:
number:
min: 0.0
max: 10
step: 0.25
unit_of_measurement: Minutes
controll_sensor:
name: Controllable Sensor
description: Your controllable sensor *
selector:
entity:
domain:
- number
integration: mqtt
multiple: false
virtual_temperature:
name: Virtual Block Temp
description: Your selected virtual temperature to block your heater
default: 20
selector:
number:
min: 0.0
max: 30
mode: slider
step: 1.0
unit_of_measurement: °C
# Variables
variables:
grid_area: !input grid_area
expensive_hours: !input expensive_hours
temperature_sensor: !input temperature_sensor
refresh_temperature_delay: !input refresh_temperature_delay
controll_sensor: !input controll_sensor
virtual_temperature: !input virtual_temperature
# Triggers
trigger:
- platform: state
entity_id: !input grid_area
- platform: homeassistant
event: start
- platform: time_pattern
seconds: 30
# Conditions
action:
- choose:
- conditions:
- condition: template
value_template: "{{ (state_attr(grid_area,'today')|sort)[24 - expensive_hours|int] < states(grid_area)|float }}"
sequence:
- service: number.set_value
entity_id: !input controll_sensor
data:
value: !input virtual_temperature
- conditions:
- condition: template
value_template: "{{ (state_attr(grid_area,'today')|sort)[24 - expensive_hours|int] > states(grid_area)|float }}"
sequence:
- alias: "Refresh the controllable temperature sensor"
repeat:
until: "{{ (state_attr(grid_area,'today')|sort)[24 - expensive_hours|int] < states(grid_area)|float }}"
sequence:
- service: number.set_value
entity_id: !input controll_sensor
data:
value: "{{ states(temperature_sensor)|float(0) }}"
- alias: "Refresh time before setting the controllable temperature again"
delay:
minutes: !input refresh_temperature_delay
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment