State Entities
It is possible to separate control entities and state entities.
Control entities are the entities that are being turned on and off by EC.
State entities, on the other hand, are used to observe state.
In a basic configuration, your control entities are the same as your state entities (handled internally for ease of use).
The notion of separate state entities
allows you to keep the entity that is being controlled separate from the one that is being observed. The following examples should illustrate the use cases for state entities.
Example 1
One example is my porch light shown below:
mtn_porch:
sensors:
- sensor.cam_front_motion_detected
entities:
- light.porch_light
- script.buzz_doorbell
The control entities contains a mix of entities from different domains. The state of the script entitity is non-sensical and causes issues. The controller enters active state, turns on control entities and then immediately leaves active state (going back to idle). This is because the state of the script is interpreted after turn on.
In this case, you need to tell the controller exactly which entitty to observe for state.
mtn_porch:
sensors:
- binary_sensor.front_motion_detected
entities:
- light.porch_light
- script.buzz_doorbell
state_entities:
- light.porch_light
Example 2
The configuration below will trigger based on the supplied sensors, the entities defined in entities
will turn on if and only if all state_entities
states are false
. The control
entity is a scene
which does not provide useful state information as it is in scening
state at all times.
In general, you can use the config key entities
and state_entities
to specify these. For example,
mtn_lounge:
sensors:
- binary_sensor.cooking
entities:
- scene.cooking
state_entities:
- light.kitchen_led_strip
delay: 300
Note: Using state entities can have unexpected consequences. For example, if you state entities do not overlap with control entities then your control entities will never turn off. This is the culprit of advanced configurations, use at your own risk. If you have problems, make your state entities the same as your control entities, and stick to state entities with a clear state (such as lights, media players etc.)