From fa31ab859007624478c1b0d56f6e8ec885b07dc4 Mon Sep 17 00:00:00 2001 From: polyfloyd Date: Sun, 29 Sep 2024 20:38:42 +0200 Subject: [PATCH] services: Fix power total_kwh --- roles/monitoring/templates/mqtt_exporter_config.yaml | 3 ++- roles/services/templates/power-mqtt.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/roles/monitoring/templates/mqtt_exporter_config.yaml b/roles/monitoring/templates/mqtt_exporter_config.yaml index 39d147a..e1f1cbb 100644 --- a/roles/monitoring/templates/mqtt_exporter_config.yaml +++ b/roles/monitoring/templates/mqtt_exporter_config.yaml @@ -15,7 +15,8 @@ export: - subscribe: bitlair/# - subscribe: bitlair/climate/+location/# - subscribe: bitlair/climate/+location/dust_mass/+size - - subscribe: bitlair/power/+net/+group/# + - subscribe: bitlair/power/+net/+group/now_w + - subscribe: bitlair/power/+net/total_kwh - subscribe: bitlair/wifi/+ssid/# - subscribe: bitlair/state diff --git a/roles/services/templates/power-mqtt.py b/roles/services/templates/power-mqtt.py index becccc7..2fcd038 100644 --- a/roles/services/templates/power-mqtt.py +++ b/roles/services/templates/power-mqtt.py @@ -21,7 +21,7 @@ while True: sleep(10) try: data = requests.get(f'http://{sdm630_host}/api/v1/data').json() - client.publish('bitlair/power/total_kwh', data['total_power_import_kwh']) + client.publish(f'bitlair/power/{net}/total_kwh', data['total_power_import_kwh']) client.publish(f'bitlair/power/{net}/All/now_w', data['active_power_w']) client.publish(f'bitlair/power/{net}/L1/now_w', data['active_power_l1_w']) client.publish(f'bitlair/power/{net}/L2/now_w', data['active_power_l2_w'])