Entity Controller Mega Thread (Motion Lighting Controller)

Thank you, I will check.

Thanks, Iā€™ll confirm that and update the GitHub issue I openedā€¦

Thereā€™s now a new accepted PR #191 to have this changed in const.py to on_enter_overridden and on_exit_overridden. Itā€™ll be a breaking change so Iā€™ll continue following my PR and will update this thread with the new version number that incorporates this change.

Hi

Just starting to see if entity controller will fit my use case, basically Iā€™ve got some fairly complex automations at the moment using a lot of templating in order to have a generic automation to cover 90% of my lighting needs. This takes in to account an input_select called ambience, where I have different ā€œmodesā€ like day lighting, night lighting, evening lighting, ambient lighting, etc.

Some of these ā€œmodesā€ control things like turn the lamp on instead of the light in a room when motion is detected, or donā€™t turn certain lights on at all in night mode, or keep lights on etc. I use a straight forward naming convention to achieve this, i.e. a main light is ā€œlight.[room]ā€ a lamp is ā€œlight.[room]_lampā€, a motion sensor is ā€œmotion.[room]ā€ and timers are ā€œtimer.[room]ā€

I then have room specific input_selects for overriding the lighting in particular rooms e.g. the lounge or my cinema room, so things like watching tv, normal, movie mode, reading, etc.

I can see you can put overrides in but I wondered how I can best incorporate the idea of having say 2 different input selects for a particular light controller and where there are perhaps 2 different lights (lamp and light) in a room, that you may want one to come on in certain modes, or the other in other modes.

I imagine I create an motion controller per light, but then do I have to make an override script for each individually that analyses the 2 input selects for that particular lamp or light and decides weather on not it should turn on?

Does anyone have any example of using a generic script as the override for multiple motion controllers?

The reason Iā€™m looking to move to entity controller over my current automation scripts is because there are certain features that I really like and donā€™t currently have, like the back-off and control over priority of an override or input.

Thanks in advance

Andy

Iā€™ve got all my lights setup with their own motion controller and most seem to be working ok, but I have 2 things Iā€™m struggling with:

First off, Iā€™m noticing on certain lights that even when I manually turn them off for example, they get turned back on when motion is detected. An example of a light suffering this is below, am I missing something?

Secondly Iā€™m trying to figure out how to override when a light can either be turned on or off based on maybe another property in home assistant or multiple things. I.e. So a light is turned on when motion is detected between sunset and 11pm. However if input_select.ambience == ā€˜Eveningā€™ and input_select.lounge_mode == ā€˜watchingtvā€™ donā€™t turn the light.

Or another example might be if motion is detected between sunset and 11pm turn the light. But then if I trigger my night routine at say 10pm which sets the input_select.ambience to ā€˜Nightā€™ then when motion is detected the light shouldnā€™t turn on even though itā€™s between the normal sunset to 11pm time condition.

This is the lounge light as an example:

lounge_lamp_controller:
  friendly_name: "Lounge Light Controller"
  sensor: binary_sensor.lounge_motion
  entity: light.lounge
  delay: 120
  backoff: true
  backoff_factor: 1.1
  backoff_max: 600
  start_time: 'sunset'
  end_time: '23:00:00'

Thanks in advance

Andy

Version 9.0.0 has been released and the spelling has been corrected:

CONF_ON_ENTER_OVERRIDDEN = 'on_enter_overridden'
CONF_ON_EXIT_OVERRIDDEN = 'on_exit_overridden'

Too many examples!
Seems like entity_controller might not be an answer for youā€¦,

Itā€™s not the be-all end-all solution but it works for my needs.

Believe it or notā€¦ Thereā€™s a whole home automation platform behind EC. Itā€™s definitely not going to cover all use cases. All itā€™s supposed to do is cover a set of commons use cases really well and then add some more with additional configuration.

Thereā€™s a reason automations, custom scripts, AppDeamon and the whole Python programming language exist :slight_smile:

EC is not plug and play and relies on some experimentation to get it to do what you want (for more complex use cases). Unfortunately, I donā€™t have time to respond and help people to set it up. Enough effort has gone into the documentation and implementation itself.

Maybe we could add a ā€œrecipeā€ style section to the docs with common use cases or usage ideas? The docs focus on motion lighting because itā€™s easy to understand, but they would benefit from some concise real world applications to demonstrate the versatility of the component and spark peopleā€™s imagination :rainbow:

Add your configs to this issue!!

1 Like

Hi

Iā€™ve got some inconsistent behavior with overridesā€¦ Both my lounge and snug have the same setup (literally exactly the same bar the names). Both have a light and a lamp and I use the idea of ā€œwatching TVā€ in the lounge and ā€œwatching movieā€ in the snug, either of which will result in the entity being overridden.

Here are my sensors I use for the overrides, these are both working as expected based on the states of my input_selects and the scenes.

# Snug light
- platform: template
  sensors:
    snug_light_constrained:
      value_template: >-
        {{ not (states('input_select.ambience') in ['Bright', 'Day', 'Evening'] and is_state('input_select.snug_mode', 'Normal') and is_state('light.snug_lamp', 'off')) }}

# Snug lamp
- platform: template
  sensors:
    snug_lamp_constrained:
      value_template: >-
        {{ not (states('input_select.ambience') in ['Ambient', 'Evening'] and is_state('input_select.snug_mode', 'Normal') and is_state('light.snug', 'off')) }}

Here are my entity controllers:

snug_light_controller:
  friendly_name: "Snug Light Controller"
  sensors: 
    - binary_sensor.snug_motion
  overrides:
    - binary_sensor.snug_light_constrained
  entities:
    - light.snug
  delay: 120
  backoff: true
  backoff_factor: 1.5
  backoff_max: 600
  block_timeout: 900

snug_lamp_controller:
  friendly_name: "Snug Lamp Controller"
  sensors: 
    - binary_sensor.snug_motion
  overrides:
    - binary_sensor.snug_lamp_constrained
  entities:
    - light.snug_lamp
  delay: 120
  backoff: true
  backoff_factor: 1.5
  start_time: 'sunset + 02:00:00'
  end_time: 'sunrise'
  backoff_max: 600
  block_timeout: 900

In the lounge with the same as the above but named lounge and watch_tv it works perfectly when the lounge_mode is ā€œwatch tvā€, both the light and lamp are constrained, and my scene turns the light on and lamp off.

In the snug with setup above, when the ā€œsnug_modeā€ is set to ā€œwatch movieā€ by the watch movie scene, both the sensors used for the overrides, detailed above, are correctly set to True. However the snug light doesnā€™t go from idle to blocked when motion is triggered, instead it turn the snug light on and the active_timer is triggered.

Here is a picture if the helps:

Could someone please post an example of using custom state strings? Canā€™t figure it out from the docs.

I want to be able to turn control elements on when sensor elements are off, and vice-versa.

Thanks

Iā€™m getting blocked state, but donā€™t know whyā€¦
So my light just stop working.

hodnik:
  sensor: 
    - binary_sensor.motion_sensor_158d0001d8e4b8
    - binary_sensor.door_window_sensor_158d0001e0354e
  sensor_type_duration: True
  sensor_resets_timer: True
  start_time: '06:10:00'
  end_time: '22:00:00'
  entity: switch.hodnik_relay
  delay: 15
  block_timeout: 600

Here is my logbook ss
blocked
IDK why is it going in blocked state?

Hi. I have a pretty simple problem that i couldnā€™t find an answer for.
I have some motion sensors that trigger my outside light 30 min before sundown till 30 min after sunrise. They should stay on for 15 minutes. This all works fine. Butā€¦
If the light goes on in the morning by being triggered by motion, and the sun triggers Entity Controller to go into ā€œconstrainedā€ mode before the 15 minute timer has a chance to turn off the light, the light will remain on till i manually turn it off. Its like the constrained mode overrides the timer. Thoughts on how i can fix this?
Heres my code.


entity_controller:
  driveway_motion_sensors:
    sensors: 
      - binary_sensor.driveway_motion
      - binary_sensor.tent_motion
      - binary_sensor.yard_motion
    entities: 
      - light.outside_front_light
    start_time: sunset - 00:30:00               # required
    end_time: sunrise + 00:30:00                # required
    delay: 900
    sensor_resets_timer: True

Driveway

Thank you.

Hi everyone.
First post here, so please be patient if I am missing something.
I have embraced EC since I started the transition to Home Assistant some months ago. I have several devices, and they are working very good. And after diving in to the documentation I managed to filter out some mistakes from my side also :slight_smile:.

However, I have one case that I dont manage to figure out. I have a EC device that keeps getting in to blocked state in night mode. Right after the sensor has sent started counting down I belive.

motion_light_attic:
    sensor:
      - binary_sensor.ms_motion_attic
      - binary_sensor.ms_motion_stairs
      - binary_sensor.attic_multisensor_2_contact
    entities:
      - light.loftstue_gang
    delay: 300
    sensor_type: duration
    sensor_resets_timer: True
    block_timeout: 3600
    service_data:
      brightness_pct: 80
      kelvin: 2700
    night_mode:
      delay: 60
      service_data:
        brightness_pct: 10
        color_name: red
      start_time: "22:00:00" # required
      end_time: "06:00:00" # required

I dont see why this should not work, anyone who does?

Do you have transitions on your light? If they take time to dim the ilght or change colour EC can see that as a state change and block itself.

I donā€™t have any transition. That was my idea at one time also.
But as you can see from the config above there is only service data for colour and brightness.

Meybe related to my problem. I too have an entity that goes in blocked state, but only a simple config for itā€¦

The light itself might have a transition or some kind of delay. EC goes into blocked if the light updates its own state shortly after EC controls it. Once you identify this is whats happening there are configs to work around that. (this happens when theres network latency as well).

That could be in my case. What would be a workaround?

How would you recommend to identify that that is the cause?
Interestingly, I only have the issue in night mode.