Pylontech Battery monitor

Hello everyone,
I’ve forked a project for monitor and control pylotech battery from console port and send data to home assistant over wifi with mqtt.

I’ve also implemented a web server for control and monitor directly.

interesting. I’m investigating battery purchase and seen pylontech as option indeed. you’re using the CAN bus right? Is that bus not ethernet compatible normally?
I dont necessarly need wifi, so hence the question, would without the wifi need the setup be straight forward?

I use console port rs232, there isn’t ethernet port on pylontech.
If you don’t use wifi you can try to modify the project and use an ethernet adapter port

ok… thx. thought that CAN bus was ETH too.

Great Idea!

How to implement it than in Home Assistant?
So if i flash my ESP D1 Mini with that and the correct connection, how to get that into my Home Assistant?

Didnt find what to do on the readme.

Would be great if you can add how to implement it into home assistant on the readme :slight_smile:
I am already using the original project but didnt know how to use it in home assistant.

Already tried to put it on my ESP8266, but get error:

ArduinoJson.h: No such file or directory

Probably forget libery?

Just installed ArduinoJson directly in arduino. It works.

But how to see the MQTT Stats now? I used the MQTT from my home assistant but doesnt get a new one there

You can access data from a web browser pointed at the ESP address. Type ‘help’ and it will list the commands. If you have multiple batteries then just append a number after the command to get the info for that battery.
If you’ve configured MQTT then you can use ‘mqtt explorer’ (https://mqtt-explorer.com/) to view the data transmitted

But how can i get the values now on Home Assistant with MQTT?

I saw yesterday that the ESP was connected to mqtt with logs. But if i check mqtt explorer, i didnt see it, so it is disconnected after a few minutes. But why?

Probably add HomeAssistant Discovery? :slight_smile:

My first pass at configuration of the configuration.yaml file. The entities then show up in Settings/Devices&Service/Entities under Pylontech Battery.


.
.
.
mqtt:
sensor:
- name: “Pylontech Battery”
state_topic: “homeassistant/sensor/grid_battery/soc”
unit_of_measurement: “%”
- name: “Pylontech Battery”
state_topic: “homeassistant/sensor/grid_battery/battery_count”


View from MQTT Explorer:
image

Thank you!

Did i see it right, that there is no voltage of the pylontech in the list?

Hi,
this is my conf for mqtt sensors:

mqtt:
  sensor:
    - name: "Livello Carica Batteria"
      state_topic: "homeassistant/sensor/grid_battery/soc"
      unit_of_measurement: "%"
      device_class: battery
      
    - name: "Stato Batteria"
      state_topic: "homeassistant/sensor/grid_battery/base_state"
      
    - name: "Temperatura Batteria"
      state_topic: "homeassistant/sensor/grid_battery/temp"
      unit_of_measurement: "°C"
      device_class: temperature
      
    - name: "Num Batterie"
      state_topic: "homeassistant/sensor/grid_battery/battery_count"
      
    - name: "Potenza impegnata Batterie"
      state_topic: "homeassistant/sensor/grid_battery/getPowerDC"
      unit_of_measurement: "Wh"
      device_class: energy
      
    - name: "Potenza carica Batterie"
      state_topic: "homeassistant/sensor/grid_battery/powerIN"
      unit_of_measurement: "Wh"
      state_class: "total_increasing"
      device_class: "energy"
      #last_reset: none
      icon: mdi:flash

      
    - name: "Potenza scarica Batterie"
      state_topic: "homeassistant/sensor/grid_battery/powerOUT"
      unit_of_measurement: "Wh"
      state_class: "total_increasing"
      device_class: "energy"
      #last_reset: none
      icon: mdi:flash

Hi,
I’vent implemented voltage in mqtt sensors yet, but it’s possibile

Can you add every sensor to it, that is possible? I mean its the best? :slight_smile: If someone dont need, than he dont need to setup the config.

Also, did you will implement Discovery, so it popups in integration? I hear that Home Assistant has Discovery MQTT - Home Assistant

There must be some parameters to instant show it in integration as other things do it also

as soon as I have time I implement the voltage, but for the discovery
I couldn’t get it to work, if anyone knows how to do it it’s welcome :grinning:

Probably /config missing on MQTT publish?

I also found this:

Hello,
I pasted the below in the configuration.yaml file but then did not show in the Settings/Devices&Service/Entities at all.

Can you please help?

mqtt:
sensor:

  • name: “Pylontech Battery”
    state_topic: “homeassistant/sensor/grid_battery/soc”
    unit_of_measurement: “%”
  • name: “Pylontech Battery”
    state_topic: “homeassistant/sensor/grid_battery/battery_count

Good day everyone, and most especially @hidaba … really hope that one of you can give me pointers, as I cannot get this device to output the battery data…

I followed instructions to the letter … Wemos connected to transceiver connected to UP5000. Accessible by IP Address, but if I type any command or click one of the four links, it tries to load for around 10sec but does not output anything…

image

Only runtime log link works to show the “new baud rate” changes.

Battery definitely set to 115200 baud.
I did use a different MAX3232 board than in the instructions (only has single TX and RX either side, no R1 / R2 etc.) - surely the different transceiver wouldn’t matter?

(sample image of my transceiver - obviosly com port replaced with RJ45)

Any recommendation on troubleshooting steps?

Hi David,
have you check mqtt server if it works correctly
I use “mqtt explorer” for debug data on mqtt

Hi,
Do you used arduino? I’ve tested it on esp8266.
tx and rx seems ok, but have you try to invert them on arduino?

Hi,
I just set up this Project on the corresponding hardware. This worked successful and I got all entities in Home Assistant.

The only Problem I have is, that the Entity which should contain the charged and discharged kWh is not correlated to the time.
It acts like a mirror of the DC Power entity, putting all positive values to charged and all negative values to discharged…
From the description I thought it would give me a increasing energy meter.

Is this behavior intended? The actual code is commented with ah and wh, but the actual values don’t contain any time related values