Traits for entities

I think automation, scripts, and templates could be more flexible and useful if they could support/select entities based on their capability.

For example, there are several different entity types that have an ‘on’ and ‘off’ state. In an entity selector in yaml, it should be easy to select entities that have that trait, and treat them the same. Similarly for devices the have a ‘turn_on’ and ‘turn_off’ service. ,

When trying to combine the states of several objects, we can ask for the state ‘has_state.turn_on’ instead of ‘binary_sensor.turn_on’.

instead of ‘binary_sensor.turn_on’ service we call has_onoff_trait.turn_on.

The helpers that ship with home assistant should support these traits. The use of these should be in examples for helpers, blueprints, etc. The blueprint tutorial could use this to select the input.

First, the convention in HA is generally that the state of sensors are controlled by the integration that creates them, not user input… so your example of a nonexistent binary_sensor.turn_on action is moot.

But otherwise… you mean like homeassistant.turn_on? AFAIK, this action (and it’s turn_off variant) already work across all domains that support their own turn_on/off actions. It can be targetted at groups, mixed entities, areas, labels, or devices.