sanjoyg / dirigera_platform

HomeAssistant Integration for Dirigera Platform
MIT License
122 stars 16 forks source link

Devices managed in _sets_ in Ikea Home Smart are unnamed #25

Closed bjorncs closed 7 months ago

bjorncs commented 7 months ago

My imported GU10s are missing the original name except for one single device, which is my only GU10 not grouped in a device set in the Ikea Home Smart app. They were briefly named IKEA Dirigera Hub : 10.0.0.3 before settling to Unnamed device. The other imported Ikea devices were correctly named including 3rd party devices.

Screenshot 2024-03-29 at 19 53 22

dirigera-devices.json

sanjoyg commented 7 months ago

I checked the JSON, the custom_name attribute of these bulbs are not set. Which is why the issue exists, will make changes in the code to name unnamed bulbs with unique id of the device

sanjoyg commented 7 months ago

please try with latest release and let know. The work on remotes is still pending, that @slajob is working on

bjorncs commented 7 months ago

I checked the JSON, the custom_name attribute of these bulbs are not set. Which is why the issue exists, will make changes in the code to name unnamed bulbs with unique id of the device

You're right - I double checked with the Ikea app now. Although the sets are named the individual devices were not. I'll add names and try again with your latest commit.

My setup consist of multiple ceiling spotlights with 4 spots each (Ikea Nymåne). I never control those devices directly - just the aggregate sets. It would be practical to have the sets being imported as light groups in HA.

sanjoyg commented 7 months ago

Agreed, will include support for sets as well. Any clue if the command to set on/off to a set is to each device individually or to the set

bjorncs commented 7 months ago

After upgrading to the newest version the unnamed Ikea bulbs had their id as name.

FYI there is no easy way of naming devices that are part of a set in the Ikea app. A device must be temporarily removed from the set to give it a name.

Any clue if the command to set on/off to a set is to each device individually or to the set

No clue. However, I'm happy to assist in finding out.

sanjoyg commented 7 months ago

ok i figured out how to work with sets. Now I have couple of questions, that I would need answers before I can start implementing the changes

  1. Can you mix in your setup a set to have lights with other device types. Or does it only allow bulbs/light. I wasnt unable to create a set outside of lights, so need to confirm that.
  2. When the set is exposed it would be exposed as a light, do you want the individual bulbs/lights also exposed as device/entity. The IKEA app doesnt expose the individual bulbs once merged into a set.

@slajob please do weigh in with your thoughts also

bjorncs commented 7 months ago

That's awesome 👍

  1. I'm allowed to add bulbs, spots, Trådfri drivers and 3rd party zigbee wall dimmers. The Trådfri smart outlet and temperature sensors are not available (the latter not really suprising...).
  2. I prefer having them exposed as a single light entity, like in the Ikea app. All my sets are homogenous with identical Ikea spots. Individual control hasn't been necessary yet.
sanjoyg commented 7 months ago

@bjorncs I have an implementation ready would you be able to test device sets and all other functions?

If yes will release a beta

bjorncs commented 7 months ago

@sanjoyg Sure thing 👍

sanjoyg commented 7 months ago

1.5.1 Beta released for you to test and let me know

bjorncs commented 7 months ago

All my device sets were imported as such with 1.4.1 pre-release version after a reinstall. My installation was modified with some small code changes in the first place, so I'm not certain that the reinstall would be necessary when upgrading from a clean installation. I tested some basic behaviour (on/off, dimming, color change). Everything works great so far 👏.

bjorncs commented 7 months ago

FYI there are repeated failures being logged. Not sure if this is a regression or just a result of my Aqara sensors being treated as a VINDSTYRKA device.

2024-04-10 21:50:13.436 ERROR (MainThread) [custom_components.dirigera_platform] error encountered running update on : Temperatur bathroom
2024-04-10 21:50:13.436 ERROR (MainThread) [custom_components.dirigera_platform] 'ikea_vindstyrka_device' object has no attribute 'hass'
2024-04-10 21:50:13.436 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.temperatur_bathroom_voc_index fails
Traceback (most recent call last):
File "/config/custom_components/dirigera_platform/sensor.py", line 93, in async_update
self._json_data = await self.hass.async_add_executor_job(self._hub.get_environment_sensor_by_id, self._json_data.id)
^^^^^^^^^
AttributeError: 'ikea_vindstyrka_device' object has no attribute 'hass'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 951, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1268, in async_device_update
await self.async_update()
File "/config/custom_components/dirigera_platform/sensor.py", line 175, in async_update
await self._ikea_env_device.async_update()
File "/config/custom_components/dirigera_platform/sensor.py", line 100, in async_update
raise HomeAssistantError(ex, DOMAIN, "hub_exception")
homeassistant.exceptions.HomeAssistantError: (AttributeError("'ikea_vindstyrka_device' object has no attribute 'hass'"), 'dirigera_platform', 'hub_exception')
sanjoyg commented 7 months ago

@bjorncs would you also test with release 1.4.2 is an entire new way to update device state. need help to test with

  1. motion sensor
  2. open close sensor
  3. air purifier
  4. environment sensor
  5. controllers

@slajob if you could also please have a look.

bjorncs commented 7 months ago
  1. The state of my Trådfri motion sensor always off. Looking at the history it's been like that all the time.
  2. Too early to tell whether temperature changes are reported.
  3. Not sure what you mean by "controllers". Battery status of remote/buttons are reported. State changes for both my Trådfri driver and outlet are instantly detected when toggled in Ikea app.

There are some new warnings occurring - see attached log. logs.txt

sanjoyg commented 7 months ago

Thank you. For the motion sensor would be able to send me json when its off and when its on. Think the attribute is not been captured

Also when you enable debug the hub event of motion sensor will indicate the change in attribute that is another source to figure

The colorMode issue I will start looking into

bjorncs commented 7 months ago

When motion is detected the a websocket event is received with isDetected=true

2024-04-11 21:40:52.807 DEBUG (Thread-2) [custom_components.dirigera_platform] rcvd message : {"id":"8ec8d256-ebf6-40e5-9add-fedfb103c402","time":"2024-04-11T19:40:52.000Z","specversion":"3.150.0","source":"urn:com:ikea:homesmart:iotc:zigbee","type":"deviceStateChanged","data":{"id":"deb44783-06c3-4489-8346-f98f6b183308_1","type":"sensor","deviceType":"motionSensor","createdAt":"2023-10-29T21:17:17.000Z","isReachable":true,"lastSeen":"2024-04-11T21:40:52.000Z","attributes":{"isDetected":true,"sensorConfig":{"scheduleOn":false,"onDuration":120,"schedule":{"onCondition":{"time":"22:00"},"offCondition":{"time":"06:00"}}},"circadianPresets":[]},"remoteLinks":[]}}

3 minutes later a new event is received with isDetected=false.

2024-04-11 21:43:52.785 DEBUG (Thread-2) [custom_components.dirigera_platform] rcvd message : {"id":"4d62257f-1d99-477c-b770-eb41425c6dbf","time":"2024-04-11T19:43:52.000Z","specversion":"3.150.0","source":"urn:com:ikea:homesmart:iotc:zigbee","type":"deviceStateChanged","data":{"id":"deb44783-06c3-4489-8346-f98f6b183308_1","type":"sensor","deviceType":"motionSensor","createdAt":"2023-10-29T21:17:17.000Z","isReachable":true,"lastSeen":"2024-04-11T21:40:52.000Z","attributes":{"isDetected":false,"sensorConfig":{"scheduleOn":false,"onDuration":120,"schedule":{"onCondition":{"time":"22:00"},"offCondition":{"time":"06:00"}}},"circadianPresets":[]},"remoteLinks":[]}}

The isDetected attribute is not included in the output from dump_data. I could not find any difference before and after a detection except for lastSeen.

sanjoyg commented 7 months ago

Thank you, what model of motion sensor is it?

sanjoyg commented 7 months ago

Also would you send me the log line output of the websocket event for the colorMode that generates the warning

Also would request for the json dump of the motion sensor

bjorncs commented 7 months ago

Thank you, what model of motion sensor is it?

Ikea Trådfri Motion Sensor E1745

Also would you send me the log line output of the websocket event for the colorMode that generates the warning

Also would request for the json dump of the motion sensor

See attached file dump.txt

sanjoyg commented 7 months ago

@bjorncs Thank you for the logs. Both issues should be fixed. Do let me know if you now see the motion sensor working

bjorncs commented 7 months ago

There's some new failure appearing in the log. HA claims the binary_sensor.storage_sensor entity is unavailable. logs.txt

sanjoyg commented 7 months ago

Would you please check this with the new release.

bjorncs commented 7 months ago

I submitted a short fix in https://github.com/sanjoyg/dirigera_platform/pull/32 to resolve a crash during device setup.

My installation was also in a bad state where it failed to update dirigera dependency to 1.1.1. Once upgraded the detection entity started working 💯

bjorncs commented 7 months ago

The revert back to polling did result in a lot of timeouts and connection failures. This could be a result of too aggresive pooling or some edge case when combining websocket listener with polling. My hub is on version 2.556.0, which is fairly new, so a regression there is not unlikely either. dump.txt

sanjoyg commented 7 months ago

I am thinking setting the listener for only certain devices such as motion_sensor. What do u think?

sanjoyg commented 7 months ago

Have done that in the release. If there continues to be an issue do open another issue, closing this for now. Thank you for your changes have merged it in.

bjorncs commented 7 months ago

I am thinking setting the listener for only certain devices such as motion_sensor. What do u think?

I prefer listener for all devices is it provides immediate update on state transitions. The cost of polling increases linearly with the number devices. The local push model scales better for large number of devices.

sanjoyg commented 7 months ago

Its a hybrid right now. Do have a look at the implementation and if there is a away to improve it... please feel free to add.