Hello,
this is driving me crazy for days now!
I have a ESP D1 mini connected to a Victron IP22 battery charger in order to control the charging current. The control from esphome via UART is working fine.
But I did not manage to pass the current as a numerical value from homeassistant!
I have found a couple of threads explaining this, and I think I followed the examples to setup the HA side as well as the esphome side.
Here is the homeassistant part that defines an input number and a sensor that gets the value. This part seem to work, as I can set values with the GUI slider and see the senbsor state change in developer tools page.
Homeassistant configuration.yaml:
input_number:
num_charger_current:
name: AC Charger Current
initial: 3
min: 3
max: 12
step: 1
sensor:
# This is a sensor to be read by esphome to control the charging current
- platform: template
sensors:
ac_charger_current:
value_template: "{{ states('input_number.num_charger_current') | int }}"
unit_of_measurement: "A"
Here is the esphome side.
I defined the sensor of the homeassistant side (platform: homeassistant) referenced the entity id.
In order to check, if the value is passed, I defined another template sensor, that is displayed in the web interface. However this sensor is always showing “NAN”, regardless what value I set with the slider.
esphome yaml:
sensor:
# This is to get the charging current from HA
- platform: homeassistant
name: "AC Charger Current"
entity_id: sensor.ac_charger_current
id: id_ac_charger_current
unit_of_measurement: 'A'
# Show value of charging current received from HA
- platform : template
name: charge current received
unit_of_measurement: 'A'
lambda: |-
return { id(id_ac_charger_current).state };
update_interval: 1s
I wonder, how I can verify, if the value is actually passed via the api interface?
I did set the esphome logger level to DEBUG, but see no output, if I move the slider.
Can someone please have a look at the code for any mistakes or guide me on how to debug the transfer of the value via the api?
I deeply appreciate any help on this issue.
Thank you.
nob
Edit: Maybe this is helpful: I noticed that there are API connection errors every minute or so:
WARNING victron-mppt @ 192.168.181.81: Connection error occurred: [Errno 104] Connection reset by peer
INFO Processing unexpected disconnect from ESPHome API for victron-mppt @ 192.168.181.81
WARNING Disconnected from API
INFO Successfully connected to victron-mppt @ 192.168.181.81 in 0.005s
INFO Successful handshake with victron-mppt @ 192.168.181.81 in 3.011s