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
299 stars 40 forks source link

Broken since Hass 2023.12 beta #316

Closed Paul-Vdp closed 10 months ago

Paul-Vdp commented 11 months ago

Description

Ever since I installed a Hass 2023.12 beta version, EC stopped working. It complains about non-existing states (they DO exist), and about 'not enough values to unpack (expected 2, got 1)' upon override state changes - and ends up doing nothing.

Configuration

mtn_living:
  friendly_name: Motion Living
  sensor: binary_sensor.motion_living_occupancy
  sensor_type: duration
  entity: light.living_wandlichten
#  block_timeout: 1
  service_data:
    brightness_pct: 50
  night_mode:
    start_time: '00:00:00'
    end_time: sunrise
    service_data:
      brightness_pct: 1
  override_states_off: ["off", "unavailable"]
  overrides:
    - binary_sensor.day
    - light.living_luster
    - media_player.tv_living

Steps to reproduce

Steps to reproduce the behavior:

  1. Nothing special - just install a 2023.12 beta

Expected behavior

This is how the component should work:

  1. Control the entities and act on state changes (what else ?)

Actual Behaviour

This is what actually happened:

  1. Does nothing, just generates nonsensical errors

Logs

This error originated from a custom integration.

Logger: custom_components.entity_controller.mtn_living
Source: custom_components/entity_controller/__init__.py:800
Integration: Entity Controller (documentation)
First occurred: 17:15:22 (3 occurrences)
Last logged: 17:26:12

Potential configuration error: State Entity (l) does not exist (yet). Please check for spelling and typos. 'NoneType' object has no attribute 'state'

AND

Logger: homeassistant.helpers.event
Source: helpers/event.py:296
First occurred: 17:15:22 (5 occurrences)
Last logged: 17:26:12

Error while dispatching event for binary_sensor.day to <Job track state_changed event ['binary_sensor.day', 'light.living_luster', 'media_player.tv_living'] HassJobType.Callback <function async_track_state_change.<locals>.state_change_listener at 0x7f381a8516c0>>
Error while dispatching event for binary_sensor.day to <Job track state_changed event ['binary_sensor.day', 'light.keuken_lichten'] HassJobType.Callback <function async_track_state_change.<locals>.state_change_listener at 0x7f381a851e40>>
Error while dispatching event for binary_sensor.day to <Job track state_changed event ['binary_sensor.day', 'media_player.tv_eetkamer'] HassJobType.Callback <function async_track_state_change.<locals>.state_change_listener at 0x7f381a852480>>
Error while dispatching event for light.living_luster to <Job track state_changed event ['binary_sensor.day', 'light.living_luster', 'media_player.tv_living'] HassJobType.Callback <function async_track_state_change.<locals>.state_change_listener at 0x7f381a8516c0>>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 296, in _async_dispatch_entity_id_event
    hass.async_run_hass_job(job, event)
  File "/usr/src/homeassistant/homeassistant/core.py", line 671, in async_run_hass_job
    hassjob.target(*args)
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 240, in state_change_listener
    state_change_dispatcher(event)
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 227, in state_change_dispatcher
    hass.async_run_hass_job(
  File "/usr/src/homeassistant/homeassistant/core.py", line 671, in async_run_hass_job
    hassjob.target(*args)
  File "/config/custom_components/entity_controller/__init__.py", line 631, in override_state_change
    self.enable()
  File "/usr/local/lib/python3.11/site-packages/transitions/extensions/nesting.py", line 816, in trigger_event
    res = self._trigger_event(_model, _trigger, None, *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/transitions/extensions/nesting.py", line 1016, in _trigger_event
    tmp = self.events[_trigger].trigger(_model, self, *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/transitions/extensions/nesting.py", line 112, in trigger
    return _machine._process(func)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/transitions/core.py", line 1172, in _process
    return trigger()
           ^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/transitions/extensions/nesting.py", line 127, in _trigger
    res = self._process(event_data)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/transitions/extensions/nesting.py", line 143, in _process
    if trans.execute(event_data):
       ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/transitions/core.py", line 272, in execute
    self._change_state(event_data)
  File "/usr/local/lib/python3.11/site-packages/transitions/extensions/nesting.py", line 276, in _change_state
    func()
  File "/usr/local/lib/python3.11/site-packages/transitions/extensions/nesting.py", line 205, in scoped_enter
    self.enter(event_data)
  File "/usr/local/lib/python3.11/site-packages/transitions/core.py", line 124, in enter
    event_data.machine.callbacks(self.on_enter, event_data)
  File "/usr/local/lib/python3.11/site-packages/transitions/core.py", line 1107, in callbacks
    self.callback(func, event_data)
  File "/usr/local/lib/python3.11/site-packages/transitions/core.py", line 1128, in callback
    func(*event_data.args, **event_data.kwargs)
  File "/config/custom_components/entity_controller/__init__.py", line 855, in on_enter_idle
    self.do_transition_behaviour(CONF_ON_ENTER_IDLE)
  File "/config/custom_components/entity_controller/__init__.py", line 1751, in do_transition_behaviour
    self.turn_off_control_entities()
  File "/config/custom_components/entity_controller/__init__.py", line 1302, in turn_off_control_entities
    self.call_service(e, "turn_off")
  File "/config/custom_components/entity_controller/__init__.py", line 1537, in call_service
    domain, e = entity.split(".")
    ^^^^^^^^^
ValueError: not enough values to unpack (expected 2, got 1)

Version

Hass 2023.12.0b5
EC v9.6.1
ajguerre1 commented 11 months ago

Same issue here for official 2023.12. Please help fixing this! Thanks!

sebfar9172 commented 11 months ago

I confirm, i'm going back to 2023.11.3 version

Pabsilon commented 11 months ago

I had issues in 2023.12, rolling back to 2023.11.3 solved them.

One of my entity controllers would stay stuck forever in an 'active' state - I coulnd't figure out why. Others would work fine. Here's the config of the one messing around:

# Motion Activated Stair Lights
stairs_motion_light:
 # Sensor Config
  sensor:
    - binary_sensor.stairs_occupancy
  sensor_type: duration
  delay: 1
  block_timeout: 360

  # Observable Entity
  entity: light.stairs_led
  state_attributes_ignore:
    - brightness
    - color_temp

  # Extra Actions
  trigger_on_activate: script.toggle_the_stairs
  trigger_on_deactivate: script.turn_off_stairs_smoothly

I'm using scripts because depending on external sensorsI like my lights to behave one way or another

jeeftor commented 11 months ago

I dont know if its related I found an issue in one my blueprints where json wasn't being handled correctly post update - any chance this is related?

HemiBob commented 11 months ago

Yes, same here. I have quite a few rooms using EC, some still work perfectly but others just don't turn the lights on even though the controlling motion detectors show motion. Very strange, this is day two so I guess I'll roll back a version and see.

Yes, returned to 11.3 and working again.

m90att commented 11 months ago

Same here

egelinotte commented 11 months ago

Same issue. EC stopped working. This is painful, I relied a lot of this good component. I am not so sure that this component is still maintained.

Paul-Vdp commented 11 months ago

@danobot Hi Daniel, Any chance of a solution (soon ...), or must we all say goodbye to our beloved EC, and frantically start searching for an alternative ? Hoping for the best, but preparing for the worst ?

jeeftor commented 11 months ago

There is always a chance for a solution ... just depends how long you want to wait ... I dont really think .12 added much over .11

12.1 fixed an issue I had with one of my blueprints so keep your fingers crossed

m90att commented 11 months ago

Strangely, one of my three entity controllers is still working ok! The other two are not.

On Sun, 10 Dec 2023, 12:16 Jeef, @.***> wrote:

There is always a chance for a solution ... just depends how long you want to wait ... I dont really think .12 added much over .11

12.1 fixed an issue I had with one of my blueprints so keep your fingers crossed

— Reply to this email directly, view it on GitHub https://github.com/danobot/entity-controller/issues/316#issuecomment-1848948254, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANP4WKL65QZG6M7UBI2TDETYIWRZDAVCNFSM6AAAAABAJU3KHKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBYHE2DQMRVGQ . You are receiving this because you commented.Message ID: @.***>

jddayley commented 11 months ago

To fix the issue, I updated the configuration.yaml file by using a list format for specifying sensors and entities. Instead of directly assigning a single sensor or entity. See example below: sensor:

VS (Doesn't Work): sensor: binary_sensor.storage_motion entity: switch.storage

m90att commented 11 months ago

Thank you! That worked for me and it showed why one of my three controllers wasn't affected.

On Sun, 10 Dec 2023, 19:21 jddayley, @.***> wrote:

To fix the issue, I updated the configuration.yaml file by using a list format for specifying sensors and entities. Instead of directly assigning a single sensor or entity, I listed them under their respective types: sensor:

  • binary_sensor.storage_motion entity:
  • switch.storage

VS: sensor: binary_sensor.storage_motion entity: switch.storage

— Reply to this email directly, view it on GitHub https://github.com/danobot/entity-controller/issues/316#issuecomment-1849057077, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANP4WKNPYNRF25JF6F7AMR3YIYDUBAVCNFSM6AAAAABAJU3KHKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBZGA2TOMBXG4 . You are receiving this because you commented.Message ID: @.***>

dan-s-github commented 11 months ago

@jddayley thank you very much for figuring this out, updated all my configs to use list style and updated core to 2023.12.1 everything works as expected.

wondering if this actually a bug or a feature?

Pabsilon commented 11 months ago

@jddayley I did some quick tests and it does indeed seem to solve it. I'll do further testing this afternoon.

If I remember correctly, they recently introduced config processing and error handling to the HA Core - this might've had a side effect on EC...

egelinotte commented 11 months ago

What about the other features ? I have now the following setting:

automation_motion_garage: sensor: binary_sensor.groupe_capteurs_mvt_garage entity: light.lumiere_garage_switch
delay: 60
sensor_type: duration

sensor_resets_timer: True

block_timeout: 30

What should be the way to write the whole paragraph ?

Pabsilon commented 11 months ago

automation_motion_garage: sensor: binary_sensor.groupe_capteurs_mvt_garage entity: light.lumiere_garage_switch delay: 60 sensor_type: duration

sensor_resets_timer: True

block_timeout: 30

Sensor and entities as lists, so:

automation_motion_garage:
sensor: 
  - binary_sensor.groupe_capteurs_mvt_garage
entity: 
  - light.lumiere_garage_switch
delay: 60
sensor_type: duration
# sensor_resets_timer: True
block_timeout: 30
littlease commented 11 months ago

To fix the issue, I updated the configuration.yaml file by using a list format for specifying sensors and entities. Instead of directly assigning a single sensor or entity. See example below: sensor: - binary_sensor.storage_motion entity: - switch.storage

VS (Doesn't Work): sensor: binary_sensor.storage_motion entity: switch.storage

Confirmed as a workaround. Many thanks!

Something broked at config processing, entities became list of characters instead of strings.

Here debug entry from 2023.12:

2023-12-11 11:53:25.789 DEBUG (MainThread) [custom_components.entity_controller.bathroom_motion_light] Sensor Entities         ['b', 'i', 'n', 'a', 'r', 'y', '_', 's', 'e', 'n', 's', 'o', 'r', '.', 'm', 'o', 't', 'i', 'o', 'n', '_', 'd', 'e', 't', 'e', 'c', 't', 'o', 'r', '_', 'z', 'h', 'a', '_', 'i', 'a', 's', 'z', 'o', 'n', 'e']
2023-12-11 11:53:25.789 DEBUG (MainThread) [custom_components.entity_controller.bathroom_motion_light] Control Entities:       ['l', 'i', 'g', 'h', 't', '.', 'b', 'a', 't', 'h', 'r', 'o', 'o', 'm', '_', 'l', 'i', 'g', 'h', 't', 's']
2023-12-11 11:53:25.789 DEBUG (MainThread) [custom_components.entity_controller.bathroom_motion_light] State Entities:         ['l', 'i', 'g', 'h', 't', '.', 'b', 'a', 't', 'h', 'r', 'o', 'o', 'm', '_', 'l', 'i', 'g', 'h', 't', 's']

and from 2023.10

2023-12-11 14:47:24.133 DEBUG (MainThread) [custom_components.entity_controller.bathroom_motion_light] Sensor Entities         ['binary_sensor.motion_detector_zha_iaszone']
2023-12-11 14:47:24.133 DEBUG (MainThread) [custom_components.entity_controller.bathroom_motion_light] Control Entities:       ['light.bathroom_lights']
2023-12-11 14:47:24.133 DEBUG (MainThread) [custom_components.entity_controller.bathroom_motion_light] State Entities:         ['light.bathroom_lights']
Pabsilon commented 11 months ago

Hello!

I wanted to add something to the fix following my own tests at home.

To fix the issue, I updated the configuration.yaml file by using a list format for specifying sensors and entities. Instead of directly assigning a single sensor or entity. See example below: sensor: - binary_sensor.storage_motion entity: - switch.storage

VS (Doesn't Work): sensor: binary_sensor.storage_motion entity: switch.storage

If your setup uses 'trigger_on_activate' and 'trigger_on_deactivate', both have to be set as lists too.

jeeftor commented 11 months ago

Core moved to orjson from strict json - probably a yaml parsing error with the new lib

jeeftor commented 11 months ago

https://github.com/home-assistant/core/issues/105309 https://github.com/home-assistant/core/issues/105323

I'm guessing something here is related. If you can figure iut out they can get it fixed fast

hvddrift commented 11 months ago

To fix the issue, I updated the configuration.yaml file by using a list format for specifying sensors and entities. Instead of directly assigning a single sensor or entity. See example below: sensor: - binary_sensor.storage_motion entity: - switch.storage

VS (Doesn't Work): sensor: binary_sensor.storage_motion entity: switch.storage

Just for interest, Mine is in a list format: Always has been, but only - binary_sensor.philips_hallway_motion_occupancy triggers the lights, the others are ignored.


  motion_light: # serves as a name
    sensor:
      - binary_sensor.philips_hallway_motion_occupancy # required, [sensors]
      - binary_sensor.konnected_7e1888_zone_2
      - binary_sensor.konnected_7e1888_zone_3
      - binary_sensor.pad_door_contact
    entity:
      - light.first_hallway_lamp```
jddayley commented 11 months ago

I would turn on debugging and share the output.

dominicusmento commented 11 months ago

To fix the issue, I updated the configuration.yaml file by using a list format for specifying sensors and entities. Instead of directly assigning a single sensor or entity. See example below: sensor: - binary_sensor.storage_motion entity: - switch.storage VS (Doesn't Work): sensor: binary_sensor.storage_motion entity: switch.storage

Just for interest, Mine is in a list format: Always has been, but only - binary_sensor.philips_hallway_motion_occupancy triggers the lights, the others are ignored.

  motion_light: # serves as a name
    sensor:
      - binary_sensor.philips_hallway_motion_occupancy # required, [sensors]
      - binary_sensor.konnected_7e1888_zone_2
      - binary_sensor.konnected_7e1888_zone_3
      - binary_sensor.pad_door_contact
    entity:
      - light.first_hallway_lamp```

the problem reflects on the parsing completely, attribute doesn't matter.. so use list for entities too.. it will work.. You also have to use the plural -> sensors

dominicusmento commented 11 months ago

To fix the issue, I updated the configuration.yaml file by using a list format for specifying sensors and entities. Instead of directly assigning a single sensor or entity. See example below: sensor: - binary_sensor.storage_motion entity: - switch.storage

VS (Doesn't Work): sensor: binary_sensor.storage_motion entity: switch.storage

this should definitely be defined in plural ->

sensors:
  - binary_sensor.storage_motion
entities:
  - switch.storage
VimalO commented 10 months ago

To fix the issue, I updated the configuration.yaml file by using a list format for specifying sensors and entities. Instead of directly assigning a single sensor or entity. See example below: sensor: - binary_sensor.storage_motion entity: - switch.storage

VS (Doesn't Work): sensor: binary_sensor.storage_motion entity: switch.storage

That worked for me too! Thanks a lot @dominicusmento !

dan-s-github commented 10 months ago

Just for the records. If there is only one sensor/entity I use singular notation (with a -)

storage_motion:
  sensor: 
    - binary_sensor.storage_motion
  sensor_type: duration
  sensor_resets_timer: true
  entity: 
    - light.storage_downlights

and plural notation if there are multiple values

attic_motion:
  sensors:
    - binary_sensor.attic_motion
    - binary_sensor.everything_presence_one_pir
    - binary_sensor.attic_presence_enhancer
  sensor_type: duration
  sensor_resets_timer: true
  entity: 
    - light.attic_battons

sorry don't currently use multiple entites

dominicusmento commented 10 months ago

Technically, you are wrong.. by defining an array (list) in yaml, you should always use plural; doesn't matter how many records are there in it.. and you did it by changing this:

entity: light.attic_battons

to this:

entity: 
    - light.attic_battons

https://www.baeldung.com/spring-boot-yaml-list#quick-recap-about-lists-in-yaml

If it accidentally works is another thing but better get rid of singularity here..

dan-s-github commented 10 months ago

I work with spring-boot on a daily basis and it doesn't actually care if the key is singular or plural. It will just instantiate a list when you use list notation instead of a single object.

But for clarity it would be recommended to use plural keys when using list values.

Unfortunately all the config examples on this component use singular naming but code shows that it handles both options and that's why both are valid. https://github.com/danobot/entity-controller/blob/f76e717a904f3b2734cf7033acbdfc4919d964da/custom_components/entity_controller/const.py#L62-L63

jeeftor commented 10 months ago

Does this work with 2024.1?

I'm still on 2023.11

jeeftor commented 10 months ago

I just tried ton 24.1 and it still doesn't work for me ... I could prob fix it if I wasn't so busy right now

ryanwinter commented 10 months ago

To fix the issue, I updated the configuration.yaml file by using a list format for specifying sensors and entities. Instead of directly assigning a single sensor or entity. See example below: sensor: - binary_sensor.storage_motion entity: - switch.storage

VS (Doesn't Work): sensor: binary_sensor.storage_motion entity: switch.storage

Genius, this fixed it for my running 2024.1!

jeeftor commented 10 months ago

I got mine working :)

danobot commented 10 months ago

Hi all, please update to 9.7.1 which contains a fix for configuration loading (string values vs list values). @Paul-Vdp please close issue once fix has been verified.

dan-s-github commented 10 months ago

After updating to 9.71 and reverting the configuration changes I can confirm that issue has been resolved.