danobot / entity-controller

Home Assistant Entity and lighting controller for managing devices with timers, scripts, and sun-based time restrictions.
https://danobot.github.io/ec-docs/
GNU General Public License v3.0
289 stars 41 forks source link

Lights turning off during restart #323

Closed chupacabra71 closed 3 months ago

chupacabra71 commented 4 months ago

Description

Whenever there is an HA restart, lights controlled by EC turn off. it seems to happen on a transition to idle even though i don't have a behavior set up for on_enter_idle. It is most likely a configuration issue on my side, but thought i'd check here.

Configuration

entity_controller_motion_kitchen:
  friendly_name: "Kitchen Motion Controller"
  sensor: 
    - binary_sensor.kitchen_motion_any
  entity: 
    - light.kitchen_lights
  overrides:
    - input_boolean.entity_controller_motion_kitchen_override
  sensor_type: duration
  sensor_resets_timer: True
  delay: 600
#  end_time_action: "off"
  backoff: true
  backoff_factor: 1.2
  backoff_max: 1800
  service_data:
    brightness_pct: 100
  start_time: sunset
  end_time: '21:59:59'
  night_mode:
    delay: 120
    backoff_factor: 1.2
    backoff_max: 1800
    service_data:
      brightness_pct: 20
    start_time: '22:00:00'
    end_time: sunrise
    end_time_action: "off"

Steps to reproduce

Steps to reproduce the behavior:

  1. turn on lights (either manually or automatically through EC)
  2. restart HA
  3. as HA is coming up, Lights turn off

Expected behavior

This is how the component should work:

  1. Expected lights to stay on during reboot.

Logs

2024-02-24 09:38:55.480 INFO (SyncWorker_28) [transitions.core] Finished processing state pending exit callbacks.
2024-02-24 09:38:55.480 DEBUG (SyncWorker_28) [custom_components.entity_controller.entity_controller_motion_kitchen] Entering idle
2024-02-24 09:38:55.480 DEBUG (SyncWorker_28) [custom_components.entity_controller.entity_controller_motion_kitchen] set_context :: name_hash: f58b76
2024-02-24 09:38:55.480 DEBUG (SyncWorker_28) [custom_components.entity_controller.entity_controller_motion_kitchen] set_context :: context_id: ec_f58b76_0ca4b67cbf10a8ea
2024-02-24 09:38:55.480 DEBUG (SyncWorker_28) [custom_components.entity_controller.entity_controller_motion_kitchen] on_enter_idle | Performing Transition Behaviour
2024-02-24 09:38:55.480 DEBUG (SyncWorker_28) [custom_components.entity_controller.entity_controller_motion_kitchen] on_enter_idle | Action - off
2024-02-24 09:38:55.480 DEBUG (SyncWorker_28) [custom_components.entity_controller.entity_controller_motion_kitchen] on_enter_idle | Performing Action - Turning off
2024-02-24 09:38:55.480 DEBUG (SyncWorker_28) [custom_components.entity_controller.entity_controller_motion_kitchen] turn_off_control_entities :: Turning off light.kitchen_lights
2024-02-24 09:38:55.480 DEBUG (SyncWorker_28) [custom_components.entity_controller.entity_controller_motion_kitchen] call_service :: Calling service turn_off on light.kitchen_lights
2024-02-24 09:38:55.480 DEBUG (SyncWorker_28) [custom_components.entity_controller] Resetting state
2024-02-24 09:38:55.480 INFO (SyncWorker_28) [transitions.core] Executed callback 'on_enter_idle'
2024-02-24 09:38:55.480 INFO (SyncWorker_28) [transitions.core] Finished processing state idle enter callbacks.
2024-02-24 09:38:55.480 INFO (SyncWorker_28) [transitions.core] Executed callback 'finalize'
2024-02-24 09:38:55.678 DEBUG (MainThread) [custom_components.entity_controller.entity_controller_motion_kitchen] state_entity_state_change :: [ Entity: light.kitchen_lights, Context: <homeassistant.core.Context object at 0x7f309bc72870> ]
Old state: <state light.kitchen_lights=on; supported_color_modes=[<ColorMode.BRIGHTNESS: 'brightness'>], color_mode=brightness, brightness=255, friendly_name=Kitchen Lights , supported_features=32 @ 2024-02-24T09:37:47.161102-05:00>
New State: <state light.kitchen_lights=off; supported_color_modes=[<ColorMode.BRIGHTNESS: 'brightness'>], color_mode=None, brightness=None, friendly_name=Kitchen Lights , supported_features=32 @ 2024-02-24T09:38:55.671871-05:00>
2024-02-24 09:38:55.678 DEBUG (MainThread) [custom_components.entity_controller.entity_controller_motion_kitchen] state_entity_state_change :: Ignoring this state change because it came from ec_f58b76_0ca4b67cbf10a8ea

Version

9.7.2
hvorragend commented 4 months ago

Same here

chupacabra71 commented 4 months ago

as a test i did add the on_enter_idle to the config set to ignore and it seems to fix the issue. i am still doing some testing, so will report back when certain. the config now looks like this:

entity_controller_motion_kitchen:
  friendly_name: "Kitchen Motion Controller"
  sensor: 
    - binary_sensor.kitchen_motion_any
  entity: 
    - light.kitchen_lights
  overrides:
    - input_boolean.entity_controller_motion_kitchen_override
  sensor_type: duration
  sensor_resets_timer: True
  delay: 600
  backoff: true
  backoff_factor: 1.2
  backoff_max: 1800
  service_data:
    brightness_pct: 100
  start_time: sunset
  end_time: sunrise
  behaviours:
    on_enter_idle: "ignore"
  night_mode:
    delay: 120
    backoff_factor: 1.2
    backoff_max: 1800
    service_data:
      brightness_pct: 20
    start_time: '22:00:00'
    end_time: sunrise
    behaviours:
      on_enter_idle: "ignore"
chupacabra71 commented 4 months ago

as a test i did add the on_enter_idle to the config set to ignore and it seems to fix the issue.

After a few days of testing, this seems to fix the issue of lights turning off on reboots. It appears that the on_enter_idle behavior does not honor what the documentations states as it's default setting of ignore. Manually setting it seems to do the trick.