Hi
What do you mean? Samples for template sensors or a sample for the influxdb configuration in configuration.yaml? A sample for a binary sensor is in one of the posts above, similar for a temperature sensor:
bme680_temperature_db:
value_template: "{{ states('sensor.bme680_temperature') }}"
friendly_name: "Sensor BME680"
unique_id: bme680_temperature_db
device_class: temperature
attribute_templates:
update_now: "{{ (now().minute / 5) | round(0) }}"
takes the existing entity “sensor.bme680_temperature” and creates an addtional sensor with name “sensor.bme680_temperature_db” including the additional attribute to change the sensor every 5 minutes. This triggers the influxdb integration to write a value to the database.
this is the configuration for influx:
influxdb:
host: 127.0.0.1
port: 8086
database: homeassistant
username: influxuser
password: influxpassword
ssl: false
verify_ssl: false
max_retries: 3
default_measurement: state
include:
entity_globs:
- binary_sensor.*_db
- sensor.*_db
- sensor.*_db_2
component_config_glob:
sensor.*humidity*:
override_measurement: humidity
sensor.*temperature*:
override_measurement: temperature
sensor.*valve*:
override_measurement: valve
tags:
instance: prod
source: hass
the “include” defines the entities to be stored to influxdb. I’m storing my template sensors ( all ending with “_db” or “_db_2”) only, all other entities are not transferred to influxdb.
the “component_config_glob” is a workaround for a feature in the influxdb-integration I didn’t really like. By default it was creating measurements where the unit of the entity was the name of the measurement (for example “°C” for temperature entities). I didn’t like that, here I’m setting for example “temperature” as the name ( based on the name of the entity)
Finally I have this “recorder” configuration in configuration.yaml
recorder:
exclude:
entity_globs:
- binary_sensor.*_db
- sensor.*_db
- sensor.*_db_2
This excludes the entities I’m writing to influxdb from being written to the standard homeassistant database
Armin