sanjoyg / dirigera_platform

HomeAssistant Integration for Dirigera Platform
MIT License
71 stars 8 forks source link

Light status updates are very slow (e.g. when changing brightness) #46

Closed ghost closed 3 weeks ago

ghost commented 1 month ago

I recently have a IKEA Dirigera hub and moved all my Tradfri lights from my old Tradfri hub to this new hub. I run Home Assistant on a Raspberry Pi4 and use the latest version of the Dirigera platform.

When I turn on/off a light (or change brightness) via the IKEA Smart app or IKEA remote, then in HA I see that the status of the light is updated very slowly, can take several seconds. With my old Tradfri hub I didn't have these issues, the HA Tradfri component was rather fast.

I don't see real errors in the logging, except for one error every time when I change a light, generated by hub_event_listener.py line 107, which should be info iso error logging I guess:

Logger: custom_components.dirigera_platform Source: custom_components/dirigera_platform/hub_event_listener.py:107 integration: IKEA Dirigera Hub Integration (documentation, issues) First occurred: 16:58:03 (1 occurrences) Last logged: 16:58:03

id='95a165f4-a7cb-4db5-9f35-9fbc9907ddc2_1' relation_id=None type='light' device_type='light' created_at=datetime.datetime(2024, 5, 9, 15, 30, 43, tzinfo=datetime.timezone.utc) is_reachable=True last_seen=datetime.datetime(2024, 5, 15, 16, 51, 59, tzinfo=datetime.timezone.utc) attributes=LightAttributes(custom_name='Lamp tv right', model='TRADFRI bulb E27 WS opal 980lm', manufacturer='IKEA of Sweden', firmware_version='2.3.095', hardware_version='1', serial_number='000B57FFFE9AD822', product_code='LED1545G12', ota_status='upToDate', ota_state='readyToCheck', ota_progress=0, ota_policy='autoUpdate', ota_schedule_start=datetime.time(0, 0), ota_schedule_end=datetime.time(0, 0), startup_on_off=<StartupEnum.START_ON: 'startOn'>, is_on=True, light_level=3, color_temperature=2202, color_temperature_min=4000, color_temperature_max=2202, color_hue=None, color_saturation=None) capabilities=Capabilities(can_send=[], can_receive=['customName', 'isOn', 'lightLevel', 'colorTemperature']) room=Room(id='f24519ce-712b-461e-8cac-7cf286ef119e', name='Room 3', color='ikea_yellow_no_24', icon='rooms_arm_chair') device_set=[] remote_links=['c0bfdc16-8af7-466d-8586-6148c995a9a6_1'] is_hidden=False dirigera_client=<dirigera.hub.hub.Hub object at 0x7f826f69c0>

It's strange that nobody else reported similar issues. So maybe I'm doing something wrong ? The Dirigera hub works fine via the IKEA Smart app (on IOS and on Android). But it's very slow via the HA Dirigera platform.

ghost commented 1 month ago

Not sure, but it looks like the Dirigera platform is only polling for status change every 30 seconds.

For some sensors you want to know the status change as soon as possible, e.g. door sensor and motion sensor (not tested yet). After some googling I found out that this can be done with an automation which triggers the update entity service every x seconds.

But The Dirigera platform works very well. Keep up the good work!!! I know it costs a lot of time and effort.

Unseen88 commented 1 month ago

hi,

just got new ikea setup yes the same thing is happening with me as well even turning on off also it has a delay, it does update and is working way better than the home kit work around that just disconnects after few minutes

so, no complains flawless work

Unseen88 commented 1 month ago

Not sure, but it looks like the Dirigera platform is only polling for status change every 30 seconds.

For some sensors you want to know the status change as soon as possible, e.g. door sensor and motion sensor (not tested yet). After some googling I found out that this can be done with an automation which triggers the update entity service every x seconds.

But The Dirigera platform works very well. Keep up the good work!!! I know it costs a lot of time and effort.

hi, let me know if you want to test the motion sensors i have few not installed any yet, also if you get any good results from automation workaround

slajob commented 1 month ago

Guys, are you using newest dirigera platform version? The delay was repaired recently

vulcanoid1975 commented 1 month ago

I'm using Dirigera hub firmware version 2.556.0 and still have the same slowness from the start, hasn't changed at all ... (release from the 9th of April, from the release notes)

slajob commented 1 month ago

I meant version of dirigera platform integration in home assistant.

duat13 commented 1 month ago

I meant version of dirigera platform integration in home assistant.

I installed everything minutes ago, so hopefully I got the latest releases and have the same issue. After changing a state, it takes very long to get the response in ha. It's to long to control light with the motion sensor

vulcanoid1975 commented 1 month ago

I meant version of dirigera platform integration in home assistant.

Installed version 1.7.1 Latest version 1.7.1

sanjoyg commented 1 month ago

Would you enable debug and try switch on/off or brightness and paste the log. Ideally the event from the hub should be processed asap.

vulcanoid1975 commented 1 month ago

Hi @sanjoyg,

Hope this helps:

home-assistant_dirigera_platform_2024-05-16T06-47-50.337Z.log

Switched on and off and changed brightness level for 4 lights, 2 from Ikea 2 from Aqara, all of them added to the Dirigera Hub.

Thank You!

vulcanoid1975 commented 1 month ago

Uninstalled a few integrations that weren't doing anything just creating errors, restarted Home Assistant and enabled debug logging and did the same test, here's the result:

home-assistant_dirigera_platform_2024-05-16T07-25-01.626Z.log

Sorry the last log wasn't very helpful ... (already on 1.7.2)

sanjoyg commented 1 month ago

I think know the issue, confirm that the slowness is in brightness change only. But no switch on switch off. As per code switch on/off should be fast.

Unseen88 commented 1 month ago

i have just installed everything 10 days back , delay is there lights on off shoes delay still group lights seems to do things fast individual controls takes time on on off also , i will re confirm looking at the plugs

slajob commented 1 month ago

Sanjoyg found the issue. I'm fixing it

ghost commented 1 month ago

I’m using latest version 7.1.2 of the Dirigera platform. Tested the IKEA Parasoll door/window sensor today. Status change open/close can take up to 30 seconds. This is the kind of delay I was talking about and why I created this issue. Will test the motion sensor later….

I also noticed another type of delay when switching e.g. a light from HA lovelace webinterface. Turning on/off a light takes about half a second, which is OK. When changing brightness, the responce of the light is a bit slower but OK. However the brightness slider in Lovelace is reacting very slow. So when I change the brightness from 5 to 100%, the slider will jump back from 100% to 24% and then it’s not changing anymore for seconds. Finally the status in Lovelace will be 100%. Please try it yourself and see how the brightness slider in Lovelace is reacting on a brightness change.

When I have more time I will make a video.

ghost commented 1 month ago

I found the cause of the long delays when testing with a door_window sensor. Def async_schedule_update_ha_state in module base_classes is not working. It raises exceptions for all listeners. listener.async_schedule_update_ha_state(force_refresh) should be listener.schedule_update_ha_state(force_refresh). This will solve the status update for door_window sensors but not for e.g lights. A light entity has no listeners, so it will get no ha_status updates at all, so has to be updated in another way. More investigation needed…

sanjoyg commented 1 month ago

Try the latest release. There is an issue with the hub, which gives the stale state first. So when you set brightness u would see a past state come up and then in a second the right state is set.

If it works then close the issue

ghost commented 1 month ago

Thanks sanjoyg for all your effort. I have to test the brightness issue better. With the latest version there still seem to be some issues with brightness responsiveness.

For the ha status updates I will create a new issue. I get errors in the logging. Update of lights (on/off) and door/window sensors(open/close) are not working.

vulcanoid1975 commented 1 month ago

Again Thank You @sanjoyg but unfortunately I don't see any improvements either. If you need any information I can test and send logs.

ghost commented 1 month ago

Errors when changing brightness with a remote control:

============

Logger:` homeassistant.helpers.frame Source: helpers/frame.py:190 First occurred: 17:26:39 (2 occurrences) Last logged: 17:26:40

Detected that custom integration 'dirigera_platform' calls async_write_ha_state from a thread at custom_components/dirigera_platform/hub_event_listener.py, line 115: entity.async_schedule_update_ha_state(False), please report it to the author of the 'dirigera_platform' custom integration.

===========

This error originated from a custom integration.

Logger: custom_components.dirigera_platform Source: custom_components/dirigera_platform/hub_event_listener.py:118 integration: IKEA Dirigera Hub Integration (documentation, issues) First occurred: 17:26:39 (2 occurrences) Last logged: 17:26:40

error processing hub event

==================

This error originated from a custom integration.

Logger: custom_components.dirigera_platform Source: custom_components/dirigera_platform/hub_event_listener.py:119 integration: IKEA Dirigera Hub Integration (documentation, issues) First occurred: 17:26:39 (2 occurrences) Last logged: 17:26:40

{"id":"dcb0670e-8317-4543-827d-93bccc2f485c","time":"2024-05-19T15:26:39.000Z","specversion":"3.150.0","source":"urn:com:ikea:homesmart:iotc:zigbee","type":"deviceStateChanged","data":{"id":"6afe28e4-fd52-41d6-a3a4-8c68a30098f5_1","type":"light","deviceType":"light","createdAt":"2024-05-11T18:26:18.000Z","isReachable":true,"lastSeen":"2024-05-19T17:26:39.000Z","attributes":{"lightLevel":22},"remoteLinks":["ceeafbc0-f9f5-4586-8eaa-fa9d587ae4cf_1"]}} {"id":"56bc5649-5836-459b-adf8-4411a3caf829","time":"2024-05-19T15:26:40.000Z","specversion":"3.150.0","source":"urn:com:ikea:homesmart:iotc:zigbee","type":"deviceStateChanged","data":{"id":"6afe28e4-fd52-41d6-a3a4-8c68a30098f5_1","type":"light","deviceType":"light","createdAt":"2024-05-11T18:26:18.000Z","isReachable":true,"lastSeen":"2024-05-19T17:26:40.000Z","attributes":{"lightLevel":1},"remoteLinks":["ceeafbc0-f9f5-4586-8eaa-fa9d587ae4cf_1"]}}

============

This error originated from a custom integration.

Logger: custom_components.dirigera_platform Source: custom_components/dirigera_platform/hub_event_listener.py:120 integration: IKEA Dirigera Hub Integration (documentation, issues) First occurred: 17:26:39 (2 occurrences) Last logged: 17:26:40

Detected that custom integration 'dirigera_platform' calls async_write_ha_state from a thread at custom_components/dirigera_platform/hub_event_listener.py, line 115: entity.async_schedule_update_ha_state(False). Please report it to the author of the 'dirigera_platform' custom integration.

vulcanoid1975 commented 1 month ago

I have the same errors:

This error originated from a custom integration.

Logger: custom_components.dirigera_platform Source: custom_components/dirigera_platform/hub_event_listener.py:120 integration: IKEA Dirigera Hub Integration (documentation, issues) First occurred: 12:18:54 PM (380 occurrences) Last logged: 7:51:39 PM

Detected that custom integration 'dirigera_platform' calls async_write_ha_state from a thread at custom_components/dirigera_platform/hub_event_listener.py, line 115: entity.async_schedule_update_ha_state(False). Please report it to the author of the 'dirigera_platform' custom integration. Detected that custom integration 'dirigera_platform' calls async_write_ha_state from a thread at custom_components/dirigera_platform/base_classes.py, line 81: listener.async_schedule_update_ha_state(force_refresh). Please report it to the author of the 'dirigera_platform' custom integration. Detected that custom integration 'dirigera_platform' calls async_write_ha_state from a thread at custom_components/dirigera_platform/hub_event_listener.py, line 113: delegate.async_schedule_update_ha_state(False). Please report it to the author of the 'dirigera_platform' custom integration.


This error originated from a custom integration.

Logger: custom_components.dirigera_platform Source: custom_components/dirigera_platform/hub_event_listener.py:119 integration: IKEA Dirigera Hub Integration (documentation, issues) First occurred: 12:18:54 PM (380 occurrences) Last logged: 7:51:39 PM

{"id":"2c749e69-d596-4abd-818f-0f68c9d81120","time":"2024-05-19T18:49:31.000Z","specversion":"3.150.0","source":"urn:com:ikea:homesmart:iotc:zigbee","type":"deviceStateChanged","data":{"id":"feab0316-070b-4a2e-8e97-4c0c354a1636_1","type":"light","deviceType":"light","createdAt":"2024-04-05T22:43:50.000Z","isReachable":true,"lastSeen":"2024-05-19T19:49:31.000Z","attributes":{"lightLevel":100},"remoteLinks":[]}} {"id":"c6f72c3c-128a-4be4-8d15-110b4884cc92","time":"2024-05-19T18:50:06.000Z","specversion":"3.150.0","source":"urn:com:ikea:homesmart:iotc:zigbee","type":"deviceStateChanged","data":{"id":"feab0316-070b-4a2e-8e97-4c0c354a1636_1","type":"light","deviceType":"light","createdAt":"2024-04-05T22:43:50.000Z","isReachable":true,"lastSeen":"2024-05-19T19:50:06.000Z","attributes":{"lightLevel":93},"remoteLinks":[]}} {"id":"4531a1b6-222d-4566-81cb-141ecab532f0","time":"2024-05-19T18:50:08.000Z","specversion":"3.150.0","source":"urn:com:ikea:homesmart:iotc:zigbee","type":"deviceStateChanged","data":{"id":"feab0316-070b-4a2e-8e97-4c0c354a1636_1","type":"light","deviceType":"light","createdAt":"2024-04-05T22:43:50.000Z","isReachable":true,"lastSeen":"2024-05-19T19:50:08.000Z","attributes":{"lightLevel":100},"remoteLinks":[]}} {"id":"563a6255-a794-419f-8b11-b2ef0f55bd3b","time":"2024-05-19T18:50:41.000Z","specversion":"3.150.0","source":"urn:com:ikea:homesmart:iotc:zigbee","type":"deviceStateChanged","data":{"id":"9d04542a-5d6c-4d09-b207-469cb72fc9b0_1","type":"sensor","deviceType":"motionSensor","createdAt":"2024-05-19T12:38:16.000Z","isReachable":true,"lastSeen":"2024-05-19T19:49:41.000Z","attributes":{"isDetected":false,"sensorConfig":{"scheduleOn":false,"onDuration":60,"schedule":{"onCondition":{"time":"01:00"},"offCondition":{"time":"06:00"}}},"circadianPresets":[]},"remoteLinks":[]}} {"id":"6aceb19b-6c0d-49e4-a69b-a7cf3ee3149f","time":"2024-05-19T18:51:39.000Z","specversion":"3.150.0","source":"urn:com:ikea:homesmart:iotc:zigbee","type":"deviceStateChanged","data":{"id":"7afcc32a-bc70-40d5-8343-bf995d010b53_1","type":"sensor","deviceType":"openCloseSensor","createdAt":"2024-05-15T20:28:30.000Z","isReachable":true,"lastSeen":"2024-05-19T19:51:39.000Z","attributes":{"batteryPercentage":96},"remoteLinks":[]}}


And also:

This error originated from a custom integration.

Logger: custom_components.dirigera_platform Source: custom_components/dirigera_platform/hub_event_listener.py:118 integration: IKEA Dirigera Hub Integration (documentation, issues) First occurred: 12:18:54 PM (380 occurrences) Last logged: 7:51:39 PM

error processing hub event


As the number of occurences are the same ... I imagined they might be related ...

sanjoyg commented 1 month ago

Please try the latest release

sanjoyg commented 3 weeks ago

Closing as no response. Do re-open if it doesnt work