It would be great if there was a way to restrict which entities have their state changes published via MQTT.
I have some sensors that are updated once per second (which report power usage for a number of branch circuits.) This data can consume a lot of space in the recorder database, so I’ve excluded it there. However, when publishing these state changes, I also get events logged in the databased as a consequence of the MQTT activity like this:
sqlite> select * from events order by created desc limit 20;
16080636|service_executed|{"service_call_id": "4410591664-162162"}|LOCAL|2017-10-18 13:18:49.538304|2017-10-18 13:18:49.541744
16080635|call_service|{"service": "publish", "domain": "mqtt", "service_data": {"topic": "19916/homeassistant/sensor/power_total/state", "payload": "1023.0", "retain": true, "qos": 1}, "service_call_id": "4410591664-162162"}|LOCAL|2017-10-18 13:18:49.533652|2017-10-18 13:18:49.539218
16080634|service_executed|{"service_call_id": "4410591664-162161"}|LOCAL|2017-10-18 13:18:48.553081|2017-10-18 13:18:48.565953
16080633|service_executed|{"service_call_id": "4410591664-162160"}|LOCAL|2017-10-18 13:18:48.551799|2017-10-18 13:18:48.561557
16080632|service_executed|{"service_call_id": "4410591664-162159"}|LOCAL|2017-10-18 13:18:48.550754|2017-10-18 13:18:48.559761
16080631|call_service|{"service": "publish", "domain": "mqtt", "service_data": {"topic": "19916/homeassistant/sensor/power_total/state", "payload": "1024.0", "retain": true, "qos": 1}, "service_call_id": "4410591664-162161"}|LOCAL|2017-10-18 13:18:48.546971|2017-10-18 13:18:48.558104
16080630|call_service|{"service": "publish", "domain": "mqtt", "service_data": {"topic": "19916/homeassistant/sensor/power_fridge/state", "payload": "115.0", "retain": true, "qos": 1}, "service_call_id": "4410591664-162160"}|LOCAL|2017-10-18 13:18:48.546802|2017-10-18 13:18:48.556324
16080629|call_service|{"service": "publish", "domain": "mqtt", "service_data": {"topic": "19916/homeassistant/sensor/power_volts/state", "payload": "123.2", "retain": true, "qos": 1}, "service_call_id": "4410591664-162159"}|LOCAL|2017-10-18 13:18:48.540044|2017-10-18 13:18:48.549988
16080628|service_executed|{"service_call_id": "4410591664-162158"}|LOCAL|2017-10-18 13:18:47.557605|2017-10-18 13:18:47.568535
16080627|service_executed|{"service_call_id": "4410591664-162157"}|LOCAL|2017-10-18 13:18:47.555074|2017-10-18 13:18:47.566540
16080626|service_executed|{"service_call_id": "4410591664-162156"}|LOCAL|2017-10-18 13:18:47.552531|2017-10-18 13:18:47.562759
16080625|call_service|{"service": "publish", "domain": "mqtt", "service_data": {"topic": "19916/homeassistant/sensor/power_total/state", "payload": "1026.0", "retain": true, "qos": 1}, "service_call_id": "4410591664-162158"}|LOCAL|2017-10-18 13:18:47.546467|2017-10-18 13:18:47.560990
16080624|call_service|{"service": "publish", "domain": "mqtt", "service_data": {"topic": "19916/homeassistant/sensor/power_fridge/state", "payload": "114.0", "retain": true, "qos": 1}, "service_call_id": "4410591664-162157"}|LOCAL|2017-10-18 13:18:47.546284|2017-10-18 13:18:47.558916
16080623|call_service|{"service": "publish", "domain": "mqtt", "service_data": {"topic": "19916/homeassistant/sensor/power_volts/state", "payload": "123.3", "retain": true, "qos": 1}, "service_call_id": "4410591664-162156"}|LOCAL|2017-10-18 13:18:47.542724|2017-10-18 13:18:47.549915
16080622|service_executed|{"service_call_id": "4410591664-162155"}|LOCAL|2017-10-18 13:18:46.538614|2017-10-18 13:18:46.541959
16080621|call_service|{"service": "publish", "domain": "mqtt", "service_data": {"topic": "19916/homeassistant/sensor/power_total/state", "payload": "1014.0", "retain": true, "qos": 1}, "service_call_id": "4410591664-162155"}|LOCAL|2017-10-18 13:18:46.533674|2017-10-18 13:18:46.539276
16080620|service_executed|{"service_call_id": "4410591664-162154"}|LOCAL|2017-10-18 13:18:45.545590|2017-10-18 13:18:45.552038
16080619|service_executed|{"service_call_id": "4410591664-162153"}|LOCAL|2017-10-18 13:18:45.544014|2017-10-18 13:18:45.550371
16080618|call_service|{"service": "publish", "domain": "mqtt", "service_data": {"topic": "19916/homeassistant/sensor/power_total/state", "payload": "1023.0", "retain": true, "qos": 1}, "service_call_id": "4410591664-162154"}|LOCAL|2017-10-18 13:18:45.540931|2017-10-18 13:18:45.548561
16080617|call_service|{"service": "publish", "domain": "mqtt", "service_data": {"topic": "19916/homeassistant/sensor/power_volts/state", "payload": "123.2", "retain": true, "qos": 1}, "service_call_id": "4410591664-162153"}|LOCAL|2017-10-18 13:18:45.536683|2017-10-18 13:18:45.545137
In the mean time, I’ve had to disable the MQTT eventstream component to avoid generating an extra gazillion events per day.
Ideally, the publishing of these MQTT messages wouldn’t need to be inserted into the events table of the recorder database, and I’d like to be able to control which entities are published via MQTT… In my circumstance, these power measurements are from MQTT sensors, so I don’t need to publish them again on a different topic.