Skip to content

Instantly share code, notes, and snippets.

@elden1337
Last active April 30, 2022 23:31
Show Gist options
  • Save elden1337/673f939e4a05255716be22be9dcb5524 to your computer and use it in GitHub Desktop.
Save elden1337/673f939e4a05255716be22be9dcb5524 to your computer and use it in GitHub Desktop.
Nibe automations for Home Assistant.
- id: '1616449993366'
alias: Nibe - COP increase
trigger:
- platform: time
at: '11:00'
- platform: time
at: '12:00'
- platform: time
at: '12:30'
- platform: time
at: '11:30'
condition:
- condition: and
conditions:
- condition: state
entity_id: timer.nibe_sunwarm_heat
state: idle
- condition: template
value_template: "{%set hotrooms = ((states('sensor.hotroom1_temperature')|float+states('sensor.hotroom2_temperature')|float +states('sensor.hotroom3_temperature')|float)/3)|round(1) %}{{hotrooms - states('sensor.medeltemp_hemma')|float > 0.5}}"
- condition: numeric_state
entity_id: sensor.nibe_heatpump_speed
above: '0'
- condition: numeric_state
entity_id: sensor.nibe_00000_43005
above: '-1000'
action:
- service: script.nibe_vent_boost
- condition: and
conditions:
- condition: numeric_state
entity_id: sensor.nibe_heatpump_speed
above: '0'
- service: input_number.set_value
data:
value: 1
target:
entity_id:
- input_number.nibe_offset_change
- service: script.nibe_heat_offset_update
- service: timer.start
target:
entity_id:
- timer.nibe_sunwarm_heat
- wait_for_trigger:
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.nibe_sunwarm_heat
id: timer
- platform: numeric_state
entity_id: sensor.nibe_delta_returtemp
below: '1'
for:
hours: 0
minutes: 20
seconds: 0
id: delta
- service: input_number.set_value
data:
value: -1
target:
entity_id: input_number.nibe_offset_change
- service: script.nibe_ventilation_normal
- service: script.nibe_heat_offset_update
- service: timer.cancel
target:
entity_id: timer.nibe_sunwarm_heat
mode: single
- id: '1633362594597'
alias: Nibe - Night temp-decrease
trigger:
- platform: time
at: '21:00'
id: start
- platform: time
at: 03:00
id: end
condition:
- condition: state
entity_id: input_boolean.vacation_mode
state: 'off'
action:
- choose:
- conditions:
- condition: trigger
id: start
- condition: template
value_template: '{%set lower = namespace(value = true)%}
{%set now = states(''sensor.nibe_00000_40004'')|float%}
{%for f in state_attr(''weather.hake_hourly'', ''forecast'')%}
{%if loop.index <= 10%}
{%if now - f.temperature|float > 4%}
{%set lower.value = false%}
{%endif%}
{%endif%}
{%endfor%}
{{lower.value}}'
- condition: template
value_template: '{{(states(''sensor.medeltemp_hemma'')|float - 21.3) > -0.3}}'
- condition: numeric_state
entity_id: sensor.nibe_00000_40004
below: '13'
above: '-6'
sequence:
- service: input_number.set_value
target:
entity_id: input_number.nibe_offset_change
data:
value: -1
- service: script.turn_on
target:
entity_id: script.nibe_heat_offset_update
- service: input_boolean.turn_on
target:
entity_id: input_boolean.nibe_didlower_night
- conditions:
- condition: trigger
id: end
- condition: state
entity_id: input_boolean.nibe_didlower_night
state: 'on'
sequence:
- service: input_number.set_value
target:
entity_id: input_number.nibe_offset_change
data:
value: 1
- service: script.turn_on
target:
entity_id: script.nibe_heat_offset_update
- service: input_boolean.turn_off
target:
entity_id: input_boolean.nibe_didlower_night
default: []
mode: single
- id: '1638118346997'
alias: Nibe - preheat before cold
trigger:
- platform: time_pattern
minutes: /30
condition:
- condition: template
value_template: '{{not is_state(''sensor.nibe_cold_weather_preheat'', ''0'')}}'
- condition: state
entity_id: timer.nibe_precold_preheat
state: idle
- condition: state
entity_id: timer.nibe_precold_wait
state: idle
action:
- service: input_number.set_value
target:
entity_id: input_number.nibe_offset_change
data:
value: 1
- service: script.nibe_heat_offset_update
- service: timer.start
target:
entity_id: timer.nibe_precold_preheat
- wait_for_trigger:
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.nibe_precold_preheat
- service: input_number.set_value
target:
entity_id: input_number.nibe_offset_change
data:
value: -1
- service: script.nibe_heat_offset_update
- service: timer.start
target:
entity_id: timer.nibe_precold_wait
mode: single
- id: '1638170973561'
alias: Nibe - Vent boost when low degree minutes
trigger:
- platform: time_pattern
minutes: /30
condition:
- condition: template
value_template: '{{states.fan.nibe_00000_ventilation.attributes.percentage|int < 100}}'
- condition: template
value_template: '{{states(''sensor.nibe_00000_43005'')|int < -450}}'
- condition: numeric_state
entity_id: sensor.nibe_00000_40004
above: '-7'
action:
- service: script.nibe_vent_boost
- wait_for_trigger:
- platform: template
value_template: '{{states(''sensor.nibe_00000_43005'')|int > -100}}'
continue_on_timeout: true
timeout: 04:00:00
- service: script.nibe_ventilation_normal
mode: single
- id: '1638947480580'
alias: Nibe - Prepare smart legionella
trigger:
- platform: time
at: 02:00
condition:
- condition: template
value_template: '{{now().day == 28 or now().day == 14}}'
action:
- service: input_boolean.turn_on
target:
entity_id: input_boolean.attempt_legionella_run
mode: single
- id: '1638947853008'
alias: Nibe - Smart legionella
trigger:
- platform: state
entity_id: input_boolean.attempt_legionella_run
to: 'on'
condition: []
action:
- wait_for_trigger:
- platform: template
value_template: '{{states(''sensor.predicted_energy_this_hour'')|float < states(''sensor.flux_percentile_legionella'')|float and now().minute > 40}}'
timeout: '24:00:00'
- service: nibe.set_parameter
data:
system: 00000
parameter: hot_water_boost
value: 1
- service: input_boolean.turn_off
target:
entity_id: input_boolean.attempt_legionella_run
mode: single
nibe_heat_offset_update:
alias: Update Nibe heat_offset
sequence:
- variables:
adjustedcurve: '{{(states(''sensor.nibe_heater_offset'')|int) + states(''input_number.nibe_offset_change'')|int}}'
- service: nibe.set_parameter
data:
system: 000000
parameter: 47011
value: '{{ adjustedcurve }}'
mode: single
icon: mdi:hvac
nibe_vent_boost:
alias: Nibe ventilation boost
sequence:
- service: nibe.set_parameter
data:
system: 000000
parameter: ventilation_boost
value: 1
mode: single
icon: mdi:fan-chevron-up
nibe_ventilation_normal:
alias: Nibe ventilation normal
sequence:
- service: nibe.set_parameter
data:
system: 000000
parameter: ventilation_boost
value: 0
mode: single
icon: mdi:fan-chevron-down
- platform: template
sensors:
nibe_heatpump_speed:
friendly_name: 'Värmebärarpumphastighet'
unit_of_measurement: '%'
value_template: >
{{state_attr('climate.nibe_00000_s1_room', 'pump_speed_heating_medium')}}
nibe_heater_offset:
unit_of_measurement: 'Step'
friendly_name: 'Kurvförskjutning'
value_template: >
{{state_attr('climate.nibe_00000_s1_supply', 'offset_heat')}}
nibe_delta_returtemp:
unit_of_measurement: '°C'
value_template: >
{{(states.climate.nibe_00000_s1_supply.attributes.current_temperature|float - states.sensor.nibe_00000_40012.state|float)|round(2)}}
nibe_cold_weather_preheat:
unit_of_measurement: h
value_template: >
{%set currentTemp = states.weather.hake_hourly.attributes.temperature|float%}
{%set hours = namespace(value = 0) %}
{%if currentTemp < 2%}
{%for p in states.weather.hake_hourly.attributes.forecast if(p.temperature - currentTemp) < -4 and (((as_timestamp(p.datetime) - as_timestamp(now())) / 3600) // 1)|int >= 3%}
{%if loop.index == 1%}
{%set hours.value = (((as_timestamp(p.datetime) - as_timestamp(now())) / 3600) // 1)|int%}
{%endif%}
{%endfor%}
{%endif%}
{{hours.value}}
flux_percentile_legionella:
#create a sensor that checks the average hourly energy consumption for a period (Im using 7 days)
#and what percentage the current hourly consumption is at in that regard.
predicted_energy_this_hour:
#create a sensor that predicts the total energy for the current hour.
#Im using a running average of 5min power draw times the remainder of this hour,
#plus the accumulated energy this hour.
- platform: input_boolean
sensors:
vacation_mode:
icon: mdi:wallet-travel
attempt_legionella_run:
icon: mdi:house
nibe_didlower_night:
icon: mdi:house
- platform: input_number
sensors:
nibe_offset_change:
mode: box
min: -10
max: 10
step: 1
unit_of_measurement: step
icon: mdi:hvac
- platform: timer
sensors:
nibe_sunwarm_heat:
duration: "03:00:00"
nibe_precold_preheat:
duration: "03:00:00"
nibe_precold_wait:
duration: "08:00:00"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment