#hello.

1 messages · Page 1 of 1 (latest)

ionic rune
#

I have the add-on from frlequ: https://github.com/frlequ/home-assistant-network-tariff, which displays the current billing block for electricity consumption as its state (sensor.elektro_network_tariff).

I also have a P1 meter, from which I created an integration sensor to convert W to kWh (sensor.p1_meter_power_phase_3_w_to_kwh). This sensor is for phase 3.

I would like to create entities for blocks 1 to 5 that show how many kWh I have consumed in each block.

Does anyone have any ideas?

Later, I would like to use the utility meter to create a sensor that calculates the monthly billing.

Thanks.

P.S. The post with images is also available at: https://community.home-assistant.io/.../how-to.../844664

dense tree
#

Hi, what means "a block" (blocks 1 to 5)? Some period of time per day?

Ps. the last link does not work

ionic rune
#

Hi.
Thanks for the reply.
Link: https://community.home-assistant.io/t/how-to-create-entities-based-on-the-state-of-one-entity-and-added-values-in-another-sensor-electricity-billing-in-slovenia/844664

The electricity blocks change during the day as shown in the picture.
sensor.elektro_network_tariff shows me which electricity block is in use.

dense tree
#

I'm not very good in templates, but maybe somehow create 5 template sensors, one for each block, so that template shows value of the current power if the actual time is within the defined block, otherwise 0? And then you probably need 5 integrals for each of those template sensors as well.

ionic rune
# dense tree I'm not very good in templates, but maybe somehow create 5 template sensors, one...

Thanks.
I know how to make simple sensors myself.
In this case, I don't know how to approach the matter.
chatgpt wrote me the following:

To add to configuration.yaml:

input_number:
 block_1_consumption:
 name: "Block 1 Consumption"
 min: 0
 max: 10000
 step: 0.01
 unit_of_measurement: 'kWh'

 block_2_consumption:
 name: "Block 2 Consumption"
 min: 0
 max: 10000
 step: 0.01
 unit_of_measurement: 'kWh'

 block_3_consumption:
 name: "Block 3 Consumption"
 min: 0
 max: 10000
 step: 0.01
 unit_of_measurement: 'kWh'

 block_4_consumption:
 name: "Block 4 Consumption"
 min: 0
 max: 10000
 step: 0.01
 unit_of_measurement: 'kWh'

 block_5_consumption:
 name: "Block 5 Consumption"
 min: 0
 max: 10000
 step: 0.01
 unit_of_measurement: 'kWh'

and also in automations.yaml

- id: '1739128677653'
 alias: Monitoring consumption by blocks
 description: ''
 triggers:
 - entity_id: sensor.elektro_network_tariff
 trigger: state
 conditions: []
 actions:
 - target:
 entity_id: "{% if is_state('sensor.elektro_network_tariff', '1') %}\n input_number.blok_1_consumption\n{%
 elif is_state('sensor.elektro_network_tariff', '2') %}\n input_number.blok_2_consumption\n{%
 elif is_state('sensor.elektro_network_tariff', '3') %}\n input_number.blok_3_consumption\n{%
elif is_state('sensor.elektro_network_tariff', '4') %}\n input_number.blok_4_consumption\n{%
elif is_state('sensor.elektro_network_tariff', '5') %}\n input_number.blok_5_consumption\n{%
endif %}\n"
data:
value: '{{ (states(''sensor.p1_meter_power_phase_3'')|float / 1000) }}

'
action: input_number.set_value
mode: single

Otherwise, chatgpt explained to me what this is supposed to do and input_number actually adds something up for me by blocks. I'm not sure this is the right way, especially since, if I understand correctly, these sensors are cumulative, so they don't do monthly cumulatives, but add up until it exceeds the value of 10,000!

dense tree
#

ChatGPT didn't apparently know that your sensors report W instead of kWh, so I think the code is correct otherwise, expect that the sensors should be named "block_X_power" instead, and then you still need to add integrals over those

#

So that automation is just updating the values of each "block sensor" - value is in W instead of kWh

ionic rune
# dense tree ChatGPT didn't apparently know that your sensors report W instead of kWh, so I t...

Hi again.

Thanks for the answer.

A little explanation of what the sensors that are tied to the billing look like:

The sensor sensor.elektro_network_tariff shows which block is currently in use.

The sensor sensor.p1_meter_power_phase_3 shows the current consumption on phase 3.

The sensor sensor.p1_meter_power_phase_3_w_to_kwh collects the consumption in kWh from the sensor sensor.p1_meter_power_phase_3.

What did you mean by I would have to add integrals? How do I do that?

Thanks for your effort.

#

More pictures of the sensors with data.

dense tree
#

The sensor sensor.p1_meter_power_phase_3_w_to_kwh which "collects" the energy is actually integrating the power, so it is integral.

What I would have maybe done is following:

  1. Create 5 template sensors (or use they way chatGPT showed) for each block, call them e.g. sensor.block_1_power etc.
  2. Template for such sensor would be in pseudo something like {{ iif(sensor.elektro_network_tariff == 1, sensor.p1_meter_power_phase_3, 0) }}
  3. Then you need to create integral (helper) for each of those block sensors to integrate the power to energy, let's call them sensor.block_1_consumption - and each of them have value kWh
#

I'm not native English spearker, so I'm not sure if "integrate" is the correct verb for integral

ionic rune
# dense tree The sensor `sensor.p1_meter_power_phase_3_w_to_kwh` which "collects" the energy ...

If I understood you correctly, it should look like this:

input_number:
faza3_blok1_consumption:
name: "Block 1 Consumption"
min: 0
max: 10000
step: 0.01
unit_of_measurement: 'kWh'

faza3_blok2_consumption:
name: "Block 2 Consumption"
min: 0
max: 10000
step: 0.01
unit_of_measurement: 'kWh'

faza3_blok3_consumption:
name: "Block 3 Consumption"
min: 0
max: 10000
step: 0.01
unit_of_measurement: 'kWh'

faza3_blok4_consumption:
name: "Block 4 Consumption"
min: 0
max: 10000
step: 0.01
unit_of_measurement: 'kWh' 

phase3_blok5_consumption:
 name: "Block 5 Consumption"
 min: 0
 max: 10000
 step: 0.01
 unit_of_measurement: 'kWh'

and automations.yaml:

- id: '1739128677653'
 alias: Monitoring consumption by blocks
 description: ''
 triggers:
 - entity_id: sensor.elektro_network_tariff
 trigger: state
 conditions: []
 actions:
 - target:
 entity_id: "{% if is_state('sensor.elektro_network_tariff', '1') %}\n input_number.faza3_blok1_consumption\n{%
 elif is_state('sensor.elektro_network_tariff', '2') %}\n input_number.faza3_blok2_consumption\n{%
 elif is_state('sensor.elektro_network_tariff', '3') %}\n input_number.faza3_blok3_consumption\n{%
 elif is_state('sensor.elektro_network_tariff', '4') %}\n input_number.faza3_blok4_consumption\n{%
 elif is_state('sensor.elektro_network_tariff', '5') %}\n input_number.faza3_blok5_consumption\n{%
 endif %}\n"
 date:
 value: '{{ (states(''sensor.p1_meter_power_phase_3_w_to_kwh'')) }}

 '
 action: input_number.set_value
 fashion: single
```?
#

I think I understand. I should use this sensor that calculates the cumulative monthly consumption for phase 3.

dense tree
#

Check https://www.home-assistant.io/integrations/template/

I would create template sensor (in your configuration.yaml) which looks like following

template:
  - sensor:
      - name: "Block 1 power"
        unit_of_measurement: "W"
        state: {{ iif(states('sensor.elektro_network_tariff') == 1, states('sensor.p1_meter_power_phase_3'), 0) | float }}
        
      - name: "Block 2 power"
        unit_of_measurement: "W"
        state: {{ iif(states('sensor.elektro_network_tariff') == 2, states('sensor.p1_meter_power_phase_3'), 0) | float }}
        
      - name: "Block 3 power"
        unit_of_measurement: "W"
        state: {{ iif(states('sensor.elektro_network_tariff') == 3, states('sensor.p1_meter_power_phase_3'), 0) | float }}
        
...

then you have 5 sensors sensor.block_1_power, bloc2, block3... etc for which you can create integral

https://www.home-assistant.io/integrations/integration/

Home Assistant

Instructions on how to integrate Template Sensors into Home Assistant.

Home Assistant

Instructions on how to integrate Integration Sensor into Home Assistant.