13 Comments

  1. Paul

    I am still struggling with this and I believe it is down to the .yaml. Can you confirm your post is exact? Most other posts I was googling have quite a few sets of “”

    • Tobey

      Yes, I’m positive this is correct as I have it working in my current setup. Feel free to post the part of your yaml and I will take a look. Maybe I can spot the issue.

  2. Paul

    Thanks for trying!

    Up top:
    influxdb:
    host: 192.168.1.xxx
    verify_ssl: false
    exclude:
    entity_globs: “*”

    sensor:
    – platform: influxdb
    queries:
    – name: Pump Run Time
    field: Run Time
    where: ‘time > now() – 1d’
    group_function: last
    database: Pump_Monitor
    measurement: ‘”runTime”‘

    Query inspector in Grafana:

    SELECT “Run Time” FROM “runTime” WHERE time >= now() – 7d and time <= now()

    Sorry I did not see your reply at first. I have HA on 1 pi and then influxdb on another pi I have had running for awhile. My influxdb always logs the query – but returns a 400 code instead of 200. Which I assume are just the http codes for good and bad requests. I have that exact grafana query working from node red to influx so I was thinking that it is a matter of how HA formats the query.

    • Tobey

      Hi Paul,
      sorry for not getting back to you earlier.
      I guess the “field: Run Time” in your query is the issue. As the value contains a space I think you may need to wrap it into double quotes, please try that:
      field: “Run Time”

      And you assume correctly, http return codes 2xx are success states, 4xx are client errors.

  3. Paul

    Still does not work.

    ` queries:
    – name: SepticPumpRunTime2
    field: “Run Time”
    where: ‘time > now() – 1d’
    group_function: last
    measurement: ‘”runTime”‘

  4. Paul

    I have found a work around for this problem for now – I am able to pull the entire graphana chart into HA nicely. Thanks for the help though!

  5. Paul

    I circled back and got this working. Note how it is wrapped now by ‘ ” ” ‘.

    upper section of the config.yaml:

    influxdb:
    exclude:
    entity_globs: “*”
    then lower down.

    sensor:
    #influx sensors
    – platform: influxdb
    host: 192.168.1.51
    queries:
    – name: test_temp
    field: Temperature
    where: ‘time > now() – 7d’
    group_function: last
    database: YardWeather
    measurement: ‘”YardWeather”.”18months”.”WSReportedTemp”‘
    – name: influx_sp_run_time
    field: ‘”Run Time”‘
    where: ‘time > now() – 7d’
    group_function: last
    database: Pump_Monitor
    measurement: ‘”Pump_Monitor”.”autogen”.”runTime”‘

  6. Aaron

    Hey, I’d be so glad if you could help me.

    I got HA to work fine (using docker) on rpi.

    On that same pi I have a running influxdb (not in docker).

    Following query works:
    select last(Kapazitaet) from “solaranzeige”.”autogen”.”Batterie” where time > now() – 7d

    name: Batterie
    time last
    —- —-
    1671439871000000000 83.12

    I put, analog to your example, following lines into configuration.yaml:

    influxdb:
    # gateway from docker to host (can i verify this working ?)
    host: 172.17.0.1
    verify_ssl: false
    exclude:
    entity_globs: “*”

    sensor:
    – platform: influxdb
    queries:
    – name: influx_solar_soc
    field: Kapazitaet
    where: ‘time > now() – 1d’
    group_function: last
    database: solaranzeige
    measurement: ‘”solaranzeige”.”autogen”.”Batterie”‘

    Trying for days now with lot’s of variations but w/o luck.

    The sensor is never listed in HA !?

    So could you please check on this ?

    Thank you in advance : )

  7. Aaron

    Me again Got it to work.

    hat to add the host ip in both parts, the inital part which excludes everything and the sensor part. now it works.

  8. Arvo Paukkunen

    Struggling with the same issues – Are you still active with this? or related…
    my sensor is Victron Cerbo/Battere state of charge (last value) and HA simply does not show anything what looks like my sensor data…
    sensor:
    – platform: influxdb
    queries:
    – name: ‘Pylontech Li-Ion – SoC’
    field: ‘value’
    where: ‘time > now() – 5m’
    group_function: last
    database: homeassistant2
    measurement: ‘”homeassistant2″.”autogen”.”SOC”‘

    And in Influx side:
    SELECT last(“value”) AS “last_value” FROM “homeassistant2″.”autogen”.”SOC” WHERE time > :dashboardTime: AND time < :upperDashboardTime: GROUP BY time(:interval:) FILL(previous)

    • Tobey

      I suppose you can see the data in Chronograf or when querying InfluxDB? If not, please verify this works first. Secondly I only have suggestions, not sure if these things fix your issue. Try having a name of the device without blanks, like “Pylontech-SoC”. Also the field value has quotes on your part. I’m not sure if this may result in an issue, I did not use quotes here. Try updating the time to resemble a larger window, like 1h instead of 5m. Maybe even more than that if there’s some timezone issue.

Leave a Reply

Your email address will not be published. Required fields are marked *