sanjoyg / dirigera_platform

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

Ikea Dirigera Hub switching IP4 address causing "failed to establish a new connection" error #70

Open PinInCalgary opened 2 months ago

PinInCalgary commented 2 months ago

I'm using the IKEA Dirigera Hub Integration to control a couple of Ikea TRADFRI Color Changing LED lights 800lm Part # 604.624.27. I have the Ikea Dirigera Hub, part #505.034.14.

When I click on one of the lights in the card, I get the following error

Failed to perform the action light/turn_off. (ConnectionError(MaxRetryError("HTTPSConnectionPool(host='192.168.1.234', port=8443): Max retries exceeded with url: /v1/devices/ac311343-30b0-4e6c-aed7-abe2c6b1ac14_1 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f27894a1460>: Failed to establish a new connection: [Errno 113] Host is unreachable'))")), 'dirigera_platform', 'hub_exception')

What I have seen is that the IP4 IP address of the Dirigera Hub keeps changing, almost like it's rebooting and grabbing a new IP4 IP address, which accounts for the "Failed to establish a new connection" since the hub has a new IP4 address, i.e. moved to 192.168.1.235 by this time from 192.168.1.234

If I delete the hub from the integration and then readd with the new IP4, found using the linux command

sudo nmap -v -sP 192.168.1.0/24

then push the action button on the hub, the lights work for a few minutes, until the hub moves to the next IP4. (Not sure if it's a crash or something else.)

Note that I there is a smart light switch that controls the ceiling light, which is also a device in Alexa and the actual TRADFRI LEDs are also devices in Alexa.

Any suggestions w.r.t. troubleshooting? Is it worth it to remove the light switch and the LEDs from Alexa and see if things settle down? Is there any way to debug what's happening on the hub? Is there a way to create a static IP address for the hub given that I don't think we can actually login to it?

image

I've attached the Home Assistant Core log to this ticket.

home-assistant_2024-09-09T21-59-25.900Z.log

Here's the requested dirigera_platform.dump_data.

2024-09-09 15:41:06.538 INFO (SyncWorker_3) [custom_components.dirigera_platform] === START Devices JSON === 2024-09-09 15:41:06.538 INFO (SyncWorker_3) [custom_components.dirigera_platform] -------------- 2024-09-09 15:41:06.777 INFO (SyncWorker_3) [custom_components.dirigera_platform] [{'id': 'bba82f27-48de-4c67-a0e9-14c4f6df3141_1', 'type': 'light', 'deviceType': 'light', 'createdAt': '2024-09-06T23:45:06.000Z', 'isReachable': True, 'lastSeen': '2024-09-09T20:14:35.000Z', 'attributes': {'customName': 'e26-2 color changing', 'model': 'TRADFRI bulb E26 CWS 800lm', 'manufacturer': 'IKEA of Sweden', 'firmwareVersion': '1.0.021', 'hardwareVersion': '1', 'serialNumber': 'B0C7DEFFFE96F4BA', 'productCode': 'LED1924G9NA', 'isOn': True, 'startupOnOff': 'startOn', 'lightLevel': 50, 'startUpCurrentLevel': -1, 'colorHue': 359.94670434063096, 'colorSaturation': 1, 'colorTemperature': 3003, 'colorTemperatureMin': 4000, 'colorTemperatureMax': 2202, 'startupTemperature': -1, 'colorMode': 'color', 'identifyStarted': '2000-01-01T00:00:00.000Z', 'identifyPeriod': 0, 'permittingJoin': False, 'otaStatus': 'upToDate', 'otaState': 'readyToCheck', 'otaProgress': 0, 'otaPolicy': 'autoUpdate', 'otaScheduleStart': '00:00', 'otaScheduleEnd': '00:00'}, 'capabilities': {'canSend': [], 'canReceive': ['customName', 'isOn', 'lightLevel', 'colorTemperature', 'colorHue', 'colorSaturation']}, 'room': {'id': '2a365892-1366-4c4f-85c5-149059d24454', 'name': 'Office', 'color': 'ikea_brown_no_41', 'icon': 'rooms_office_chair'}, 'deviceSet': [], 'remoteLinks': [], 'isHidden': False}, {'id': '695d829d-d6d8-4540-9c2c-e9ae0864dd29_1', 'type': 'light', 'deviceType': 'light', 'createdAt': '2024-09-05T13:52:40.000Z', 'isReachable': False, 'lastSeen': '2024-09-09T20:10:26.000Z', 'attributes': {'customName': 'E12 1', 'model': 'TRADFRIbulbE12WSglobeopal470lm', 'manufacturer': 'IKEA of Sweden', 'firmwareVersion': '1.0.012', 'hardwareVersion': '1', 'serialNumber': '94DEB8FFFEF5401C', 'productCode': 'LED2002G5NA', 'isOn': False, 'startupOnOff': 'startOn', 'lightLevel': 100, 'startUpCurrentLevel': -1, 'colorTemperature': 2702, 'colorTemperatureMin': 4000, 'colorTemperatureMax': 2202, 'startupTemperature': -1, 'colorMode': 'temperature', 'identifyStarted': '2000-01-01T00:00:00.000Z', 'identifyPeriod': 0, 'permittingJoin': False, 'otaStatus': 'upToDate', 'otaState': 'readyToCheck', 'otaProgress': 0, 'otaPolicy': 'autoUpdate', 'otaScheduleStart': '00:00', 'otaScheduleEnd': '00:00'}, 'capabilities': {'canSend': [], 'canReceive': ['customName', 'isOn', 'lightLevel', 'colorTemperature']}, 'room': {'id': 'd034c4b2-0e35-4f6a-bd8e-843c99cf772a', 'name': 'Holding Space', 'color': 'ikea_green_no_65', 'icon': 'rooms_arm_chair'}, 'deviceSet': [], 'remoteLinks': [], 'isHidden': False}, {'id': '04208ef2-4020-46d4-909a-f865938e079b_1', 'type': 'light', 'deviceType': 'light', 'createdAt': '2024-09-05T14:01:16.000Z', 'isReachable': False, 'lastSeen': '2024-09-09T20:10:26.000Z', 'attributes': {'customName': 'E12 3', 'model': 'TRADFRIbulbE12WSglobeopal470lm', 'manufacturer': 'IKEA of Sweden', 'firmwareVersion': '1.0.012', 'hardwareVersion': '1', 'serialNumber': '1C34F1FFFEB0ADB3', 'productCode': 'LED2002G5NA', 'isOn': False, 'startupOnOff': 'startOn', 'lightLevel': 100, 'startUpCurrentLevel': -1, 'colorTemperature': 2702, 'colorTemperatureMin': 4000, 'colorTemperatureMax': 2202, 'startupTemperature': -1, 'colorMode': 'temperature', 'identifyStarted': '2000-01-01T00:00:00.000Z', 'identifyPeriod': 0, 'permittingJoin': False, 'otaStatus': 'upToDate', 'otaState': 'readyToCheck', 'otaProgress': 0, 'otaPolicy': 'autoUpdate', 'otaScheduleStart': '00:00', 'otaScheduleEnd': '00:00'}, 'capabilities': {'canSend': [], 'canReceive': ['customName', 'isOn', 'lightLevel', 'colorTemperature']}, 'room': {'id': 'd034c4b2-0e35-4f6a-bd8e-843c99cf772a', 'name': 'Holding Space', 'color': 'ikea_green_no_65', 'icon': 'rooms_arm_chair'}, 'deviceSet': [], 'remoteLinks': [], 'isHidden': False}, {'id': '6665dada-bc25-41e1-9427-99da0985d31d_1', 'relationId': '6665dada-bc25-41e1-9427-99da0985d31d', 'type': 'gateway', 'deviceType': 'gateway', 'createdAt': '2024-03-08T06:39:03.481Z', 'isReachable': True, 'lastSeen': '2024-09-09T21:41:00.528Z', 'attributes': {'customName': 'Mt McKenzie', 'model': 'DIRIGERA Hub for smart products', 'manufacturer': 'IKEA of Sweden', 'firmwareVersion': '2.615.8', 'hardwareVersion': 'P2.5', 'serialNumber': '6665dada-bc25-41e1-9427-99da0985d31d', 'identifyStarted': '2000-01-01T00:00:00.000Z', 'identifyPeriod': 0, 'otaStatus': 'upToDate', 'otaState': 'checkFailed', 'otaProgress': 0, 'otaPolicy': 'autoDownload', 'otaScheduleStart': '00:00', 'otaScheduleEnd': '00:00', 'permittingJoin': False, 'backendConnected': True, 'backendConnectionPersistent': True, 'backendOnboardingComplete': True, 'backendRegion': 'us-east-1', 'backendCountryCode': 'CA', 'userConsents': [{'name': 'analytics', 'value': 'enabled'}, {'name': 'diagnostics', 'value': 'enabled'}], 'logLevel': 3, 'coredump': False, 'timezone': 'America/Edmonton', 'nextSunSet': '2024-09-10T02:04:00.000Z', 'nextSunRise': '2024-09-10T13:05:00.000Z', 'homestate': 'home', 'countryCode': 'XZ', 'coordinates': {'latitude': 50.91891891891892, 'longitude': -113.98101273847051, 'accuracy': -1}, 'isOn': False}, 'capabilities': {'canSend': [], 'canReceive': ['customName', 'permittingJoin', 'userConsents', 'logLevel', 'time', 'timezone', 'countryCode', 'coordinates']}, 'deviceSet': [], 'remoteLinks': []}, {'id': 'a0760f78-fb3c-4f0a-a1af-680c19a63aba_1', 'type': 'light', 'deviceType': 'light', 'createdAt': '2024-09-05T13:57:42.000Z', 'isReachable': False, 'lastSeen': '2024-09-09T20:10:26.000Z', 'attributes': {'customName': 'E12 2', 'model': 'TRADFRIbulbE12WSglobeopal470lm', 'manufacturer': 'IKEA of Sweden', 'firmwareVersion': '1.0.012', 'hardwareVersion': '1', 'serialNumber': '1C34F1FFFE962027', 'productCode': 'LED2002G5NA', 'isOn': True, 'startupOnOff': 'startOn', 'lightLevel': 100, 'startUpCurrentLevel': -1, 'colorTemperature': 2702, 'colorTemperatureMin': 4000, 'colorTemperatureMax': 2202, 'startupTemperature': -1, 'colorMode': 'temperature', 'identifyStarted': '2000-01-01T00:00:00.000Z', 'identifyPeriod': 0, 'permittingJoin': False, 'otaStatus': 'upToDate', 'otaState': 'readyToCheck', 'otaProgress': 0, 'otaPolicy': 'autoUpdate', 'otaScheduleStart': '00:00', 'otaScheduleEnd': '00:00'}, 'capabilities': {'canSend': [], 'canReceive': ['customName', 'isOn', 'lightLevel', 'colorTemperature']}, 'room': {'id': 'd034c4b2-0e35-4f6a-bd8e-843c99cf772a', 'name': 'Holding Space', 'color': 'ikea_green_no_65', 'icon': 'rooms_arm_chair'}, 'deviceSet': [], 'remoteLinks': [], 'isHidden': False}, {'id': 'ac311343-30b0-4e6c-aed7-abe2c6b1ac14_1', 'type': 'light', 'deviceType': 'light', 'createdAt': '2024-09-06T23:40:53.000Z', 'isReachable': True, 'lastSeen': '2024-09-09T20:14:31.000Z', 'attributes': {'customName': 'e26-1 color changing', 'model': 'TRADFRI bulb E26 CWS 800lm', 'manufacturer': 'IKEA of Sweden', 'firmwareVersion': '1.0.021', 'hardwareVersion': '1', 'serialNumber': '3410F4FFFEF8074B', 'productCode': 'LED1924G9NA', 'isOn': True, 'startupOnOff': 'startOn', 'lightLevel': 50, 'startUpCurrentLevel': -1, 'colorHue': 118.03892835211468, 'colorSaturation': 0.9330658984558359, 'colorTemperature': 2702, 'colorTemperatureMin': 4000, 'colorTemperatureMax': 2202, 'startupTemperature': -1, 'colorMode': 'color', 'identifyStarted': '2000-01-01T00:00:00.000Z', 'identifyPeriod': 0, 'permittingJoin': False, 'otaStatus': 'upToDate', 'otaState': 'readyToCheck', 'otaProgress': 0, 'otaPolicy': 'autoUpdate', 'otaScheduleStart': '00:00', 'otaScheduleEnd': '00:00'}, 'capabilities': {'canSend': [], 'canReceive': ['customName', 'isOn', 'lightLevel', 'colorTemperature', 'colorHue', 'colorSaturation']}, 'room': {'id': '2a365892-1366-4c4f-85c5-149059d24454', 'name': 'Office', 'color': 'ikea_brown_no_41', 'icon': 'rooms_office_chair'}, 'deviceSet': [], 'remoteLinks': [], 'isHidden': False}, {'id': 'e86a8d8d-e624-48bb-b0ed-436c6ffb3889_1', 'type': 'controller', 'deviceType': 'lightController', 'createdAt': '2024-08-23T04:32:55.000Z', 'isReachable': True, 'lastSeen': '2024-09-09T20:10:27.000Z', 'attributes': {'customName': '', 'model': 'Remote Control N2', 'manufacturer': 'IKEA of Sweden', 'firmwareVersion': '2.4.16', 'hardwareVersion': '1', 'serialNumber': '28DBA7FFFEE479ED', 'productCode': 'E2001', 'batteryPercentage': 100, 'isOn': False, 'lightLevel': 1, 'permittingJoin': False, 'otaStatus': 'upToDate', 'otaState': 'readyToCheck', 'otaProgress': 0, 'otaPolicy': 'autoUpdate', 'otaScheduleStart': '00:00', 'otaScheduleEnd': '00:00', 'circadianPresets': []}, 'capabilities': {'canSend': ['isOn', 'lightLevel'], 'canReceive': ['customName']}, 'room': {'id': '2a365892-1366-4c4f-85c5-149059d24454', 'name': 'Office', 'color': 'ikea_brown_no_41', 'icon': 'rooms_office_chair'}, 'deviceSet': [], 'remoteLinks': [], 'isHidden': False}, {'id': '3246c6e3-a713-4009-94e4-21eae2cfe9d4_1', 'type': 'light', 'deviceType': 'light', 'createdAt': '2024-09-06T23:55:02.000Z', 'isReachable': False, 'lastSeen': '2024-09-09T20:10:26.000Z', 'attributes': {'customName': 'er-23 4 dimmable', 'model': 'TRADFRI bulb E26 WW globe 800lm', 'manufacturer': 'IKEA of Sweden', 'firmwareVersion': '1.0.25', 'hardwareVersion': '1', 'serialNumber': '0CAE5FFFFEA0FC7E', 'productCode': 'LED2103G5NA', 'isOn': False, 'startupOnOff': 'startOn', 'lightLevel': 100, 'startUpCurrentLevel': -1, 'identifyStarted': '2000-01-01T00:00:00.000Z', 'identifyPeriod': 0, 'permittingJoin': False, 'otaStatus': 'upToDate', 'otaState': 'readyToCheck', 'otaProgress': 0, 'otaPolicy': 'autoUpdate', 'otaScheduleStart': '00:00', 'otaScheduleEnd': '00:00'}, 'capabilities': {'canSend': [], 'canReceive': ['customName', 'isOn', 'lightLevel']}, 'room': {'id': 'd034c4b2-0e35-4f6a-bd8e-843c99cf772a', 'name': 'Holding Space', 'color': 'ikea_green_no_65', 'icon': 'rooms_arm_chair'}, 'deviceSet': [], 'remoteLinks': [], 'isHidden': False}, {'id': '64faaa50-7c24-4429-94d6-510d91a1af9f_1', 'type': 'light', 'deviceType': 'light', 'createdAt': '2024-09-06T23:51:21.000Z', 'isReachable': False, 'lastSeen': '2024-09-09T20:10:26.000Z', 'attributes': {'customName': 'er-26 3 dimmable', 'model': 'TRADFRI bulb E26 WW globe 800lm', 'manufacturer': 'IKEA of Sweden', 'firmwareVersion': '1.0.25', 'hardwareVersion': '1', 'serialNumber': 'E8E07EFFFE3F57DD', 'productCode': 'LED2103G5NA', 'isOn': False, 'startupOnOff': 'startOn', 'lightLevel': 100, 'startUpCurrentLevel': -1, 'identifyStarted': '2000-01-01T00:00:00.000Z', 'identifyPeriod': 0, 'permittingJoin': False, 'otaStatus': 'upToDate', 'otaState': 'readyToCheck', 'otaProgress': 0, 'otaPolicy': 'autoUpdate', 'otaScheduleStart': '00:00', 'otaScheduleEnd': '00:00'}, 'capabilities': {'canSend': [], 'canReceive': ['customName', 'isOn', 'lightLevel']}, 'room': {'id': 'd034c4b2-0e35-4f6a-bd8e-843c99cf772a', 'name': 'Holding Space', 'color': 'ikea_green_no_65', 'icon': 'rooms_arm_chair'}, 'deviceSet': [], 'remoteLinks': [], 'isHidden': False}] 2024-09-09 15:41:06.777 INFO (SyncWorker_3) [custom_components.dirigera_platform] -------------- 2024-09-09 15:41:06.777 INFO (SyncWorker_3) [custom_components.dirigera_platform] === END Devices JSON ===

PinInCalgary commented 2 months ago

The IP4 address change may not be related as I see the same "failed to establish a new connection" today, 14 hours later, but the IP4 address for the hub is the same, i.e. 192.168.1.235

PinInCalgary commented 2 months ago

I tried to ping the Ikea hub, 192.168.1.235, from the HomeAssistant terminal and it initially failed, also tried to use nmap, but kept getting an error indicating "network unreachable". Originally my IP shown in the HAOS startup screen was 192.168.1.157. I decided to perform a restart on my VM containing the HAOS and after the restart, the IP was 192.168.1.237 and I was also able to turn the lights on/off using the card in my dashboard. I'm not sure why I lost the network?

PinInCalgary commented 2 months ago

Well, for whatever reason, my Ikea hub has yet again switched IP4 addresses.

I wonder rather than having to "hard code" the IP4 address when configuring the Ikea Integration, would it not be possible to have the integration determine whether an ikea hub is present and if so, either automatically configure the ikea hub, or as for confirmation and then once the Ikea hub has been configured, just track the MAC address and then it doesn't matter if the IP4 address changes

sudo nmap -v -sn 192.168.1.0/24 | grep -B 2 Ikea Nmap scan report for 192.168.1.242 Host is up (0.0010s latency). MAC Address: 68:EC:8A:05:E5:9D (Ikea of Sweden AB)

sanjoyg commented 1 month ago

I suggest an alternate, write a cron to update the hosts to track the ip. In the integration use the hostname/dns name such that there is no dependency.

PinInCalgary commented 1 month ago

Hi Sanjoy, thank you for the suggestion. Will give it a try at some point and post my results here.