Adjust Heaters and Thermostats based on Electricity price-adjustments

Hi,

So after hours of tryning, I’m realizing that I need some more knowledge and input. Because I’m stuck.
Through Tibber (my powercompany) I get readings on prices(in local currency) and the price level (cheap, normal, expensive, very expensive) etc. Through HA, I have it as local sensors, and zwave connection to the thermostats and a third party Adax Heater integration to control the heaters.

Idea:
Adjust down the thermostats to energy heat (since this is 4 degrees lower than normal consumption) and turn of a group of heaters when the power is expensive, and when it goes back to normal - set the mode to regular heat and turn on the heaters.

The purpose for this is to do two things;
A) Create a SWITCH that could trigger this on demand
B) An automated activity that monitors the development, and does the changes automatically within a timespan.
Both will also send a notification to my phone / power app.

So I’m trying to solve the SWITCH first

input_boolean.yaml

#Intput_Boolean Power switch
  kjell_mode:
    name: Kjell mode aktivert
    initial: off

Switch.yaml

#Switch.yaml Powersaving mode
  - platform: template
    switches:
     kjell_mode:
      value_template: '{{ states("input_boolean.kjell_mode") }}'
      friendly_name: 'Kjell-mode'
      turn_on:
        - service: input_boolean.turn_on
          entity_id: input_boolean.kjell_mode
        - service: climate.set_present_mode
          data:
            entity_id: group.climate_termostater
            preset_mode: none
        - service: climate.set_hvac_mode
          entity_id: group.climate_panelovn
          data: 
            hvac_modes: off 
        - service: notify.tibber
        #Notification enabled
          data:
            title: "Kjell-mode er aktivert"
            message: "Strømmen er dyr, Kjell-mode er aktivert til strømmen normaliserer seg."
      turn_off:
        - service: input_boolean.turn_off
          entity_id: input_boolean.kjell_mode
        - service: climate.set_present_mode
          entity_id: group.climate_termostater
          data:
            preset_mode: none
        - service: climate.set_hvac_mode
          entity_id: group.climate_panelovn
          data: 
            hvac_modes: heat 
        - service: notify.tibber
          #Notification disabled
          data:
            title: "Kjell-mode er deaktivert"
            message: "Da vi tilbake til normalen igjen. Få kasta litt mer penger ut av vinduet. "

This is the Groups.yaml

# Groups.yaml
  climate_panelovn:
    name: Adax Panelovner
    entities:
       ## Panelovn Kontor
       #- climate.adax_82165
       ## Panelovn Gjesterom
       - climate.adax_86969 
       ## Panelovn Soverom: Ludvig
       #- climate.adax_83216
       ## Panelovn Hovedsoverom
       - climate.adax_84604 
  climate_termostater:
    name: HeatIt Thermostater
    entities:
      - climate.thermofloor_as_heatit_thermostat_tf_021_heating
      - climate.thermofloor_as_heatit_thermostat_tf_021_heating_2
      - climate.thermofloor_as_heatit_thermostat_tf_021_heating_3
      - climate.thermofloor_as_heatit_thermostat_tf_021_heating_4

So where I have trouble is to activate the switch from Lovelace. The error is the following:
55

What am I doing wrong? And do you need any more documentation to help me out?

Is the service not set_preset_mode? I don’t think many heating systems do much presenting.

Hah, that typo. Thanks.

However, I think I have an issue in the actual script.

This bug appears:
Kunne ikke tilkalle tjenesten: switch/turn_off extra keys not allowed @ data['hvac_modes']

With the current running script:

#Powersaving mode
  - platform: template
    switches:
     kjell_mode:
      value_template: '{{ states("input_boolean.kjell_mode") }}'
      friendly_name: 'Kjell-mode'
      turn_on:
        - service: input_boolean.turn_on
          entity_id: input_boolean.kjell_mode
        - service: climate.set_preset_mode
          data:
            entity_id: group.climate_termostater
            preset_mode: none
        - service: climate.set_hvac_mode
          data: 
            entity_id: group.climate_panelovn
            hvac_modes: off 
        - service: notify.tibber
        #Notification enabled
          data:
            title: "Kjell-mode er aktivert"
            message: "Strømmen er dyr, Kjell-mode er aktivert til strømmen normaliserer seg."
      turn_off:
        - service: input_boolean.turn_off
          entity_id: input_boolean.kjell_mode
        - service: climate.set_preset_mode
          data:
            entity_id: group.climate_termostater
            preset_mode: none
        - service: climate.set_hvac_mode
          data: 
            entity_id: group.climate_panelovn
            hvac_modes: heat 
        - service: notify.tibber
          #Notification disabled
          data:
            title: "Kjell-mode er deaktivert"
            message: "Da vi tilbake til normalen igjen. Få kasta litt mer penger ut av vinduet. "

That error isn’t from the code you’ve posted, you don’t have switch.turn_off in any of it.

I am triggering the switch from Lovelace. Is that not sufficient?

I have no idea what you’re trying to do, but the error message you posted means that somewhere you have some code in your configuration where you are calling the switch.turn_off service and passing it parameters it cannot accept. Without seeing your entire configuration I can’t tell you where, but I’m sure you can narrow it down based on when the error message appears.

I found the issue with set_hvac mode. It’s not supported in the third-party integration.

#Powersaving mode
  - platform: template
    switches:
     kjell_mode:
      value_template: '{{ states("input_boolean.kjell_mode") }}'
      friendly_name: 'Kjell-mode'
      turn_on:
        - service: input_boolean.turn_on
          entity_id: input_boolean.kjell_mode
        - service: climate.set_preset_mode
          entity_id: group.climate_termostater
          data:
            preset_mode: Energy Heat
#        - service: climate.set_hvac_mode
#          data:
#            entity_id: group.climate_panelovn
#            hvac_mode: 'off'
        - service: climate.set_fan_mode
          entity_id: climate.varmepumpe
          data: 
            fan_mode: quiet
        - service: notify.tibber
        #Notification enabled
          data:
            title: "Kjell-mode er aktivert"
            message: "Strømmen er dyr, Kjell-mode er aktivert til strømmen normaliserer seg."
      turn_off:
        - service: input_boolean.turn_off
          entity_id: input_boolean.kjell_mode
        - service: climate.set_preset_mode
          entity_id: group.climate_termostater
          data:
            preset_mode: none
#        - service: climate.set_hvac_mode
#          data:
#            entity_id: group.climate_panelovn
#            hvac_mode: heat
        - service: climate.set_fan_mode
          entity_id: climate.varmepumpe
          data: 
            fan_mode: low
        - service: notify.tibber
          #Notification disabled
          data:
            title: "Kjell-mode er deaktivert"
            message: "Da vi tilbake til normalen igjen. Få kasta litt mer penger ut av vinduet. "

Now it’s on to get that automation to work.

Edit: Is there a possiblity to change the temperature of an entire group?

          entity_id: group.climate_termostater

In the Groups.yaml file, this is following code.

  climate_termostater:
    name: HeatIt Thermostater
    entities:
      - climate.thermofloor_as_heatit_thermostat_tf_021_heating
      - climate.thermofloor_as_heatit_thermostat_tf_021_heating_2
      - climate.thermofloor_as_heatit_thermostat_tf_021_heating_3
      - climate.thermofloor_as_heatit_thermostat_tf_021_heating_4

All these entities has different temperature, and I want to reduce these with 4 degrees each. Is that possible?

        - service: climate.set_temperature
          entity_id: group.climate_termostater
          data:
            temperature: ?

Trying to build this through:

#Justere temperatur ned 3 grader
        - service: climate.set_temperature
          entity_id: climate.thermofloor_as_heatit_thermostat_tf_021_heating
          data:
            temperature: "{{ state_attr('climate.thermofloor_as_heatit_thermostat_tf_021_heating', 'temperature')|int() -3 | float }}"
#        - service: climate.set_temperature
#          data:
#            entity_id: climate.thermofloor_as_heatit_thermostat_tf_021_heating_2
#            temperature: "{{ state_attr('climate.thermofloor_as_heatit_thermostat_tf_021_heating_2', 'temperature')|int() -3 }}"
#        - service: climate.set_temperature
#          data:
#            entity_id: climate.thermofloor_as_heatit_thermostat_tf_021_heating_3
#            temperature: "{{ state_attr('climate.thermofloor_as_heatit_thermostat_tf_021_heating_3', 'temperature')|int() -3 }}"
#        - service: climate.set_temperature
#          data:
#            entity_id: climate.thermofloor_as_heatit_thermostat_tf_021_heating_4
#            temperature: "{{ state_attr('climate.thermofloor_as_heatit_thermostat_tf_021_heating_4', 'temperature')|int() -3 }}"

However, I’m getting
Kunne ikke tilkalle tjenesten: switch/turn_on expected float for dictionary value @ data['temperature']

Any tips?

You need data_template.

I don’t know about setting a group, but I would suspect not.

Hi,

I want hot water to turn on if price is below 1.70 SEK.
I created this, but the problem is that it turns the heater on no matter if the price is above (false) or below (true) 1.70 SEK.
alias: Hot Water cheap price

description: Turn off water heater in the (chosen) most expensive hours
trigger:

  • platform: time_pattern
    minutes: ‘1’
    condition: []
    action:
  • if:
    • condition: numeric_state
      entity_id: sensor.nordpool_kwh_se3_sek_3_095_025
      above: 1.2
      below: 1.7
      then:
    • if:
      • condition: device
        type: is_on
        device_id: 764e5b778d10adc9de55f6ad99238b3b
        entity_id: ed837d5cf18834c82815f791c6e895cb
        domain: switch
        then:
      • type: turn_off
        device_id: 764e5b778d10adc9de55f6ad99238b3b
        entity_id: ed837d5cf18834c82815f791c6e895cb
        domain: switch
        else:
    • if:
      • condition: device
        type: is_off
        device_id: 764e5b778d10adc9de55f6ad99238b3b
        entity_id: ed837d5cf18834c82815f791c6e895cb
        domain: switch
        then:
      • type: turn_on
        device_id: 764e5b778d10adc9de55f6ad99238b3b
        entity_id: ed837d5cf18834c82815f791c6e895cb
        domain: switch
        mode: single

Anyone got a clue or a better solution?
Thanks in advance

Peter