Unreliable InfluxDB size sensor

That’s an excellent idea Eric! Works perfectly. Hopefully it will solve this issue too:

The only addition I’ve made is to add the retained flag so that the sensor restores after a Home Assistant restart and to change the topic to match the structure I use:

init_commands:
  - >-
    while [ 1 = 1 ]; do docker exec addon_a0d7b954_influxdb du -s
    /data/influxdb/data/homeassistant | mosquitto_pub -t
    home-assistant/sensor/dbsize -r -u <user> -P <password> -l && sleep
    300; done &

Mqtt sensor:

- name: InfluxDB DB Size
  unit_of_measurement: 'MB'
  icon: hass:chart-line
  state_topic: "home-assistant/sensor/dbsize"
  value_template: "{{ (value.split('\t')[0]|int(0)/1000)|round(3) }}" 
5 Likes