Hi all, I’m trying to integrate my 4 pylontech batteries into HA using ESPHome and the pylontech integration available with latest update of ESPHome.
I did the hardware setup and it is correct.
Now I’m trying to edit the yaml file and I get an error in the UART part. I am following direction of the pylontech integration I found here but I’m not able to have it working.
Can someone point me to the right direction?
Following is the yaml file I’m trying to do
esphome:
name: batterie-solare
friendly_name: Batterie Solare
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: !secret api_key
ota:
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Batterie-Solare Fallback Hotspot"
password: !secret ap_password
captive_portal:
pylontech:
id: pylontech0
- uart_id: 0
- update_interval: 60s
sensor:
- platform: pylontech
battery: 1
voltage:
id: bat1_voltage
name: "Battery1 Voltage"
current:
id: bat1_current
name: "Battery1 Current"
coulomb:
name: "Battery1 State of Charge"
temperature:
name: "Battery1 Temperature"
- platform: pylontech
battery: 2
voltage:
id: bat2_voltage
name: "Battery2 Voltage"
current:
id: bat2_current
name: "Battery2 Current"
coulomb:
name: "Battery2 State of Charge"
temperature:
name: "Battery2 Temperature"
- platform: pylontech
battery: 3
voltage:
id: bat3_voltage
name: "Battery3 Voltage"
current:
id: bat3_current
name: "Battery3 Current"
coulomb:
name: "Battery3 State of Charge"
temperature:
name: "Battery3 Temperature"
- platform: pylontech
battery: 4
voltage:
id: bat4_voltage
name: "Battery4 Voltage"
current:
id: bat4_current
name: "Battery4 Current"
coulomb:
name: "Battery4 State of Charge"
temperature:
name: "Battery4 Temperature"
- platform: template
id: pylontech_power
name: "Pylontech power"
unit_of_measurement: W
lambda: |-
auto pwr1 = id(bat1_voltage).state * id(bat1_current).state;
auto pwr2 = id(bat2_voltage).state * id(bat2_current).state;
auto pwr3 = id(bat3_voltage).state * id(bat3_current).state;
auto pwr4 = id(bat4_voltage).state * id(bat4_current).state;
auto pwr = pwr1 + pwr2 + pwr3 + pwr4;
id(combined_charge_power).publish_state(max(pwr, 0.0f));
id(combined_discharge_power).publish_state(max(-pwr, 0.0f));
return pwr;
update_interval: 5s
device_class: power
state_class: measurement
- platform: template
id: combined_charge_power
- platform: template
id: combined_discharge_power
- platform: integration
name: "Pylontech charging"
sensor: combined_charge_power
time_unit: h
state_class: total_increasing
device_class: energy
unit_of_measurement: "Wh"
- platform: integration
name: "Pylontech discharging"
sensor: combined_discharge_power
time_unit: h
state_class: total_increasing
device_class: energy
unit_of_measurement: "Wh"
text_sensor:
- platform: pylontech
battery: 1
base_state:
id: bat1_base_state
name: "Battery1 Base State"
voltage_state:
id: bat1_voltage_state
name: "Battery1 Voltage State"
current_state:
id: bat1_current_state
name: "Battery1 Current State"
temperature_state:
id: bat1_temperature_state
name: "Battery1 Temperature State"
- platform: pylontech
battery: 2
base_state:
id: bat2_base_state
name: "Battery2 Base State"
voltage_state:
id: bat2_voltage_state
name: "Battery2 Voltage State"
current_state:
id: bat2_current_state
name: "Battery2 Current State"
temperature_state:
id: bat2_temperature_state
name: "Battery2 Temperature State"
- platform: pylontech
battery: 3
base_state:
id: bat3_base_state
name: "Battery3 Base State"
voltage_state:
id: bat3_voltage_state
name: "Battery3 Voltage State"
current_state:
id: bat3_current_state
name: "Battery3 Current State"
temperature_state:
id: bat3_temperature_state
name: "Battery3 Temperature State"
- platform: pylontech
battery: 4
base_state:
id: bat4_base_state
name: "Battery4 Base State"
voltage_state:
id: bat4_voltage_state
name: "Battery4 Voltage State"
current_state:
id: bat4_current_state
name: "Battery4 Current State"
temperature_state:
id: bat4_temperature_state
name: "Battery4 Temperature State"