我需要帮助将 InfluxDB 查询转换为 Homeassistant 可以读取的 YAML 格式。
Influx 数据库托管在外部服务器上,并通过 Grafana 无缝集成到仪表板中,如下所示:
SELECT mean("temperature_C") FROM "LaCrosse-TX141THBv2" WHERE $timeFilter GROUP BY time($__interval) fill(null)
---------- 现在 Homeassistant 还应将此值用作输入传感器值。我创建了以下 YAML:
sensor:
- platform: influxdb
host: network-pi
username: config
port: 8086
password: !secret influx_password
queries:
- name: badtemperatur
group_function: last
where: '"name" = ''LaCrosse-TX141THBv2'''
#measurement: '"LaCrosse-TX141THBv2"'
field: temperature_C
database: monitoring
---------- 但是,我在 Homeassistant 的“开发人员工具/检查配置”下收到此错误消息:
Invalid config for [sensor.influxdb]: required key not provided @ data['queries'][0]['measurement']. Got None. (See ?, line ?).
在 Hass 文档中,有一个 Influx 值作为传感器的模板:
sensor:
- platform: influxdb
host: localhost
username: home-assistant
password: password
queries:
- name: last value of foo
unit_of_measurement: °C
value_template: '{{ value | round(1) }}'
group_function: last
where: '"name" = ''foo'''
measurement: '"°C"'
field: value
database: db1
- name: Min for last hour
unit_of_measurement: "%"
value_template: '{{ value | round(1) }}'
group_function: min
where: '"entity_id" = ''salon'' and time > now() - 1h'
measurement: '"%"'
field: tmp
database: db2
然而,对于我来说,下面这行代码是什么却是一个谜:这不可能指的是时间,是吗?
非常感谢所有帮助我的人!