Open tomlut opened 7 months ago
What value do you get when it should be negative?
You can see it in the history graphs I posted. It is value|abs
. i.e. the positive magnitude.
Look at the values from midnight to 7am. The power is positive, but the current is negative. Voltage is always positive.
Currently working around this issue with the following config:
sensor:
- platform: ina219
address: 0x40
shunt_resistance: 0.1 ohm
current:
name: "Shed Battery Current"
id: battery_current
filters:
- multiply: -1
- sliding_window_moving_average:
window_size: 10
send_every: 10
send_first_at: 1
on_value:
then:
- component.update: battery_power
# power:
# name: "Shed Battery Power"
# filters:
# - sliding_window_moving_average:
# window_size: 10
# send_every: 10
# send_first_at: 1
bus_voltage:
name: "Shed Battery Voltage"
id: battery_voltage
filters:
- sliding_window_moving_average:
window_size: 10
send_every: 10
send_first_at: 1
on_value:
then:
- component.update: battery_power
max_voltage: 15.0V
max_current: 3A
update_interval: 6s
- platform: template
name: "Shed Battery Power"
id: battery_power
unit_of_measurement: 'W'
state_class: measurement
device_class: power
lambda: |-
if ( (id(battery_current).state) && (id(battery_voltage).state) ){
return (id(battery_current).state * id(battery_voltage).state);
} else {
return NAN;
}
The problem
This is a bi-directional device.
A negative current and a positive voltage should produce a negative power (P = I x V).
However the power reported by ESPHome is always positive for the INA219. This makes it impossible to track battery state of charge without a work-around.
Which version of ESPHome has the issue?
2024.4.1
What type of installation are you using?
Home Assistant Add-on
Which version of Home Assistant has the issue?
core-2024.4.4
What platform are you using?
ESP32
Board
QuinLED ESP32
Component causing the issue
INA219
Example YAML snippet
Anything in the logs that might be useful for us?
No response
Additional information
No response