mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-04 10:19:29 +02:00
fix mqtt auto
This commit is contained in:
parent
0993b52553
commit
8e38e8562f
1 changed files with 7 additions and 7 deletions
|
@ -60,7 +60,7 @@ static void publish_cell_voltages(void) {
|
||||||
"\"object_id\": \"sensor_battery_voltage_cell%d\","
|
"\"object_id\": \"sensor_battery_voltage_cell%d\","
|
||||||
"\"origin\": {"
|
"\"origin\": {"
|
||||||
"\"name\": \"BatteryEmulator\","
|
"\"name\": \"BatteryEmulator\","
|
||||||
"\"sw\": \"5.1.0-mqtt\","
|
"\"sw\": \"%s-mqtt\","
|
||||||
"\"url\": \"https://github.com/dalathegreat/Battery-Emulator\""
|
"\"url\": \"https://github.com/dalathegreat/Battery-Emulator\""
|
||||||
"},"
|
"},"
|
||||||
"\"state_class\": \"measurement\","
|
"\"state_class\": \"measurement\","
|
||||||
|
@ -70,7 +70,7 @@ static void publish_cell_voltages(void) {
|
||||||
"\"unit_of_measurement\": \"V\","
|
"\"unit_of_measurement\": \"V\","
|
||||||
"\"value_template\": \"{{ value_json.cell_voltages[%d] }}\""
|
"\"value_template\": \"{{ value_json.cell_voltages[%d] }}\""
|
||||||
"}",
|
"}",
|
||||||
i + 1, i + 1, i + 1, i);
|
i + 1, versionNumber, i + 1, i + 1, i);
|
||||||
// End each discovery topic with cell number and '/config'
|
// End each discovery topic with cell number and '/config'
|
||||||
String cell_topic = topic + String(i + 1) + "/config";
|
String cell_topic = topic + String(i + 1) + "/config";
|
||||||
mqtt_publish_retain(cell_topic.c_str());
|
mqtt_publish_retain(cell_topic.c_str());
|
||||||
|
@ -134,18 +134,18 @@ static void publish_common_info(void) {
|
||||||
"\"name\": \"%s\","
|
"\"name\": \"%s\","
|
||||||
"\"state_topic\": \"%s\","
|
"\"state_topic\": \"%s\","
|
||||||
"\"unique_id\": \"battery-emulator_%s\","
|
"\"unique_id\": \"battery-emulator_%s\","
|
||||||
"\"object_id\": \"%s\","
|
"\"object_id\": \"sensor_battery_%s\","
|
||||||
"\"device\": {"
|
"\"device\": {"
|
||||||
"\"identifiers\": ["
|
"\"identifiers\": ["
|
||||||
"\"battery-emulator\""
|
"\"battery-emulator\""
|
||||||
"],"
|
"],"
|
||||||
"\"manufacturer\": \"DalaTech\","
|
"\"manufacturer\": \"DalaTech\","
|
||||||
"\"model\": \"BatteryEmulator\","
|
"\"model\": \"BatteryEmulator\","
|
||||||
"\"name\": \"BatteryEmulator\","
|
"\"name\": \"BatteryEmulator\""
|
||||||
"},"
|
"},"
|
||||||
"\"origin\": {"
|
"\"origin\": {"
|
||||||
"\"name\": \"BatteryEmulator\","
|
"\"name\": \"BatteryEmulator\","
|
||||||
"\"sw\": \"5.1.0-mqtt\","
|
"\"sw\": \"%s-mqtt\","
|
||||||
"\"url\": \"https://github.com/dalathegreat/Battery-Emulator\""
|
"\"url\": \"https://github.com/dalathegreat/Battery-Emulator\""
|
||||||
"},"
|
"},"
|
||||||
"\"value_template\": \"%s\","
|
"\"value_template\": \"%s\","
|
||||||
|
@ -154,7 +154,7 @@ static void publish_common_info(void) {
|
||||||
"\"enabled_by_default\": true,"
|
"\"enabled_by_default\": true,"
|
||||||
"\"state_class\": \"measurement\""
|
"\"state_class\": \"measurement\""
|
||||||
"}",
|
"}",
|
||||||
config.name, state_topic, config.object_id, config.object_id, config.value_template, config.unit, config.device_class);
|
config.name, state_topic, config.object_id, config.object_id, versionNumber, config.value_template, config.unit, config.device_class);
|
||||||
mqtt_publish_retain(config.topic);
|
mqtt_publish_retain(config.topic);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -167,7 +167,7 @@ static void publish_common_info(void) {
|
||||||
" \"stat_batt_power\": %.3f,\n"
|
" \"stat_batt_power\": %.3f,\n"
|
||||||
" \"battery_current\": %.3f,\n"
|
" \"battery_current\": %.3f,\n"
|
||||||
" \"cell_max_voltage\": %d,\n"
|
" \"cell_max_voltage\": %d,\n"
|
||||||
" \"cell_min_voltage\": %d\n"
|
" \"cell_min_voltage\": %d,\n"
|
||||||
" \"battery_voltage\": %d\n"
|
" \"battery_voltage\": %d\n"
|
||||||
"}\n",
|
"}\n",
|
||||||
((float)SOC) / 100.0,
|
((float)SOC) / 100.0,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue