I have InfluxDB addon, and Home Assistant sends data to its default database. This works well.
I also have InfluxDB sensor which works:
- platform: influxdb
host: 192.168.0.10
username: homeassistant
password: !secret influxdb
queries:
- name: Min for last 18hour
unit_of_measurement: °C
value_template: '{{ value | round(1) }}'
group_function: min
where: '"entity_id" = ''outdoortemperature'' and time > now() - 18h'
measurement: '"°C"'
field: min_value
database: homeassistant
I also have another database, to which I send sensor data from external system (another Raspberry Pi running RuuviTag collector).
When using InluxDB:s Explore, I see that values are updating. And when I initially created sensors to Home Assistant, values were updating.
But now sensor values won’t update. I can’t figure out why. Restarting HA or other Raspberry does not help. Values in InfluxDB do update, but not on HA sensors. Recreating sensors with same names does not help.
Has anyone else had this kind of issue with InfluxDB sensor?
Sensor configuration:
I have not been able to solve this from HA, I will do workaround by on external system running python, which queries influxdb, and sends data to HA by MQTT. Not ideal, but it should work. Got to see in few weeks when I have time to work on this.
I finally get this work.
To document it to myself and help other in same problem I dare to hijack this topic.
I used topic owner configuration in starting point and ended to following…
- platform: influxdb
host: 10.10.10.235
port: 8086
username: homeassistant
password: ******************
queries:
- name: patio_temp
unit_of_measurement: °C
value_template: '{{ value | round(1) }}'
group_function: last
where: '"mac" = ''C9:AA:26:BA:C6:02'''
measurement: 'ruuvi_measurements'
field: temperature
database: ruuvi
noteworthy was add port and group_function.
Also MAC need to write same way that in Influxdb with : mark (this of cource debend how you system write it)
Nice! I don’t remember if I tried having group functions in query. It is curious, that queries against Home Assistants own DB work, but not against other internal InfluxDB database.
And I just realized, that I did my “solution” bit hard way: I have Ruuvi collector and TICK stack on another raspberry, and I run python loop which queries data and sends it to HA via MQTT. I could as well try to add InfluxDB sensor to HA, querying remote InfluxDB. Live, learn and forget.