syssi / esphome-jk-bms

ESPHome component to monitor and control a Jikong Battery Management System (JK-BMS) via UART-TTL or BLE
Apache License 2.0
405 stars 134 forks source link

Can it add "Charge&Discharge Switch" function? #404

Closed zjhcr closed 6 months ago

zjhcr commented 6 months ago

the UART command is below:

"Turn ON Charge": [0x4E, 0x57, 0X00, 0x14, 0x00, 0x00, 0x00, 0x00, 0X02, 0X03,0X00, 0XAB, 0X01, 0X00, 0X00, 0X00, 0X00, 0X68, 0X00, 0X00, 0X01, 0XD2]);

"Turn OFF Charge":[0x4E, 0x57, 0X00, 0x14, 0x00, 0x00, 0x00, 0x00, 0X02, 0X03, 0X00, 0XAB, 0X00, 0X00, 0X00, 0X00, 0X00, 0X68, 0X00,0X00, 0X01, 0XD1]);

"Turn ON Discharge":[0x4E, 0x57, 0X00, 0x14, 0x00, 0x00, 0x00, 0x00, 0X02, 0X03, 0X00, 0XAC, 0X01, 0X00, 0X00, 0X00, 0X00, 0X68, 0X00, 0X00, 0X01, 0XD3]);

"Turn OFF Discharge":[0x4E, 0x57, 0X00, 0x14, 0x00, 0x00, 0x00, 0x00, 0X02, 0X03, 0X00, 0XAC, 0X00, 0X00, 0X00, 0X00, 0X00, 0X68, 0X00, 0X00, 0X01, 0XD2]);

I have been tested these commands works well. I'd appreciate if you could add these function into esphome firmware? Thanks a lot.

syssi commented 6 months ago

These commands are already implemented as switch entities: https://github.com/syssi/esphome-jk-bms/blob/main/components/jk_bms/switch/__init__.py#L18-L19

Please add these lines to your YAML configuration:

switch:
  - platform: jk_bms
    charging:
      name: "${name} charging"
    discharging:
      name: "${name} discharging"
AlbertWete commented 5 months ago

Hi, I get this. INFO ESPHome 2023.12.5 INFO Reading configuration esp8266-example.yaml... Failed config

switch.jk_bms: [source :265]

Platform not found: 'switch.jk_bms'. platform: jk_bms charging: name: jk-bms charging discharging: name: jk-bms discharging

syssi commented 5 months ago

@AlbertWete Please create a new issue and provide your complete configuration YAML (esp8266-example.yaml).