Multiple fixes, new device support, and dynamic device discovery#186
Open
nrbrt wants to merge 29 commits intosanjoyg:mainfrom
Open
Multiple fixes, new device support, and dynamic device discovery#186nrbrt wants to merge 29 commits intosanjoyg:mainfrom
nrbrt wants to merge 29 commits intosanjoyg:mainfrom
Conversation
IKEA MYGGSPRAY motion sensors (E2494) report as deviceType 'occupancySensor' instead of 'motionSensor'. They also lack the 'is_on' attribute that regular motion sensors have. This PR fixes both issues by: - Including 'occupancySensor' in motion sensor queries - Creating MotionSensorX with optional is_on attribute - Overriding get_motion_sensors() and get_motion_sensor_by_id() Tested with IKEA MYGGSPRAY E2494 sensors on Home Assistant 2026.1.1.
MYGGSPRAY motion sensors send events as occupancySensor device type. Without this, the hub_event_listener ignores real-time state changes from these sensors. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Cherry-picked from sanjoyg#163 by noahwilliamsson
Cherry-picked from sanjoyg#174 by lordylike Fixes sanjoyg#171
Cherry-picked from sanjoyg#182 by stirante
Cherry-picked from sanjoyg#161 by JuhaMR
STYRBAR has 4 buttons but was treated as 1-button controller. This enables button1_*, button2_*, button3_*, button4_* triggers.
Adds English translations for button3_* and button4_* triggers to support 4-button controllers like STYRBAR.
STYRBAR, RODRET and similar lightController-type remotes send remotePressEvent messages via WebSocket instead of sceneUpdated. Previously these were discarded as "non state message". This commit adds a new handler (parse_remote_press_event) that: - Parses remotePressEvent messages from lightController devices - Converts clickPattern to trigger types (single_click, long_press, etc) - Handles multi-button controllers using the _N suffix - Debounces duplicate events within 1 second (IKEA bug workaround) - Fires dirigera_platform_event for Home Assistant automations Enables use of STYRBAR 4-button and RODRET 2-button remotes in Home Assistant automations without requiring scene configuration. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This was referenced Jan 25, 2026
The min_color_temp_kelvin, max_color_temp_kelvin, and color_temp_kelvin properties were returning raw mired values from Dirigera instead of converting them to Kelvin as Home Assistant expects. Also fixed async_turn_on to use direct API patch for setting color temperature, bypassing the dirigera library's broken validation that rejects valid Kelvin values. Fixes sanjoyg#181 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Changed OptionsFlowHandler to inherit from OptionsFlowWithConfigEntry instead of OptionsFlow with explicit self.config_entry assignment. This fixes the deprecation warning: "Detected that custom integration 'dirigera_platform' sets option flow config_entry explicitly, which is deprecated" Fixes sanjoyg#170 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The IKEA ALPSTUGA air quality monitor reports CO2 levels via the currentCO2 attribute, but the dirigera library doesn't have this field in its EnvironmentSensorAttributes pydantic model yet. This commit: - Creates patched EnvironmentSensorAttributesX with current_c_o2 field - Creates EnvironmentSensorX class using the patched attributes - Adds get_environment_sensors/get_environment_sensor_by_id to HubX - Updates add_environment_sensors to create CO2 entities - Adds None default to getattr calls for safer attribute checking Fixes sanjoyg#178 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
device_trigger.py now uses the same regex pattern as hub_event_listener.py to determine whether to add the buttonX_ prefix to trigger types. Previously, device_trigger only checked number_of_buttons > 1, but hub_event_listener checks if the device ID ends with _X suffix (e.g. "xxx_1") and always adds the prefix in that case. This caused a mismatch where: - Events fired as "button1_single_click" - Triggers registered as "single_click" This affected RODRET and similar controllers where the device ID has a _1 suffix but number_of_buttons is 1. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This was referenced Jan 26, 2026
The previous fix incorrectly assumed the Dirigera API returned color temperature values in mired (micro reciprocal degrees) and converted them to Kelvin. However, the API already returns Kelvin values directly: - colorTemperature: current temp in Kelvin (e.g. 6535) - colorTemperatureMin: coldest/highest Kelvin (e.g. 4000) - colorTemperatureMax: warmest/lowest Kelvin (e.g. 2202) The erroneous conversion (1000000/value) resulted in values like 250K and 454K, which are way below the visible light spectrum and caused the UI to display incorrect colors. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
These environment sensors were missing state_class="measurement", which caused Home Assistant to show warnings about missing state_class for Long Term Statistics. Sensors fixed: - ikea_vindstyrka_humidity - ikea_vindstyrka_pm25 (current, min, max) - ikea_vindstyrka_voc_index - ikea_alpstuga_co2 Temperature already had state_class set. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Previously, schedule_update_ha_state() was only called when attribute changes were received via WebSocket. If a device only sent an isReachable change (without other attributes), the internal value was updated but Home Assistant was never notified. This caused devices to appear as "available" in HA even after they went offline in the Dirigera hub. The fix tracks reachability changes separately and ensures schedule_update_ha_state() is called when either attributes OR reachability changes. Fixes sanjoyg#147 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Devices added or removed from the Dirigera hub are now automatically reflected in Home Assistant without requiring a restart. Features: - DeviceDiscoveryCoordinator handles runtime entity registration - WebSocket events trigger discovery for new devices (deviceAdded) - Removed devices become unavailable (deviceRemoved) - Name changes sync from IKEA app to HA entity names - Room/area changes sync to HA device registry areas - Outlet entities show proper icon via device_class Implementation: - New device_discovery.py with DeviceDiscoveryCoordinator class - Modified hub_event_listener.py to handle deviceAdded/deviceRemoved - Updated all platforms (light, switch, sensor, etc.) to register with the discovery coordinator - Entity names update dynamically from device custom_name attribute Tested scenarios: - Add device from scratch: entity appears in correct room with icon - Remove device: entity becomes unavailable (safe, no auto-delete) - Rename device in IKEA app: HA entity name updates - Move device to different room: HA device area updates Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When a lamp color was changed via the IKEA Home app, Home Assistant did not reflect the change because: 1. colorHue and colorSaturation were missing from the WebSocket event whitelist, so color changes were silently ignored 2. color_mode was set once at initialization and never updated, so switching between HS color and color temperature (e.g. on RGBWW lamps) was not reflected in HA Changes: - Add colorHue and colorSaturation to light event processing list - Dynamically update color_mode in event listener when color attributes change (HS vs COLOR_TEMP) - Update color_mode in async_turn_on for HA-initiated changes - Fix color_hue setter typo (self.json_data → self._json_data) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Updated README to include additional information about the integration and donation details.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace external link to sanjoyg wiki with docs/dump-data.md. Also update screenshot paths to use relative links. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Added recommendation to revert to upstream if it becomes active again and noted plans for answering questions and filing PRs.
Corrected spelling of 'recommend' in README.
Some bulbs (e.g. KAJPLATS) only send colorMode in the deviceStateChanged event after a scene activation, without the actual color values (colorHue, colorSaturation, colorTemperature). This causes Home Assistant to not update the light color when a color scene is triggered. The sceneUpdated event contains the full attribute set in its actions array. This commit adds _apply_scene_actions() which extracts those attributes and applies them to the corresponding light entities, ensuring HA always receives the correct color state. Fixes sanjoyg#181 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
great work, thanks :) |
robertgocs-pixel
approved these changes
Jan 30, 2026
Both controllers have 2 buttons and need to be mapped so that each button is recognized as a separate entity (_1 and _2 suffix). Without this mapping, devices default to 1 button, causing trigger type mismatches for multi-button controllers. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The Dirigera hub reports both physical buttons (on and off) with the same device ID suffix (_1). Setting button count to 1 to match actual hub behavior. See issue sanjoyg#160 debug log confirmation. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Keep at 2 for forward compatibility - the device has 2 physical buttons, even though the Dirigera hub currently reports both as _1. If IKEA fixes this in a firmware update, it will work automatically. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.
This PR combines several fixes and improvements:
New Features
Dynamic Device Discovery (Issue #139)
Devices added or removed from the Dirigera hub are now automatically reflected in Home Assistant without requiring a restart.
Tested scenarios:
New Device Support
MYGGSPRAY Motion Sensors (E2494)
occupancySensordevice type support (IKEA reports these as occupancySensor, not motionSensor)RODRET/STYRBAR Remote Controls (lightController)
remotePressEventhandling forlightControllerdevice typesshortcutControllertypesALPSTUGA Air Quality Sensor
current_c_o2attribute)Bug Fixes
Light Color Mode Not Updating (NEW)
colorHueandcolorSaturationwere missing from the WebSocket event whitelist, so color changes made in the IKEA Home app were silently ignored by HAcolor_modewas set once at initialization and never updated, so switching between HS color and color temperature on RGBWW lamps was not reflected in HAcolor_mode(HS ↔ COLOR_TEMP) when color attributes change, both from external changes (IKEA app) and HA-initiated changescolor_huesetter (self.json_data→self._json_data)Device Reachability Not Updating (#147)
schedule_update_ha_state()was only called when attribute changes were receivedisReachablechange (no other attributes), HA was never notifiedDevice Trigger Prefix Mismatch (Important!)
device_trigger.pyandhub_event_listener.pyhub_event_listeneruses regex to detect_Xsuffix in device ID and addsbuttonX_prefixdevice_triggeronly checkednumber_of_buttons > 1, causing triggers to not match eventsColor Temperature Unit Conversion
ikea_bulb_devicecolor_tempin mireds, was incorrectly providing KelvinEnvironment Sensor State Class
state_class: measurementto temperature, humidity, PM2.5, VOC, CO2 sensorsDeprecation Warning
OptionsFlowwithOptionsFlowWithConfigEntryTesting
Tested on Home Assistant 2026.1+ with:
Closes #139, #147