Template error: [delay_off] is an invalid option for [sensor.template]

Hi, I am trying to create a sensor template but when it loads, I have an error.
Here is my template:

- platform: template
  sensors:
    motion_delay_corridor:
      friendly_name: "Corridor Lighting motion delay"
      delay_off:
        seconds: 15
      value_template: >-
        {{ is_state('binary_sensor.presence_2', 'on) }}

And here is the error I get:

Invalid config for [sensor.template]: [delay_off] is an invalid option for [sensor.template]. Check: sensor.template->sensors->motion_delay_corridor->delay_off. (See ?, line ?). Please check the docs at https://home-assistant.io/integrations/template/

I even tried to copy/paste the template from the integration page and get the same error :confused: I tried to write the whole think by hand in case it was a special character when I copy/paste but nothing works.

I am using Hass.io 193 with HassOS 3.7

1 Like

My bad, I was putting the code in the sensors.yaml but it is a binary_sensor, not a regular sensor.
It works if I put it in my configuration.yaml :slight_smile:

3 Likes

Please could you clarify?
I can’t declare a sensor in configuration.yaml since Hass says there is a double mapping because of “sensor: !include sensor.yaml”. Have you put all of your sensor entries back in configuration.yaml??
Thanks

He defined a binary_sensor, not a sensor. Probably he has sensor: !include sensor.yaml, but not
binary_sensor: !include binary_sensor.yaml

So, in other words: a template sensor (https://www.home-assistant.io/integrations/template/) can’t have a delay. But a binary sensor (https://www.home-assistant.io/integrations/binary_sensor/) can.

I was trying to find our a way to delay a template sensor; this seems more logical for CPU use I think. But i’ll need to delay may automation then. :slight_smile: