Can both the group and the template me named the same thing?
Log Details (ERROR)
Wed Sep 04 2019 17:18:01 GMT-0500 (Central Daylight Time)
Invalid config for [sensor.template]: value is not allowed for dictionary value @ data['sensors']['window_status']['device_class']. Got 'window'. (See ?, line ?). Please check the docs at https://home-assistant.io/components/sensor.template/
Log Details (ERROR)
Wed Sep 04 2019 16:45:22 GMT-0500 (Central Daylight Time)
Invalid config for [sensor.template]: value is not allowed for dictionary value @ data['sensors']['window_status']['device_class']. Got 'window'. (See ?, line ?). Please check the docs at https://home-assistant.io/components/sensor.template/
Log Details (ERROR)
Wed Sep 04 2019 16:32:04 GMT-0500 (Central Daylight Time)
Invalid config for [sensor.template]: [window_status] is an invalid option for [sensor.template]. Check: sensor.template->window_status. (See ?, line ?). Please check the docs at https://home-assistant.io/components/sensor.template/
Connection lost. Reconnecting…
It’s getting hard to follow this thread; I was referring to this post by Literoya where the group is defined as Contact Sensors: and then is referred to by its name.
Also, check out the latest reported errors. There should be no complaint about the device_class yet there it is. Roya is doing something out of the ordinary to get that error message.
So @Holdestmade pointed out that I had a typo when referring to my group. I used window and windows. I changed it to be the same group name of windows.
The other fix was changing the sensor to binary_sensor and splitting it out.
The typo clearly needed to be fixed but changing from Template Sensor to Template Binary Sensor shouldn’t make any difference with regards to the error messages. Petro provided a valid configuration for a Template Sensor and I use a similar one without the error message(s) you had.
I have a feeling the next time you attempt to define a Template Sensor, this problem will re-appear.
Can’t argue with that … but changing it to a Template Binary Sensor doesn’t explain why it originally failed when it was defined as a Template Sensor.
I carried out an experiment and was able to replicate the error message Literoya received. The answer is actually quite simple. Although both Template Sensor and Template Binary Sensor support the device_class option, they don’t share the same types of device_class.
The available types for a sensor are listed here:
What you won’t find in that list is window. That’s a type of device_class only valid for binary_sensors.
That’s why switching from Template Sensor to Template Binary Sensor eliminated the error message. A window device_class is valid for binary_sensors, not sensors.
I offer you yet another way to achieve the same thing.
In this version, you specify the binary_sensors you wish to monitor (windows) within the value_template. You don’t need a group and you don’t need to list the binary_sensors in entity_id.
So i am trying to do as much as i can looking at what others are doing since i am a newbie. However what am i doing wrong i have what he has but i am getting an error. in my groups file this is everything i have at this point. Please, what am i missing?
Error
Error loading /config/configuration.yaml: expected '<document start>', but found '<block sequence start>'
in "/config/groups.yaml", line 2, column 3
binary_sensor:
- platform: template
sensors:
window_status:
friendly_name: "Window Status"
entity_id:
-binary_sensor.basement_slider_door
-binary_sensor.front_door_window_sensor
-binary_sensor.Landon_window_sensor
-binary_sensor.girls_bedroom_window_sensor
-binary_sensor.Middle_slider_door_sensor
-binary_sensor.Master_bedroom_window_sensor
-binary_sensor.hall_window_sensor
-binary_sensor.dinning_room_window_sensor
-binary_sensor.Basement_window_sensor
-binary_sensor.Entry_Door
device_class: windows
value_template: "{{ expand('group.windows') | selectattr('state','eq','on') | list | count > 0 }}"
How can the status of all those sensors be grouped in a way the individual sensors don’t need to be in the config, but instead the template includes all binary_sensors automatically? This would be based on this automation, but than inside a template. I can’t get my head around this how to do this.
EDIT: I mean something like this, which doesn’t seem to be working, as it reads unavailable, while all my sensors are online.