This sensor allows me to know the istantaneous power drawn from the grid. How can I get the daily energy from this sensor? I tried to use the Total Daily Energy Sensor component but it requires an id which I don’t have
sensor:
- platform: template
sensors:
prelievo_istantaneo_corrente:
friendly_name: Prelievo istantaneo Chint
device_class: power
value_template: >
{% set linea = states('sensor.esp32_chint_potenza_istantanea')|int(0)
%} {% if linea < 0 %}
{{ 0 - linea }}
{% else %} {{ 0 | int }} {% endif %}
unit_of_measurement: W
The original sensor (sensor.esp32_chint_instantaneous_power) takes data from the registers of a Meter Chint through an Esp32 microcontroller in EspHome.
This register returns both positive and negative instantaneous power (feed to grid/puchased from grid).
I created a custom yaml file inside the packages folder in which, with the above code, I get two sensors, one for instantaneus purchased power and one for instantaneus feed power (named Prelievo istantaneo Chint and Immissione istantanea Chint).
I used Prelievo istantaneo Chint sensor in Integration - Riemann sum integral but I get som incredible data, as if in one day I purchased about 1.600 Wh
Actually my daily withdrawals from the grid are much lower, around 1 to 20 Wh (verified by the electricity distributor)
esphome:
name: "chint-meter"
friendly_name: Esp32
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
level: verbose
baud_rate: 0
#web_server:
#port: 80
# Enable Home Assistant API
api:
encryption:
key: "yyyyyyy"
ota:
password: "xxxxx"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
#manual_ip:
#static_ip: 192.168.1.234
#gateway: 192.168.1.254
#subnet: 255.255.255.0
#dns1: 192.168.1.254
#dns2: 8.8.4.4
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esp32 Fallback Hotspot"
password: "xxxxx"
captive_portal:
###
uart:
id: mod_bus
tx_pin: 03
rx_pin: 01
baud_rate: 9600
stop_bits: 1
modbus:
flow_control_pin: 5
id: modbus1
modbus_controller:
address: 0x001
modbus_id: modbus1
update_interval: 1s
setup_priority: -10
sensor:
- platform: modbus_controller
id: chint_voltage
name: "Chint Tensione"
address: 0x2000
unit_of_measurement: "V" ## for any other unit the value is returned in minutes
register_type: holding
value_type: FP32
accuracy_decimals: 2
filters:
- multiply: 1
- platform: modbus_controller
id: chint_current
name: "Chint Corrente"
address: 0x2002
unit_of_measurement: "A" ## for any other unit the value is returned in minutes
register_type: read
value_type: FP32
accuracy_decimals: 2
filters:
- multiply: 1
- platform: modbus_controller
id: chint_power
name: "Chint Potenza istantanea"
address: 0x2004
unit_of_measurement: "W" ## for any other unit the value is returned in minutes
state_class: "measurement"
register_type: read
value_type: FP32
accuracy_decimals: 2
filters:
- multiply: 1000
- platform: modbus_controller
id: chint_frequency
name: "Chint Frequenza Rete"
address: 0x200E
unit_of_measurement: "Hz" ## for any other unit the value is returned in minutes
register_type: read
value_type: FP32
accuracy_decimals: 2
filters:
- multiply: 1
- platform: modbus_controller
id: chint_energy_sold
name: "Chint Energia ceduta"
address: 0x4000
unit_of_measurement: "KWh" ## for any other unit the value is returned in minutes
register_type: read
value_type: FP32
accuracy_decimals: 2
filters:
- multiply: 1
- platform: modbus_controller
id: chint_energy_purchased
name: "Chint Energia acquistata"
address: 0x400A
unit_of_measurement: "Wh" ## for any other unit the value is returned in minutes
register_type: read
value_type: FP32
accuracy_decimals: 3
filters:
- multiply: 1000
- platform: modbus_controller
id: chint_reactive_power
name: "Chint Potenza reattiva"
address: 0x2004
unit_of_measurement: "Var" ## for any other unit the value is returned in minutes
register_type: read
value_type: FP32
accuracy_decimals: 2
filters:
- multiply: 1000
I divided the power sensor into two sensors, negative and positive.
So I used these two sensors for Total_daily_energy.
Then I created two sensors for yesterday’s energy using Time.
Do you think it can work?