Repository navigation
refactor: use dirigera 1.6.0 instead of local model patches - #67
Merged
Merged
Conversation
dirigera 1.6.0 covers several things this integration patched around, so bump it and rely on the library: - lights keep colorMode as attributes.color_mode: drop LightX and the HubX.get_lights / get_light_by_id overrides - motion sensor is_on is optional, so MYGGSPRAY parses as MotionSensor: drop MotionSensorX (get_motion_sensors still includes occupancySensor) - ControllerX was identical to the library's Controller: drop it and the get_controllers override - set colour temperature with Light.set_color_temperature() instead of a direct PATCH; report the Kelvin range with the library's mired rule and clamp requests to it - stop blinds with Blind.set_state(BlindsStateEnum.STOPPED) - select outlets by deviceType, so a GRILLPLATS metering half with type "outlet" no longer fails to parse (missing isOn)
nrbrt
added a commit
that referenced
this pull request
Oct 26, 2026
) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016G9Pu8TcL6HFd6wuvdY3ca
Owner
|
Thanks, this is a welcome cleanup. I merged it on top of v0.3.24 and released it as v0.3.25. Tested on a real hub with colour-temperature changes on a TRÅDFRI colour bulb (2700 K, 4000 K, an out-of-range 6500 K clamped to 4000 K, and 3000 K confirmed in the hub's state); no errors in the log. I couldn't test the blinds stop, we have no blinds here. |
nrbrt
pushed a commit
that referenced
this pull request
Oct 26, 2026
get_environment_sensors() merged a TIMMERFLOTTE pair into whichever half the hub listed first. When the humidity half (<rel>_2) comes first, the merged sensor takes its id, generic name and empty room, and get_environment_sensor_by_id(<rel>_1) raises ValueError on refresh. Sort each relationId group so the half with the temperature, the room and the _1 suffix wins, deep-copy instead of writing into the /devices response, and inherit the room from the other half if the primary lacks one. Adds tests/test_split_environment_sensor.py, which fails on the old merge for the reversed order and passes for the order real hubs use. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Squashed from PR #57; the import conflict with #67 resolved on merge. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016G9Pu8TcL6HFd6wuvdY3ca
1 of 2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your changes
I maintain the dirigera library. Several things this integration patches around in
dirigera_lib_patch.py, or works around with direct PATCH calls, are covered by the library now, so this bumps it to 1.6.0 (released today) and uses it instead.dirigera_lib_patch.pyshrinks by about 120 lines.LightkeepscolorModeasattributes.color_modesince 1.6.0 (Add color_mode to lights and make motion sensor is_on optional Leggin/dirigera#148). RemovesLightX,LightAttributesX,dict_to_light_xand theHubX.get_lights/get_light_by_idoverrides. The hs-first fallback inset_state()stays for bulbs that don't reportcolorMode.MotionSensorAttributes.is_onis optional since 1.6.0, so MYGGSPRAY parses as a plainMotionSensor. RemovesMotionSensorX/MotionSensorAttributesX.HubX.get_motion_sensorsstill includesoccupancySensordevices, and runtime discovery uses the library'sdict_to_motion_sensor.ControllerXwas identical to the library'sController(same optional fields and methods since dirigera 1.2), so it and theget_controllersoverride are removed.Light.set_color_temperature()instead of PATCHing the hub directly. The bypass was there for "library validation issues", which were fixed in the library (mired bounds, Fix color temperature range check for bulbs reporting mired bounds Leggin/dirigera#137).min_color_temp_kelvin/max_color_temp_kelvinnow use the library's rule: bounds below 1000 are mireds and get converted, and the order doesn't matter. Before, a KAJPLATS reporting 153..454 showed up in HA as 454..153 "Kelvin". Requests are clamped to that range. The manual write-through to the model goes away because the library updates it._send_stopusesBlind.set_state(BlindsStateEnum.STOPPED)(dirigera ≥ 1.3.0) instead of its own PATCH.HubX.get_outletsselects outlets bydeviceTypeinstead oftype. On some firmware the metering half of a GRILLPLATS also hastype: "outlet", and parsing it as anOutletfailed on the missingisOn(get_outlets()fails for new IKEA GRILLPLATS plug: missingattributes.isOnLeggin/dirigera#131). The library made the same fix in 1.3.0, but this override kept the old filter. The energy merge is unchanged.Not changed: Matter filtering, the
/devicesbatch cache, TIMMERFLOTTE merging, the energy merge into outlets, the empty scenes for controller triggers,HackScene, and device sets, which still PATCH directly because the library has no device-set API.One behaviour difference: a bulb that accepts
colorTemperaturebut reports no min/max now gets the library'sValueErrorinstead of an unchecked PATCH. IKEA bulbs report the range.Tests
dirigera==1.6.0,python-dateutil,pytestandpytest-asyncio. Withdirigera==1.2.6installed, the 7 tests that use the real library fail, so the new pin is needed.tests/test_light_color_temp_range.pychecks the range for Kelvin bounds in either order and for mired bounds. It also checks that the library accepts the whole range HA is offered and rejects values just outside it, so the two can't drift apart.tests/test_light_color_mode.py: theLightXtests are replaced by tests on the libraryLight: it keepscolorMode, reportsNonewithout it, and accepts the listener's writes. Theset_state()tests are unchanged.tests/test_blinds_stop.py: the fake blind gets aset_state()that behaves like the library's (PATCH first, then the model). The test now also assertsBlindsStateEnum.STOPPED.HubXagainst hub-shaped payloads on 1.2.6 (before) and 1.6.0 (after): lights, controllers, motion sensors including a MYGGSPRAY withoutisOn, empty-scene creation, and a GRILLPLATS whose metering half hastype: "outlet". That last one raised aValidationErrorbefore this change and works now. Everything else gave identical results.Checklist before submitting a pull request
requirements.txtandmanifest.jsonChecklist for reviewer