Solar 2 boiler integration

hi, I’m trying to create automation where I can set only overage from solar production to heat up water in electric boiler.
I’m using a triac regulator that can change watts dynamically based on 0-10V input where I’m using zigbee volt regulator where 0V input is 0Watts and 10V is maximum 2200W (not 100% accurate but usable)
I tried reading Active Power from Inverter sensor to set the Watts that are being used to heat up the boiler water but if certain value is set i can’t calculate actively the available Voltage + available V for generation, I came up with something like this, but the value is not OK to use after first condition is met.
any suggestion is welcome

alias: test volt change
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.active_power
condition: []
action:
  - choose:
      - conditions:
          - type: is_power
            condition: device
            device_id: 67c2c70c4ab178f24c58fa27c4a0bc9a
            entity_id: 5e3d1650dbd10ab4232306a68c56f980
            domain: sensor
            above: 200
        sequence:
          - service: light.turn_on
            metadata: {}
            data:
              brightness_pct: 50
            target:
              device_id: 3d9e496d8af7c778cce199e1787a9367
          - type: turn_on
            device_id: a7771b528f24216c3f901e50da0ac4ca
            entity_id: 40603433efa13b58af801a2e7c95dbbe
            domain: switch
  - choose:
      - conditions:
          - type: is_power
            condition: device
            device_id: 67c2c70c4ab178f24c58fa27c4a0bc9a
            entity_id: 5e3d1650dbd10ab4232306a68c56f980
            domain: sensor
            above: 400
        sequence:
          - service: light.turn_on
            metadata: {}
            data:
              brightness_pct: 55
            target:
              device_id: 3d9e496d8af7c778cce199e1787a9367
          - type: turn_on
            device_id: a7771b528f24216c3f901e50da0ac4ca
            entity_id: 40603433efa13b58af801a2e7c95dbbe
            domain: switch
  - choose:
      - conditions:
          - type: is_power
            condition: device
            device_id: 67c2c70c4ab178f24c58fa27c4a0bc9a
            entity_id: 5e3d1650dbd10ab4232306a68c56f980
            domain: sensor
            above: 600
        sequence:
          - service: light.turn_on
            metadata: {}
            data:
              brightness_pct: 59
            target:
              device_id: 3d9e496d8af7c778cce199e1787a9367
          - type: turn_on
            device_id: a7771b528f24216c3f901e50da0ac4ca
            entity_id: 40603433efa13b58af801a2e7c95dbbe
            domain: switch
  - choose:
      - conditions:
          - type: is_power
            condition: device
            device_id: 67c2c70c4ab178f24c58fa27c4a0bc9a
            entity_id: 5e3d1650dbd10ab4232306a68c56f980
            domain: sensor
            above: 800
        sequence:
          - service: light.turn_on
            metadata: {}
            data:
              brightness_pct: 63
            target:
              device_id: 3d9e496d8af7c778cce199e1787a9367
          - type: turn_on
            device_id: a7771b528f24216c3f901e50da0ac4ca
            entity_id: 40603433efa13b58af801a2e7c95dbbe
            domain: switch
  - choose:
      - conditions:
          - type: is_power
            condition: device
            device_id: 67c2c70c4ab178f24c58fa27c4a0bc9a
            entity_id: 5e3d1650dbd10ab4232306a68c56f980
            domain: sensor
            above: 1000
        sequence:
          - service: light.turn_on
            metadata: {}
            data:
              brightness_pct: 67
            target:
              device_id: 3d9e496d8af7c778cce199e1787a9367
          - type: turn_on
            device_id: a7771b528f24216c3f901e50da0ac4ca
            entity_id: 40603433efa13b58af801a2e7c95dbbe
            domain: switch
  - choose:
      - conditions:
          - type: is_power
            condition: device
            device_id: 67c2c70c4ab178f24c58fa27c4a0bc9a
            entity_id: 5e3d1650dbd10ab4232306a68c56f980
            domain: sensor
            above: 1500
        sequence:
          - service: light.turn_on
            metadata: {}
            data:
              brightness_pct: 80
            target:
              device_id: 3d9e496d8af7c778cce199e1787a9367
          - type: turn_on
            device_id: a7771b528f24216c3f901e50da0ac4ca
            entity_id: 40603433efa13b58af801a2e7c95dbbe
            domain: switch
mode: single

would it be possible to calculate somehow a new value to get real value of active power from smart socket sensor “active power” + solar production"active power" and use this value as value “above” ? as with this setup I each time get in case of consumption - above value

Hi cjano,

That looks like a lot of work. I have a couple suggestions that may make your life easier.

First, while the device_id stuff does work, it was designed for use by the UI only, and it is very clunky for people to follow. you may want to consider this:
Why and how to avoid device_ids in automations and scripts.
Not going to change anything other that you will be able to use templates in places where you cannot now, and you will be able to read it and know what you are looking at.

second, take a look at the compensation integration. You give it a few known points and it will extrapolate a number based on the number you give it.

I did a video using it if that helps you any.

howdy, thanks for suggestion, good staff, however I think for me would be easier to just add extra value that would add to PV Active Power + smart plug’s Active Power so something like this, not sure how to do, if even possible directly

action:
  - choose:
      - conditions:
          - type: is_power
            condition: device
            device_id: 67c2c70c4ab178f24c58fa27c4a0bc9a
            entity_id: 5e3d1650dbd10ab4232306a68c56f980
            domain: sensor
            above: 200 + sensor.smart_plug_active_power 

That pseudo code there would require above: to be a template and device_ids mostly don’t do templates, so maybe not.
If you used the entity with a template, yes, but the compensation is dead dimple and I highly suggest it.

Here is the compensation configuration for converting rainfall to time to keep the sprinkler on. Feed it rain amount, out comes minutes continuously. Most of it is comments because I did a video on this.

sprinkler_time:
  unique_id: 729e7199-and-other-stuff
  source: sensor.gw2000b_v2_2_4_daily_rain_rate_piezo
  # Ensure that the sensor's value will not have a state lower than -60.0
  # when the source sensors value is less than 0.01
  lower_limit: true
  # Ensure that the sensor's value will not have a state greater than 0.0
  # when the source sensors value is greater than .25
  upper_limit: true
  data_points:
    - [0.01, -60.0]
    - [0.25, 0.0]

good Sir,
thanks for your suggestion, I hope doing simple math would be easier.

just trying to add two variables but somehow it just puts two variables next to each other, can you please explain why it is not adding?
{{states.sensor.smart_plug_active_power.state+states.sensor.active_power.state}}

Definitely not simpler, but out of context you could have formatting wrong, State generally returns text not a number, and there are missing quotes both single and plural.
Templating - Home Assistant.

yeah but how exactly? according to templates documentation one should avoid that syntax, so changed it like this

{{ states(‘sensor.zasuvka_bojler_pivnica_active_power’) }}
{{ states(‘sensor.active_power’) }}
{{ states(‘sensor.zasuvka_bojler_pivnica_active_power’) + states(‘sensor.active_power’) }}

and the result i’m getting is this:
220
22
22022

so as you can see values are not added just placed to each other

jinja2 - String concatenation in Jinja - Stack Overflow Might help.

found a solution, still not to my math problem though,

so I created a helper “Combine the state of several sensors”
Create a sensor that calculates a min, max, mean, median or sum from a list of input sensors.
added two sensors I mentioned before and SUM them together and simply replaced the condition with helper so I always get the real overage from my solar production that would go to boiler to heat up the water