Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 106835

InfluxDB select to Home assistant sensor

$
0
0

Hi all, I’ve been working for a few months on this need.

Need: I want to have a sensor, representing the last 24 hours of rain accumulation in mm. I would use this sensor to control my automation that would be blocking (not started) the valves controlling the irrigation of the garden. For example, if the last 24 hours of precipitation is above 25mm, don’t start the irrigation automation.

For that:

  1. I added the AccuWeather API to HomeAssistant that sends this data to influxDB. That part works fine.

  2. I did a select in influxDB to sum the last 24 hours of data. That part works fine.

SELECT sum(“value”) as “Total_Rain” FROM “Semis_Garage”.“autogen”.“mm” WHERE time>now()-1d

For example, this morning, it shows 19.2 mm for the last 24h, it rained yesterday. Part 3 is commented out for now.

  1. Then I added in HomeAssistant config, an influxdb sensor, to have it available in HomeAssistant automation (maybe there’s another way?)

This is where it’s not working as expected!

  • platform: influxdb
    host: localhost
    username: homeassistant
    password: “PASSWORD”
    queries:
    • name: TotalRainPast24h
      unit_of_measurement: mm
      value_template: ‘{{ value | round(1) }}’
      where: ‘time > now() -1d’
      group_function: sum
      measurement: Semis_Garage.autogen.mm
      field: “value”
      database: Semis_Garage

After a restart, I added this sensor to the dashboard to test.

The first display of the number of mm of rain for the past 24 hours worked fine, but then, the next update after 60 seconds (I assume this is the default refresh rate of this sensor), the value was double! Then every 60 seconds or so, the value doubled. After a while, I was at 33 digits mm of rain!!! enough to fill the solar system :wink:

So the question is, what did I do wrong?

The funny thing is, when I went back to the influx DB screen and ran the same select, the value was doubled (x time). So it seems the sensors from HomeAssistant is writing back to the DB?

Thanks for any input.

Simon

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 106835

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>