Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override entity prevents switching off #293

Open
hcrohland opened this issue Dec 5, 2022 · 7 comments
Open

Override entity prevents switching off #293

hcrohland opened this issue Dec 5, 2022 · 7 comments

Comments

@hcrohland
Copy link

Description

I have a a threshold sensor which triggers when illumination is higher than a certain level as an override for a motion sensor triggered EC.

The documentation says: "You can define entities which stop EC from transitioning into active state if those entities are in on state". But the override is also used in active state.

Since the threshold is lower than the illumination created by the controlled light, the light never switches off.

The EC goes into the following state:

sensor_type: duration
delay: 180s
last_triggered_by: binary_sensor.lumi_lumi_sensor_motion_aq2_18cbe307_ias_zone
last_triggered_at: 2022-12-05 10:47:32.718405
icon: mdi:timer-off-outline
friendly_name: eingang
expires_at: 2022-12-05T10:50:32.718532
service_data: 
entity_id: light.iluminize_5120_1200_249828fe_on_off

sensor_turned_off_at: 2022-12-05T10:48:42.719310
overridden_by: binary_sensor.helligkeit_eingang
overridden_at: 2022-12-05 10:50:22.500030

Configuration

entity_controller:
  eingang:
    sensor: binary_sensor.lumi_lumi_sensor_motion_aq2_18cbe307_ias_zone
    sensor_type: duration
    entity: light.iluminize_5120_1200_249828fe_on_off
    overrides:
      - binary_sensor.helligkeit_eingang

Steps to reproduce

Steps to reproduce the behavior:

  1. Trigger motion with the treshold low enough

Expected behavior

This is how the component should work:

  1. Trigger motion
  2. EC switches light on
  3. Override triggers, but EC continues since it is already active....
  4. EC continues and switches light off after timeout

Actual Behaviour

This is what actually happened:

  1. Trigger motion
  2. EC switches light on
  3. Override triggers
  4. EC goes into override mode

Version

HA 2022.11.5
EC 9.6.0

@danobot
Copy link
Owner

danobot commented Dec 31, 2022

This sounds like expected behaviour. When it goes in override it should stop whatever it's doing because something is overriding the controller.

@alh84001
Copy link

alh84001 commented Apr 9, 2023

I would disagree - if entity controller is active, it's too late to override it - so it should do its thing until its done. In my mind override is used for transition to active state, not for overriding the controller in its functionality.

Well, at least it should be configurable, and I'll make a PR soon-ish to provide a flag (or a list of states in which to consult override) for this.

BTW, I have the exact scenario that OP posted:

  • I want lights to turn on when I pass into/through a room
  • BUT, I don't want that to happen if there is enough light already present in the room
  • Now, if I pass through the same area again, and motion sensor is triggered, I don't want its luminance update to affect the control, since that exact control is providing the luminance, and it is explicitly delayed for a certain amount of time

@hcrohland
Copy link
Author

Yes, the current behaviour prevents the entity controller to be usable for motion sensors with illuminance control. The light changes the illuminance and that leads to the lights staying on indefinitely

@alh84001
Copy link

alh84001 commented Apr 9, 2023

However, thinking about it more, we already do have a way to set up behaviour for transition to active - it is the sensor property. It's just a matter of making a composite binary sensor of motion and luminance (threshold).

I have a feeling that even if we could change override behaviour, it still would be a bad experience, since you would have old bright luminance value cached, and I suspect there could be some weird timing interplay here between when luminance gets updated on next trigger and when motion gets updated.

In any case, I'll actually drop the override config, and play with configuring trigger sensor more.

@alh84001
Copy link

alh84001 commented Apr 9, 2023

- trigger:
    - platform: state
      entity_id: binary_sensor.a_motion_sensor
      for:
        milliseconds: 100
  binary_sensor:
    - name: "Motion Light Trigger"
      unique_id: "a_motion_light_trigger"
      state: >
        {% set is_on = is_state('binary_sensor.a_motion_light_trigger', 'on') %}       
        {% set is_ec_active = is_state('entity_controller.a_motion_light', 'active_timer') %}
        {% set is_not_over_luminance_threshold = not is_state('binary_sensor.an_illuminance_upper_threshold_sensor', 'on') %}
        {% set is_motion_detected = is_state('binary_sensor.a_motion_sensor') %}
        
        # ignore luminance sensor if trigger itself is already on,
        # or if entity controller that is triggered is already active
        {% if is_on or is_ec_active %}
        {{ is_motion_detected }}
        {% else %}
        {{ is_motion_detected and is_not_over_luminance_threshold }}
        {% endif %}

Above is the template trigger that I ended up with, and it seems to be covering the stated use-case well. It's by no means fully tested, but that will come with time.

@pomeloy
Copy link

pomeloy commented Jul 7, 2023

I am also struggling with this type of scenario.
@alh84001 thank you for your input. Could you explain where EC actually comes into play again? Do you use another automation to turn the lights on now?

@alh84001
Copy link

alh84001 commented Jul 13, 2023

EC configuration is then simple, with the trigger defined as above

entity_controller:
    a_motion_light:
      sensor: binary_sensor.a_motion_light_trigger
      entity: light.some_light_to_control
      sensor_type: duration
      sensor_resets_timer: true

Note that a_motion_light is checked in the binary sensor defined above, and that that sensor (a_motion_light_trigger) is used here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants