🔥 CTC i350 (heat pump) Smartgrid control using Tibber electricity prices by the hour

It all started out that I need to control my heating due to the new huge variations in price.
In the manual for my air-to-water heat pump CTC i350 I found that it have an internal interface, two ports, that can be controlled via two simple switches. So now I need some automation to control this… :thinking:

Thanks to @EdwardTFN and @ondras12345 I have a solution that will work for my heater, CTC i350.

Summary table from the CTC i350 user’s manual:

So by switching two switches, Smart A and Smart B, we can signal 4 different modes/levels to CTC i350.

This is what I did so far (edited 2022-10-06 after a cleanup and added comments):
Added code to configuration.yaml:

template:
  - sensor:
      # The daily reported Price Average is needed in the threshold calculations.
      - name: Electricity Price Average
        unit_of_measurement: "SEK/kWh"
        icon: mdi:currency-usd
        state: "{{ state_attr('sensor.electricity_price_majbosv6', 'avg_price') | float(0) }}"
      # Only used to set up a simple graph.
      - name: Electricity Price Min
        unit_of_measurement: "SEK/kWh"
        icon: mdi:currency-usd
        state: "{{ state_attr('sensor.electricity_price_majbosv6', 'min_price') | float(0) }}"
      # Only used to set up a simple graph.
      - name: Electricity Price Max
        unit_of_measurement: "SEK/kWh"
        icon: mdi:currency-usd
        state: "{{ state_attr('sensor.electricity_price_majbosv6', 'max_price') | float(0) }}"

      # Calculation from the requested percentage limits and daily Price Average into
      # actual "SEK/kWh" limits.
      # Please note that the 3 "input_number.threshold..." are "helpers" created from
      # Settings -> Devices & Services -> Helpers.
      # Then you can create sliders for easy control, by adding the helpers in the
      # “Entities Card Configuration”.
      - name: Electricity Threshold Limit 1
        unit_of_measurement: "SEK/kWh"
        icon: mdi:currency-usd
        state: >
          {% set price_avg = state_attr('sensor.electricity_price_majbosv6', 'avg_price') | float(0) %}
          {% set threshold = states('input_number.threshold_1_low') | float(0) %}
          {{ (price_avg * threshold / 100) | round(2) }}
      - name: Electricity Threshold Limit 2
        unit_of_measurement: "SEK/kWh"
        icon: mdi:currency-usd
        state: >
          {% set price_avg = state_attr('sensor.electricity_price_majbosv6', 'avg_price') | float(0) %}
          {% set threshold = states('input_number.threshold_2_medium') | float(0) %}
          {{ (price_avg * threshold / 100) | round(2) }}
      - name: Electricity Threshold Limit 3
        unit_of_measurement: "SEK/kWh"
        icon: mdi:currency-usd
        state: >
          {% set price_avg = state_attr('sensor.electricity_price_majbosv6', 'avg_price') | float(0) %}
          {% set threshold = states('input_number.threshold_3_high') | float(0) %}
          {{ (price_avg * threshold / 100) | round(2) }}

      # From the above calculations, choose the appropriate Price Level.
      - name: Electricity Price 4 Levels (24h)
        unit_of_measurement: ""
        icon: mdi:currency-usd
        state: >-
          {% set price_cur = states('sensor.electricity_price_majbosv6') | float(0) %}
          {% set price_avg = state_attr('sensor.electricity_price_majbosv6', 'avg_price') | float(0) %}
          {% set threshold_1 = states('input_number.threshold_1_low') | float(0) %}
          {% set threshold_2 = states('input_number.threshold_2_medium') | float(0) %}
          {% set threshold_3 = states('input_number.threshold_3_high') | float(0) %}
          {% if price_cur == 0 or price_avg == 0 %}
            -1
          {% else %}
            {% set price_ratio = (price_cur / price_avg) %}
            {% if price_ratio >= (threshold_3 / 100) %}
              4
            {% elif price_ratio >= (threshold_2 / 100) %}
              3
            {% elif price_ratio <= (threshold_1 / 100) %}
              1
            {% else %}
              2
            {% endif %}
          {% endif %}

The “simple graph” looks like this:
image

I’m using three “helpers” to be able to adjust/trim the threshold values. These helpers can be created from Settings → Devices & Services → Helpers.

Then you can create sliders for easy control in a Dashboard page, by adding the helpers in the “Entities Card Configuration”:
image

For the controlling of CTC i350 we also need to add some automation:
The following is added to the automations.yaml:

- alias: CTC SmartGrid control
  # CTC level  Meaning     Smart A  Smart B
  # 4          expensive   Closed   Open
  # 3          normal      Open     Open
  # 2          cheap       Open     Closed
  # 1          very cheap  Closed   Closed
  trigger:
    - platform: state
      entity_id: sensor.electricity_price_majbosv6
  mode: restart
  action:
    - choose:
        # IF above 3 -> level 4: expensive
        - conditions:
            - condition: numeric_state
              entity_id: sensor.electricity_price_4_levels_24h
              above: 3
          sequence:
            - service: switch.turn_on # Closed
              target:
                # Smart A
                entity_id: switch.badrum_xx_wmr_3000_ch1
            - service: switch.turn_off # Open
              target:
                # Smart B
                entity_id: switch.badrum_yy_wmr_3000_ch2
            - service: notify.notify
              data:
                message: "level 4: most expensive"
        # ELIF above 2 -> level 3: normal
        - conditions:
            - condition: numeric_state
              entity_id: sensor.electricity_price_4_levels_24h
              above: 2
          sequence:
            - service: switch.turn_off # Open
              target:
                # Smart A
                entity_id: switch.badrum_xx_wmr_3000_ch1
            - service: switch.turn_off # Open
              target:
                # Smart B
                entity_id: switch.badrum_yy_wmr_3000_ch2
            - service: notify.notify
              data:
                message: "level 3: normal"
        # ELIF above 1 -> level 2: cheap
        - conditions:
            - condition: numeric_state
              entity_id: sensor.electricity_price_4_levels_24h
              above: 1
          sequence:
            - service: switch.turn_off # Open
              target:
                # Smart A
                entity_id: switch.badrum_xx_wmr_3000_ch1
            - service: switch.turn_on # Closed
              target:
                # Smart B
                entity_id: switch.badrum_yy_wmr_3000_ch2
            - service: notify.notify
              data:
                message: "level 2: cheap"
      # ELSE below 2 -> level 1: very cheap
      default:
        - service: switch.turn_on # Closed
          target:
            # Smart A
            entity_id: switch.badrum_xx_wmr_3000_ch1
        - service: switch.turn_on # Closed
          target:
            # Smart B
            entity_id: switch.badrum_yy_wmr_3000_ch2
        - service: notify.notify
          data:
            message: "level 1: very cheap"

Why am I using 24h average? I don’t like the Tibber style Levels due to the fact that they are using “three days old” average. This will be problematic when you’ve had a couple of cheap days because when the price goes up the heater could be blocked for a whole day since the average are too old. The heating system is a slow system, but not as slow as several days…
Here you can see the difference between Tibber Levels and Today average Levels (in this graph only three levels though)

Some of my “debug” graphs:


2022-10-08 Adding more of the integration :smiley:


Inside the CTC i350 I can identify the interfaces which needs to be connected.


Close up of the Alarm interface.


I have chosen the Shelly 2.5 as an implant for my CTC i350 and it is now connected :smiley:

Some more settings needed to be done from the CTC i350 menu defining Smartgrid.
Then the CTC i350 was restarted and I could make some tests to see the response:


Here the Shelly ports are set to Over capacity - and it shows up on the display.
Also, the Alarm was tested and now I can get a notice to Home Assistant Companion App :alarm_clock:

Right now the weather here is still quite warm and we don’t need any heating. So I am only affecting the heat water production. Later, when it gets colder we will see if the settings are fine or if i need to tweak anything… :cold_face:

I hope this can help someone else as well :smiley:

6 Likes

Nice, I’m doing more or less the same with my Daikin heatpump. It’s not yet cold here though, but I’m in doubt about my approach. With your history graphs I see the same kind of trend, enabled for an hour and then off again. From a price perspective this makes sense but how efficient does your heatpump work when using it for those short time spans?
My next step is to combine the price levels with my solar panel overcapacity moments, but I’m holding that back because that will scatter the heat moments probably even more.

I glad that that you can have my project to compare with yours! :smiley:
Please note the my heat pump only is blocked when Level 4. Otherwise it changes temperature a little bit depending on the Level.
I have used Ngenic tune about a year now and it have controlled the heatpump. It can only control the heating of the house, not my hot water. Thus my own project is needed :slightly_smiling_face:
With both Ngenic tune and this Smartgrid approach you can have problems that when the heat pump is blocked for a long time, or you ramp up the set point temp too much, the heat pump will try to compensate too fast by using direct electric heating, insted of just wait for the heat pump to do the job.
In my case (using Ngenic tune) I have changed the settings in my CTC i350 for this to occur much later (a setting called “Start at degree minute”).
Otherwise regarding efficiency I don’t think it’s a problem when you run the heat pump for one hour and if you compare to the electric price you are trying to avoid :euro:
I think it’s good if you try to sort out the control for each sub system, i.e. your heat pump and later your solar panels and whatever more you’re able to control, and then try to combine them.
Which Daikin heatpump do you have?

It’s a Daikin Altherma 2 LT. I can’t control much behaviour (or at least I don’t know how), just the temperature and on/off. So I control the temperature based on home/away/night and separately turn the heater on when the prices are oke.
I agree that doing all separately is a good approach, otherwise it all starts impacting eachother. I experienced that also when I started to control my hot water (which is done by the Altherma too).
I’ll monitor it for a while when it gets colder.

Have you tried the Daikin support if the have anything under the hood that you can’t see from the users manual? :thinking:

Updated the project with the Shelly 2.5 as implant :partying_face:

Amazingly done! After reading your post, I’m considering implementing a similar setup on my CTC heat pump. One question, how did you forward alarms to the Home Assistant Companion App, did you do it through the Shelly 2.5?

1 Like

Have tried to use the Nordpool sensor!
I have had this in my mind since i got blasted by high electric bills and have been thinking on how to make my old heat pump better and better adapted to the new reality!
Any input? I’m kinda new to this :slight_smile:
And i have a CTC EcoZenith 250i with an air to water heat pump!

template:
  - sensor:
      # The daily reported Price Average is needed in the threshold calculations.
      - name: Electricity Price Average
        unit_of_measurement: "SEK/kWh"
        icon: mdi:currency-usd
        state: "{{ state_attr('sensor.nordpool_kwh_se4_sek_3_10_025', 'average') | float(0) }}"
      # Only used to set up a simple graph.
      - name: Electricity Price Min
        unit_of_measurement: "SEK/kWh"
        icon: mdi:currency-usd
        state: "{{ state_attr('sensor.nordpool_kwh_se4_sek_3_10_025', 'min') | float(0) }}"
      # Only used to set up a simple graph.
      - name: Electricity Price Max
        unit_of_measurement: "SEK/kWh"
        icon: mdi:currency-usd
        state: "{{ state_attr('sensor.nordpool_kwh_se4_sek_3_10_025', 'max') | float(0) }}"
      # Only used to set up a simple graph.
      - name: Electricity Price Current
        unit_of_measurement: "SEK/kWh"
        icon: mdi:currency-usd
        state: "{{ state_attr('sensor.nordpool_kwh_se4_sek_3_10_025', 'current_price') | float(0) }}"
               
        

      # Calculation from the requested percentage limits and daily Price Average into
      # actual "SEK/kWh" limits.
      # Please note that the 3 "input_number.threshold..." are "helpers" created from
      # Settings -> Devices & Services -> Helpers.
      # Then you can create sliders for easy control, by adding the helpers in the
      # “Entities Card Configuration”.
      - name: Electricity Threshold Limit 1
        unit_of_measurement: "SEK/kWh"
        icon: mdi:currency-usd
        state: >
          {% set price_avg = state_attr('sensor.nordpool_kwh_se4_sek_3_10_025', 'average') | float(0) %}
          {% set threshold = states('input_number.threshold_1_low') | float(0) %}
          {{ (price_avg * threshold / 100) | round(2) }}
      - name: Electricity Threshold Limit 2
        unit_of_measurement: "SEK/kWh"
        icon: mdi:currency-usd
        state: >
          {% set price_avg = state_attr('sensor.nordpool_kwh_se4_sek_3_10_025', 'average') | float(0) %}
          {% set threshold = states('input_number.threshold_2_medium') | float(0) %}
          {{ (price_avg * threshold / 100) | round(2) }}
      - name: Electricity Threshold Limit 3
        unit_of_measurement: "SEK/kWh"
        icon: mdi:currency-usd
        state: >
          {% set price_avg = state_attr('sensor.nordpool_kwh_se4_sek_3_10_025', 'average') | float(0) %}
          {% set threshold = states('input_number.threshold_3_high') | float(0) %}
          {{ (price_avg * threshold / 100) | round(2) }}

      # From the above calculations, choose the appropriate Price Level.
      - name: Electricity Price 4 Levels (24h)
        unit_of_measurement: ""
        icon: mdi:currency-usd
        state: >-
          {% set price_cur = state_attr('sensor.nordpool_kwh_se4_sek_3_10_025', 'current_price') | float(0) %}
          {% set price_avg = state_attr('sensor.nordpool_kwh_se4_sek_3_10_025', 'average') | float(0) %}
          {% set threshold_1 = states('input_number.threshold_1_low') | float(0) %}
          {% set threshold_2 = states('input_number.threshold_2_medium') | float(0) %}
          {% set threshold_3 = states('input_number.threshold_3_high') | float(0) %}
          {% if price_cur == 0 or price_avg == 0 %}
            -1
          {% else %}
            {% set price_ratio = (price_cur / price_avg) %}
            {% if price_ratio >= (threshold_3 / 100) %}
              4
            {% elif price_ratio >= (threshold_2 / 100) %}
              3
            {% elif price_ratio <= (threshold_1 / 100) %}
              1
            {% else %}
              2
            {% endif %}
          {% endif %}

And i changed some in the automation also

alias: CTC SmartGrid control
description: Styra värmepumpen via SmartGrid med relä
trigger:
  - platform: state
    entity_id:
      - sensor.electricity_price_current
condition: []
action:
  - choose:
      - conditions:
          - condition: numeric_state
            entity_id: sensor.electricity_price_4_levels_24h
            above: 3
        sequence:
          - service: switch.turn_on
            target:
              device_id: 7873e24fdacbd3e380d08c91ebc586d5
            data: {}
          - service: switch.turn_off
            data: {}
            target:
              device_id: 3ef3864f90d649fb00540117b82d465a
          - service: notify.notify
            data:
              message: "Level 4: most expensive"
              title: Expensive
      - conditions:
          - condition: numeric_state
            entity_id: sensor.electricity_price_4_levels_24h
            above: 2
        sequence:
          - service: switch.turn_off
            target:
              device_id: 7873e24fdacbd3e380d08c91ebc586d5
            data: {}
          - service: switch.turn_off
            data: {}
            target:
              device_id: 3ef3864f90d649fb00540117b82d465a
          - service: notify.notify
            data:
              message: "Level 3: normal"
              title: Normal
      - conditions:
          - condition: numeric_state
            entity_id: sensor.electricity_price_4_levels_24h
            above: 1
        sequence:
          - service: switch.turn_off
            target:
              device_id: 7873e24fdacbd3e380d08c91ebc586d5
            data: {}
          - service: switch.turn_on
            data: {}
            target:
              device_id: 3ef3864f90d649fb00540117b82d465a
          - service: notify.notify
            data:
              message: "Level 2: cheap"
              title: Cheap
    default:
      - service: switch.turn_on
        target:
          device_id: 7873e24fdacbd3e380d08c91ebc586d5
        data: {}
      - service: switch.turn_on
        data: {}
        target:
          device_id: 3ef3864f90d649fb00540117b82d465a
      - service: notify.notify
        data:
          message: "Level 1: very cheap"
          title: Best
mode: restart

Great work! Thank you for sharing!

1 Like

Thanks :blush:
Also, thanks for the question - I’ve missed to describe that.
For the Alarm I am using one of the inputs of the Shelly 2.5 (which is normally connected to a button when you control lights). But you need to detach it from controlling the relay! This is easily made in the settings of the Shelly 2.5:

Of course, you also need to connect a Live cable to the Alarm relay pin C, and from the Alarm relay pin NO to the Shelly 2.5 input.


In HA I have renamed the input and changed the icon to better represent my usage.

To test this you need to consult your CTC user manual and (at least on my CTC) there is a setting were you can turn the Alarm on and off.

I have made a simple Automation “CTC Alarm” if the Alarm triggers that will notify me.

Recently I added another Automation “CTC Shelly problems warning”, which will notify me if the Shelly is unavailable (WiFi-problems, Shelly dies or similar):

alias: CTC Shelly problems warning
description: ""
trigger:
  - type: problem
    platform: device
    device_id: 0d32f02cefa2476df9d7a43e85742c12
    entity_id: binary_sensor.smart_b_overheating
    domain: binary_sensor
  - platform: state
    entity_id:
      - switch.smart_b_channel_1
      - switch.smart_b_channel_2
    to: unavailable
    for:
      hours: 0
      minutes: 5
      seconds: 0
condition: []
action:
  - service: notify.notify
    data:
      title: CTC Shelly
      message: >-
        Shelly controller inuti CTC värmepump har problem. Se loggar för Shelly
        VP.
  - service: notify.persistent_notification
    data:
      title: CTC Shelly
      message: >-
        Shelly controller inuti CTC värmepump har problem. Se loggar för Shelly
        VP.
mode: single

One CTC problem I have is that sometimes it doesn’t trigger to make hot water when the price is cheap or very cheap… From my point of view I would like the CTC to “top up” the hot water as soon as it gets the trigger cheap or very cheap. I am in contact with CTC support regarding this but no good answer so far…

Please let me know your experience of controlling your CTC when you have it up and running :smiley:

Using the Nordpool sensor is great - it is more versatile than Tibber, since you don’t need a Tibber account!
Do you have electricity billing by the hour?
Well, if you have the i250 I think that’s pretty much the same as my i350? I think the i250 is the “on-off” control of the compressor and you have a tank built in used both for heating system and hot water. The i350 has the frequency / variable speed controlled compressor and only have a tank for the hot water built… Please correct me if I’m wrong :innocent:
Did you get you’re code working so far? :smiley:

I haven’t changed to billing by the hour, but this is a way to get there perhaps :slight_smile:
Need to be confident that i can get everyhing to work!
I have an inverter heat pump, not the old version with on/off only.

At the moment i’m just running the relays on the side to test and evaluate.
I’m using 2 shellys 1 plus in 12v mode, not super confident in 230v and have a lot more experience in 12v i have an shelly 2.5 also and will consider your take on it with alarm and everything :smiley:

1 Like

I have a CTC GSI. Anyone else interested in trying to RS485 bus with HA?

I just installed this on my CTC Eco Zenith 360 and can confirm that it works like a charm on this model as well.

After some quite disappointing attempts with the official Uplink app and price controlled Smartgrid this looks a lot more like a way forward. So now its time to tune the algorithm and a Friday evening beer.

Thanks a lot for your efforts.

1 Like
2 Likes

Nice work and thanks for sharing.
My goal is to control an IVT air/water pump and the garage eletrical heaters by the Nordpool spot price, however I want to start simply to control an Hue light based on the proposed code.
But Im struggling to get the threshold and classification part working, I think my math is just wrong, but here goes.

I copied Vovelivov and parts of Seffels code and got it working to show simple graphs and prices. I also noted that Nordpool sensor also has an price_percent_to_average attribute which would be good to simplify the threshold calculation.

template:
  - sensor:
      # The daily reported Price Average is needed in the threshold calculations.
      - name: Electricity Price Average
        unit_of_measurement: "öre/kWh"
        icon: mdi:currency-usd
        state: "{{ state_attr('sensor.nordpool_kwh_se3_sek_3_095_025', 'average') | float(0) }}"
      # Only used to set up a simple graph.
      - name: Electricity Price Min
        unit_of_measurement: "öre/kWh"
        icon: mdi:currency-usd
        state: "{{ state_attr('sensor.nordpool_kwh_se3_sek_3_095_025', 'min') | float(0) }}"
      # Only used to set up a simple graph.
      - name: Electricity Price Max
        unit_of_measurement: "öre/kWh"
        icon: mdi:currency-usd
        state: "{{ state_attr('sensor.nordpool_kwh_se3_sek_3_095_025', 'max') | float(0) }}"
      # Only used to set up a simple graph.
      - name: Electricity Price Current
        unit_of_measurement: "öre/kWh"
        icon: mdi:currency-usd
        state: "{{ state_attr('sensor.nordpool_kwh_se3_sek_3_095_025', 'current_price') | float(0) }}"
      # Only for info.
      - name: Electricity Spotprice from average
        unit_of_measurement: "%"
        icon: mdi:currency-usd
        state: "{{ state_attr('sensor.nordpool_kwh_se3_sek_3_095_025', 'price_percent_to_average') | float(0) }}"

      # Calculation from the requested percentage limits and daily Price Average into
      # actual "SEK/kWh" limits.
      # Please note that the 3 "input_number.threshold..." are "helpers" created from
      # Settings -> Devices & Services -> Helpers.
      # Then you can create sliders for easy control, by adding the helpers in the
      # “Entities Card Configuration”.
      - name: Electricity Threshold Limit 1
        unit_of_measurement: "SEK/kWh"
        icon: mdi:currency-usd
        state: >
          {% set price_avg = state_attr('sensor.nordpool_kwh_se3_sek_3_095_025', 'average') | float(0) %}
          {% set threshold = states('input_number.threshold_1_low') | float(0) %}
          {{ (price_avg * threshold / 100) | round(2) }}
      - name: Electricity Threshold Limit 2
        unit_of_measurement: "SEK/kWh"
        icon: mdi:currency-usd
        state: >
          {% set price_avg = state_attr('sensor.nordpool_kwh_se3_sek_3_095_025', 'average') | float(0) %}
          {% set threshold = states('input_number.threshold_2_medium') | float(0) %}
          {{ (price_avg * threshold / 100) | round(2) }}
      - name: Electricity Threshold Limit 3
        unit_of_measurement: "SEK/kWh"
        icon: mdi:currency-usd
        state: >
          {% set price_avg = state_attr('sensor.nordpool_kwh_se3_sek_3_095_025', 'average') | float(0) %}
          {% set threshold = states('input_number.threshold_3_high') | float(0) %}
          {{ (price_avg * threshold / 100) | round(2) }}

      # From the above calculations, choose the appropriate Price Level.
      - name: Electricity Price 4 Levels (24h)
        unit_of_measurement: ""
        icon: mdi:currency-usd
        state: >-
          {% set price_cur = state_attr('sensor.nordpool_kwh_se3_sek_3_095_025', 'current_price') | float(0) %}
          {% set price_avg = state_attr('sensor.nordpool_kwh_se3_sek_3_095_025', 'average') | float(0) %}
          {% set threshold_1 = states('input_number.threshold_1_low') | float(0) %}
          {% set threshold_2 = states('input_number.threshold_2_medium') | float(0) %}
          {% set threshold_3 = states('input_number.threshold_3_high') | float(0) %}
          {% if price_cur == 0 or price_avg == 0 %}
            -1
          {% else %}
            {% set price_ratio = (price_cur / price_avg) %}
            {% if price_ratio >= (threshold_3 / 100) %}
              4
            {% elif price_ratio >= (threshold_2 / 100) %}
              3
            {% elif price_ratio <= (threshold_1 / 100) %}
              1
            {% else %}
              2
            {% endif %}
          {% endif %}

The helpers are set and all look good on the dashboard
But something is missed and the light doesn’t come on

1 Like

Update:
After a few hours of tinkering with the code I realized that the helpers input names didn’t match with the Threshold calculating section. In addition, the helper value should be “currency” and not %.

Now, Im at the part where I want to turn on the light if Electricity Price 4 Levels (24h) indicate below 4.
And im stuck again :slight_smile:
It’s just to try again.

Interesting thread that describe what I’m trying to do. I have an CTC Ecoair 622M connected to a CTC Ecozenith i550 Pro. My idee is to get the i550 to warm the water only at lowprice periods and the 622M on the mediumprice periods. Their will also need to be at possibility to force the system to heat the water in i550 manually if needed. As a bonus it hade been god to sens produktion from the sunpower as i criteria of on/off.

Into the i550 their is connection to handle it by the the kontaktor K22, K23 (230V AC), K24, K25 (<= 12 DC).

As I understod of your input you only use a Shelly 2.5 to control this. The Shelly connects to K22 and K23. Have I miss some information or parts to get it to work. Have the shelly possibility to been programmed and through the wifi following the spotprice?

Is it best to use the smartgrid A nd B or to adress the “tariff el” and “tariff VP”?

Is their any commercial product available?
Other easy solutions?

Hello, have you integrated a CTC Ecoair 622 with CTC Eco Logic L into the Homeassitant ?

Just wanted to add my version of the automation:

  • Tibber
  • zigbee switch (& meter) to control the boiler (from the fuse panel)
  • additional condition to only fire notification IF something changes (switch gets flipped)
  • additional condition to not do anything but a correct level is present
  • changed default (else) to fire a message that something is not right (no condition is chosen)
  • going from that, if no level is activated (boiler switched OFF or ON from the opposite state) another condition to check if boiler is OFF + whether the state has not been changed in the last XX seconds (right now I use 3 days) and whether the Level is Y or lower (could add these as helper but I hope to not change anymore)
    to avoid the water getting cold…
alias: Boiler Control by price lvl
trigger:
  - platform: state
    entity_id: sensor.electricity_price_viktoriastr_94
action:
  - choose:
      - conditions:
          - condition: template
            value_template: |
              {{ is_state('switch.boiler', 'on') and 
                 states('sensor.electricity_price_4_levels_24h')|int > 3 }}
        sequence:
          - service: switch.turn_off
            target:
              entity_id: switch.boiler
            data: {}
      - conditions:
          - condition: template
            value_template: |
              {{ is_state('switch.boiler', 'on') and
                 states('sensor.electricity_price_4_levels_24h')|int > 2 }}
        sequence:
          - service: switch.turn_off
            target:
              entity_id: switch.boiler
            data: {}
          - service: notify.pushbullet
            data:
              message: "level 3: normal - boiler off"
              target:
                - device/Mi10
                - device/Chrome
      - conditions:
          - condition: template
            value_template: |
              {{ is_state('switch.boiler', 'off') and
                 states('sensor.electricity_price_4_levels_24h')|int > 1 }}      
        sequence:
          - service: switch.turn_on
            target:
              entity_id: switch.boiler
            data: {}
          - service: notify.pushbullet
            data:
              message: "level 2: cheap - boiler on"
              target:
                - device/Mi10
                - device/Chrome
      - conditions:
          - condition: template
            value_template: |
              {{ is_state('switch.boiler', 'off') and
                 states('sensor.electricity_price_4_levels_24h')|int == 1}}
        sequence:
          - service: switch.turn_on
            target:
              entity_id: switch.boiler
            data: {}
          - service: notify.pushbullet
            data:
              message: "level 1: really cheap - boiler on"
              target:
                - device/Mi10
                - device/Chrome
      - conditions:
          - condition: template
            value_template: |
              {{ is_state('switch.boiler', 'off') and
                 ( states('sensor.electricity_price_4_levels_24h')|int < 4 and
                 utcnow()|as_timestamp - states.switch.boiler.last_changed|as_timestamp(0)  > 259200 ) }}
        sequence:
          - service: switch.turn_on
            target:
              entity_id: switch.boiler
            data: {}
          - service: notify.pushbullet
            data:
              message: >
                Preventing cold water. Switching boiler {{
                states('switch.boiler') }} with price level  {{
                states('sensor.electricity_price_4_levels_24h') }} of 4.
              target:
                - device/Mi10
                - device/Chrome
      - conditions: >
          {{ states('sensor.electricity_price_4_levels_24h')|int in [ 1, 2, 3, 4] }}
        sequence:
           
      
    default:
      - service: notify.pushbullet
        data:
          message: No level - please control states
          target:
            - device/Mi10
            - device/Chrome
mode: restart