From: David Woodhouse Date: Sun, 20 Oct 2024 15:08:12 +0000 (+0100) Subject: Set up MQTT AD for the smart meter X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=f8a9f3929fd369b210c81b3d45b31868daf5ded3;p=users%2Fdwmw2%2Fesp32-pool.git Set up MQTT AD for the smart meter --- diff --git a/heishamon.yaml b/heishamon.yaml index 306aca8..92e879b 100644 --- a/heishamon.yaml +++ b/heishamon.yaml @@ -84,6 +84,34 @@ mqtt: blue: 100% red: 0% green: 0% + - delay: 2s + - mqtt.publish_json: + topic: ${mqtt_prefix}/homeassistant/sensor/meter/electricitymeter_power/config + retain: true + payload: |- + root["dev"]["ids"] = "electricitymeter"; + root["dev"]["name"] = "meter"; + root["dev_cla"] = "energy"; + root["name"] = "Meter Power"; + root["stat_cla"] = "measurement"; + root["stat_t"] = "glow/BCDDC2C24DB0/SENSOR/electricitymeter"; + root["uniq_id"] = "uniq_meter_id_power"; + root["unit_of_meas"] = "kW"; + root["val_tpl"] = "{{ value_json.electricitymeter.power.value }} "; + - mqtt.publish_json: + topic: '${mqtt_prefix}/homeassistant/sensor/meter/electricitymeter_kwh/config' + retain: true + payload: |- + root["dev"]["ids"] = "electricitymeter"; + root["dev"]["name"] = "meter"; + root["dev_cla"] = "energy"; + root["name"] = "Meter kWh"; + root["stat_cla"] = "total"; + root["stat_t"] = "glow/BCDDC2C24DB0/SENSOR/electricitymeter"; + root["uniq_id"] = "uniq_meter_id_kwh"; + root["unit_of_meas"] = "kwh"; + root["val_tpl"] = "{{ value_json.electricitymeter.energy.import.cumulative }} "; + on_disconnect: then: - light.turn_on: