Skip to content

Commit

Permalink
Add some switches
Browse files Browse the repository at this point in the history
  • Loading branch information
syssi committed May 8, 2024
1 parent 74c1371 commit e4446dd
Showing 1 changed file with 75 additions and 2 deletions.
77 changes: 75 additions & 2 deletions esp32-jk-pb-modbus-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ modbus:
modbus_controller:
- id: bms0
# Address of the Modbus slave device on the bus
address: 0x01
address: 0x00
modbus_id: modbus0
setup_priority: -10
update_interval: 5s
Expand Down Expand Up @@ -1019,7 +1019,7 @@ sensor:
# 0x12D8 216 UINT16 2 R VolChargCur mV
# 0x12DA 218 UINT16 2 R VolDischargCur mV

# 0x12BC 188 UINT32 4 R RunTime S
# 0x12BC 188 UINT32 4 R RunTime S
- platform: modbus_controller
modbus_controller_id: bms0
name: "${name} total runtime in seconds"
Expand All @@ -1030,6 +1030,79 @@ sensor:
accuracy_decimals: 0
id: total_runtime

switch:
- platform: modbus_controller
modbus_controller_id: bms0
name: "${name} discharging"
custom_command: [0x00, 0x03, 0x10, 0x74, 0x00, 0x02]
write_lambda: |-
payload.push_back(0x00);
payload.push_back(0x10);
payload.push_back(0x10);
payload.push_back(0x74);
payload.push_back(0x00);
payload.push_back(0x02);
payload.push_back(0x04);
payload.push_back(0x00);
payload.push_back(0x00);
payload.push_back(0x00);
payload.push_back(x);
return true;
lambda: |-
if (data.size() != 4 ) {
ESP_LOGE("Custom", "Invalid data size %d",data.size());
return {};
}
return (data[3] == 1);
- platform: modbus_controller
modbus_controller_id: bms0
name: "${name} charging"
custom_command: [0x00, 0x03, 0x10, 0x70, 0x00, 0x02]
write_lambda: |-
payload.push_back(0x00);
payload.push_back(0x10);
payload.push_back(0x10);
payload.push_back(0x70);
payload.push_back(0x00);
payload.push_back(0x02);
payload.push_back(0x04);
payload.push_back(0x00);
payload.push_back(0x00);
payload.push_back(0x00);
payload.push_back(x);
return true;
lambda: |-
if (data.size() != 4 ) {
ESP_LOGE("Custom", "Invalid data size %d",data.size());
return {};
}
return (data[3] == 1);
- platform: modbus_controller
modbus_controller_id: bms0
name: "${name} balancing"
custom_command: [0x00, 0x03, 0x10, 0x78, 0x00, 0x02]
write_lambda: |-
payload.push_back(0x00);
payload.push_back(0x10);
payload.push_back(0x10);
payload.push_back(0x78);
payload.push_back(0x00);
payload.push_back(0x02);
payload.push_back(0x04);
payload.push_back(0x00);
payload.push_back(0x00);
payload.push_back(0x00);
payload.push_back(x);
return true;
lambda: |-
if (data.size() != 4 ) {
ESP_LOGE("Custom", "Invalid data size %d",data.size());
return {};
}
return (data[3] == 1);
text_sensor:
- platform: template
name: "${name} total runtime formatted"
Expand Down

0 comments on commit e4446dd

Please sign in to comment.