Skip to content

Commit

Permalink
Add balancer switch (Closes: #25) (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
syssi authored Nov 11, 2024
1 parent be4ca95 commit d6673c3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions components/daly_bms_ble/daly_bms_ble.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class DalyBmsBle : public esphome::ble_client::BLEClientNode, public PollingComp

void set_errors_text_sensor(text_sensor::TextSensor *errors_text_sensor) { errors_text_sensor_ = errors_text_sensor; }

void set_balancer_switch(switch_::Switch *balancer_switch) { balancer_switch_ = balancer_switch; }
void set_charging_switch(switch_::Switch *charging_switch) { charging_switch_ = charging_switch; }
void set_discharging_switch(switch_::Switch *discharging_switch) { discharging_switch_ = discharging_switch; }

Expand Down Expand Up @@ -115,6 +116,7 @@ class DalyBmsBle : public esphome::ble_client::BLEClientNode, public PollingComp
sensor::Sensor *temperature_sensors_sensor_;
sensor::Sensor *capacity_remaining_sensor_;

switch_::Switch *balancer_switch_;
switch_::Switch *charging_switch_;
switch_::Switch *discharging_switch_;

Expand Down
9 changes: 9 additions & 0 deletions components/daly_bms_ble/switch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@

CODEOWNERS = ["@syssi"]

CONF_BALANCER = "balancer"
CONF_CHARGING = "charging"
CONF_DISCHARGING = "discharging"

ICON_BALANCER = "mdi:seesaw"
ICON_CHARGING = "mdi:battery-charging-50"
ICON_DISCHARGING = "mdi:battery-charging-50"

SWITCHES = {
CONF_BALANCER: 0x00CF,
CONF_CHARGING: 0x00A5,
CONF_DISCHARGING: 0x00A6,
}
Expand All @@ -24,6 +27,12 @@

CONFIG_SCHEMA = DALY_BMS_BLE_COMPONENT_SCHEMA.extend(
{
cv.Optional(CONF_BALANCER): switch.SWITCH_SCHEMA.extend(
{
cv.GenerateID(): cv.declare_id(DalySwitch),
cv.Optional(CONF_ICON, default=ICON_BALANCER): cv.icon,
}
).extend(cv.COMPONENT_SCHEMA),
cv.Optional(CONF_CHARGING): switch.SWITCH_SCHEMA.extend(
{
cv.GenerateID(): cv.declare_id(DalySwitch),
Expand Down
Binary file added docs/pdus/btsnoop_daly_balancer.log
Binary file not shown.
2 changes: 2 additions & 0 deletions esp32-ble-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ text_sensor:

switch:
- platform: daly_bms_ble
balancer:
name: "${name} balancer"
charging:
name: "${name} charging"
discharging:
Expand Down

0 comments on commit d6673c3

Please sign in to comment.