Akubra
April 26, 2025, 7:15am
1
How can I use ‘platform: integration’ in the new template structure?
My configuration.yaml has
template:
sensor: !include sensors.yaml
And the sensors I have in there all work.
Wanting to add an additional sensor, which in the ‘old’ notation looks like:
sensor:
platform: integration
source: sensor.sonoff_swv_flow
name: Water Consumption increasing
method: left
round: 2
However, if I add that to the sensors.yaml file I get “required key ‘state’ not provided Invalid config for ‘template’ at sensors.yaml”.
tom_l
April 26, 2025, 7:32am
2
Firstly: https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly-16
Secondly, the integral sensor platform goes under the sensor:
integration, not under the template:
integration (not even under template/sensor).
So here is where it goes:
# configuration.yaml
sensor:
- platform: integration
Not here:
# configuration.yaml
template:
- sensor:
- platform: integration
Please see the first line of the example in the documentation:
Additionally doing this will get very confusing:
Akubra:
template:
sensor: !include sensors.yaml
As almost all people use include for sensors.yaml here:
# configuration.yaml
sensor: !include sensors.yaml
Akubra
April 27, 2025, 10:06am
3
tom_l:
- platform: integration
Thanks @tom_l , done it using the ‘modern’ notation and that seems to work.
So configuration.yaml now has:
sensor: !include sensors.yaml
template: !include templates.yaml
The integration has been added to sensors.yaml under it’s own section:
-platform: integration
source: sensor.sonoff_swv_flow
name: Water Consumption increasing
method: left
round: 2
No errors in checking the config or restarting HA