Need help - [availability] is an invalid option for [sensor.template]

I’m attemptingto define the availability criteria for a sensor.

according to the doc, I should be able to specify a template within the availability parameter of my template sensor.

(Template - Home Assistant)

availability template (optional, default: true)

Defines a template to get the available state of the component. If the template returns true, the device is available. If the template returns any other value, the device will be unavailable. If not configured, the component will always be available.

However when I create my sensor as below:

- platform: template
  sensors:
    bedroom_humidity:
     value_template: "{{ states('sensor.bedroom_humidity_raw') | float - 10 }}"
     availability: "{{ states('sensor.bedroom_temperature') != 'unavailable' }}"
     unit_of_measurement: "%"
     device_class: humidity
     friendly_name: "Bed room humidity"

I get an error when validating the config:

Invalid config for [sensor.template]: [availability] is an invalid option for [sensor.template]. Check: sensor.template->sensors->bedroom_humidity->availability. (See ?, line ?).

Any help is much appreciated.

(I’m running latest version of HA: 2021.8.8)

You are using the legacy template sensor format. That uses availability_template: not availability:.

2 Likes

Greatly appreciated.
Could you point me to the new template sensor format so I can properly align ?

1 Like

Thanks. Changes are subtle…

I have to say that I preferred the legacy, as I was able to put all sensors together into a sensor.yaml file and include it as part of my configuration.yaml…

Now all types of different entities will need to be combined into my templates.yaml file…

1 Like

There are some ideas following on from this post: Splitting config for template: - #9 by tom_l (most of them bad ideas unfortunately).