Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delay on/off from HA #6

Closed
marc3k18 opened this issue Sep 7, 2022 · 20 comments
Closed

Delay on/off from HA #6

marc3k18 opened this issue Sep 7, 2022 · 20 comments

Comments

@marc3k18
Copy link

marc3k18 commented Sep 7, 2022

When on/off a switch from ha, there is a delay of 30 seconds. Dimmer work instantenly. When on/off from cync app or Google Home, it shows directly the action on ha.

@marc3k18
Copy link
Author

marc3k18 commented Sep 7, 2022

Last version of HA and of the integration

@nikshriv
Copy link
Owner

nikshriv commented Sep 8, 2022

I will need a little more detail. Are you controlling these switches with the room switch entity or with the individual switch entity in HA? Which device(s) are affected? (Please refer to the name of the switch or group in the configuration information that you posted a few months ago). Is the behavior the same when you attempt to turn off the switch, or does it only occur when turning it on?

@nylekyland
Copy link

Hello,

I am also seeing the same issue, a consistent ~30 second delay when turning on & off my lighting group from Home Assistant. I have 4 of the "GE Cync Direct Connect Soft White A19" bulbs (I believe they are these ones), and they are all set to be in a group in the Cync app. In Home Assistant, I am using a simple switch for the group entity to turn all 4 lights on/off at the same time.

Screenshot 2022-09-14 082557

There is a 30 second delay when turning both on and off.

@nikshriv
Copy link
Owner

Is the basement group switch one of the entities created by the integration? You'll need to run the cync_data.py script and post your results. I really have no idea what could be causing this issue at this point. If you want to try to help solve this problem, consider running a packet capture on an Android device while you are using the Cync app to turn your light bulb group on and off and send me the result. You can use an app called PCAPDroid. Set the app to capture packets from the Cync app and save the result as a file, then send me that file. That's how I've been working out the tcp protocol to control these devices.

@nylekyland
Copy link

Is the basement group switch one of the entities created by the integration?

Yes, it's the default entity that was created when setting up through the integration. If it helps, I'm running my Home Assistant through a Docker instance.

I don't have any Android devices so I don't think I can packet capture to check how the calls are being made on a mobile device.

Here is the cbyge_rooms.json output for my configuration (I've omitted some user info):

{
    "data": [
        {
            "device": {
                "subscribe_date": "2022-08-29T11:11:01.526Z",
                "is_active": true,
                "role": 0,
                "last_login": "2022-08-30T01:51:27.374Z",
                "firmware_mod": "1",
                "active_code": "8c0c6769c7a0d6a4b0f20991a900fb20",
                "active_date": "2022-08-29T11:10:59.496Z",
                "groups": "",
                "mcu_version": 28,
                "firmware_version": 10215,
                "source": 1,
                "mac": "786DEB3BBF6B",
                "mcu_mod": "1",
                "product_id": "1607d2bc852800011607d2bc85283801",
                "access_key": 777,
                "name": "786DEB3BBF6B",
                "authorize_code": "1e07d4becc0c9426",
                "id": 247043688,
                "is_online": true,
                "sn": "786DEB3BBF6B"
            },
            "device_info": {
                "error": {
                    "msg": "device property not exists",
                    "code": 4041009
                }
            }
        },
        {
            "device": {
                "subscribe_date": "2022-08-29T11:05:17.724Z",
                "is_active": true,
                "role": 0,
                "last_login": "",
                "active_code": "adaa428c391d75cf4aeedbf1b3a0d547",
                "active_date": "2022-08-29T11:05:17.722Z",
                "groups": "",
                "mcu_version": 0,
                "firmware_version": 0,
                "source": 5,
                "mac": "B90C48C8CF6F",
                "product_id": "1607d2ad150cb2001607d2ad150cb201",
                "access_key": 720118,
                "name": "Basement",
                "authorize_code": "1e07d2c619c77a0c",
                "id": 500113021,
                "is_online": false
            },
            "device_info": {
                "musicShows": [],
                "bulbsArray": [
                    {
                        "occupancyDeactivationPeriod": 0,
                        "lightRingBrightness": 0,
                        "displayName": "Basement Light - Couches",
                        "showOnHome": false,
                        "loadSelection": 0,
                        "lightRingColor": 0,
                        "mac": "786DEB3ABC31",
                        "ambientLightEnable": false,
                        "occupancySensitivity": 0,
                        "firmwareVersion": "1.0.215",
                        "occupancyEnable": false,
                        "followTheSun": false,
                        "deviceType": 128,
                        "fadeOff": 0,
                        "wifiDisconnectIndicatorEnable": false,
                        "switchID": 1156033004,
                        "wifiSsid": "*******",
                        "allowOTAUpdates": true,
                        "deviceID": 500113021001,
                        "fadeOn": 0,
                        "commissionedDate": "2022-08-29T16:07:09Z",
                        "defaultBrightness": 0,
                        "wifiMac": "786DEB3AAB6D",
                        "lightRingMode": 0,
                        "ambientLightSensitivity": 0,
                        "simpleModeEnabled": false,
                        "occupancyTimeoutPeriod": 0
                    },
                    {
                        "occupancyDeactivationPeriod": 0,
                        "lightRingBrightness": 0,
                        "displayName": "Basement Light - Treadmill",
                        "showOnHome": false,
                        "loadSelection": 0,
                        "lightRingColor": 0,
                        "mac": "786DEB3ABE7F",
                        "ambientLightEnable": false,
                        "occupancySensitivity": 0,
                        "firmwareVersion": "1.0.215",
                        "occupancyEnable": false,
                        "followTheSun": false,
                        "deviceType": 128,
                        "fadeOff": 0,
                        "wifiDisconnectIndicatorEnable": false,
                        "switchID": 1156037098,
                        "wifiSsid": "******",
                        "allowOTAUpdates": true,
                        "deviceID": 500113021002,
                        "fadeOn": 0,
                        "commissionedDate": "2022-08-29T16:08:07Z",
                        "defaultBrightness": 0,
                        "wifiMac": "786DEB3AABAF",
                        "lightRingMode": 0,
                        "ambientLightSensitivity": 0,
                        "simpleModeEnabled": false,
                        "occupancyTimeoutPeriod": 0
                    },
                    {
                        "occupancyDeactivationPeriod": 0,
                        "lightRingBrightness": 0,
                        "displayName": "Basement Light - Desk",
                        "showOnHome": false,
                        "loadSelection": 0,
                        "lightRingColor": 0,
                        "mac": "786DEB3BCADE",
                        "ambientLightEnable": false,
                        "occupancySensitivity": 0,
                        "firmwareVersion": "1.0.215",
                        "occupancyEnable": false,
                        "followTheSun": false,
                        "deviceType": 128,
                        "fadeOff": 0,
                        "wifiDisconnectIndicatorEnable": false,
                        "switchID": 247043688,
                        "wifiSsid": "******",
                        "allowOTAUpdates": true,
                        "deviceID": 500113021003,
                        "fadeOn": 0,
                        "commissionedDate": "2022-08-29T16:11:01Z",
                        "defaultBrightness": 0,
                        "wifiMac": "786DEB3BBF6B",
                        "lightRingMode": 0,
                        "ambientLightSensitivity": 0,
                        "simpleModeEnabled": false,
                        "occupancyTimeoutPeriod": 0
                    },
                    {
                        "occupancyDeactivationPeriod": 0,
                        "lightRingBrightness": 0,
                        "displayName": "Basement Light - Lamp",
                        "showOnHome": false,
                        "loadSelection": 0,
                        "lightRingColor": 0,
                        "mac": "786DEB3BC5B1",
                        "ambientLightEnable": false,
                        "occupancySensitivity": 0,
                        "firmwareVersion": "1.0.128",
                        "occupancyEnable": false,
                        "followTheSun": false,
                        "deviceType": 128,
                        "fadeOff": 0,
                        "wifiDisconnectIndicatorEnable": false,
                        "switchID": 247048557,
                        "wifiSsid": "******",
                        "allowOTAUpdates": true,
                        "deviceID": 500113021004,
                        "fadeOn": 0,
                        "commissionedDate": "2022-08-29T21:08:39Z",
                        "defaultBrightness": 0,
                        "wifiMac": "786DEB3BB9ED",
                        "lightRingMode": 0,
                        "ambientLightSensitivity": 0,
                        "simpleModeEnabled": false,
                        "occupancyTimeoutPeriod": 0
                    }
                ],
                "lightShows": [],
                "admin": {
                    "emailAddress": "******",
                    "lastUseDate": "2022-08-29T12:05:17.756Z",
                    "userID": ******,
                    "username": "******",
                    "createDate": "2022-08-29T12:05:17.756Z"
                },
                "lastUseDate": "2022-08-29T12:05:17.762Z",
                "groupsArray": [
                    {
                        "sensorSchedules": [],
                        "displayName": "Basement",
                        "groupID": 32768,
                        "showOnHome": false,
                        "isSubgroup": false,
                        "subgroupIDArray": [
                            32769
                        ],
                        "deviceIDArray": []
                    },
                    {
                        "sensorSchedules": [],
                        "displayName": "Basement Group",
                        "groupID": 32769,
                        "showOnHome": false,
                        "isSubgroup": true,
                        "deviceIDArray": [
                            2,
                            1,
                            3,
                            4
                        ]
                    }
                ],
                "version": "1.0",
                "system": {
                    "app": {
                        "build": "14192",
                        "bundleID": "com.ge.cbyge1",
                        "name": "Cync",
                        "version": "6.8.2"
                    },
                    "ltk": "70830E57C8932CBECFA9852A15BAF087",
                    "timeInfo": {
                        "sunrise": "7:00:00 PM",
                        "sunset": "6:27:49 PM",
                        "timeZone": "******"
                    },
                    "platform": {
                        "os": "iOS",
                        "machine": "N/A",
                        "model": "iPhone",
                        "localizedModel": "iPhone",
                        "version": "16.0"
                    }
                },
                "standaloneDevicesArray": [],
                "geoLocation": {
                    "zipCode": "******",
                    "latitude": ******,
                    "longitude": ******
                },
                "sceneArray": [],
                "schedules": [],
                "createDate": "2022-08-29T12:05:17.762Z"
            }
        },
        {
            "device": {
                "subscribe_date": "2022-08-29T16:08:39.733Z",
                "is_active": true,
                "role": 0,
                "last_login": "2022-08-30T01:04:11.684Z",
                "firmware_mod": "1",
                "active_code": "97970b481bd4acd6d51e1a5de529d661",
                "active_date": "2022-08-29T16:08:37.661Z",
                "groups": "",
                "mcu_version": 28,
                "firmware_version": 10215,
                "source": 1,
                "mac": "786DEB3BB9ED",
                "mcu_mod": "1",
                "product_id": "1607d2bc852800011607d2bc85283801",
                "access_key": 777,
                "name": "786DEB3BB9ED",
                "authorize_code": "1e07d4becc0bbc5f",
                "id": 247048557,
                "is_online": true,
                "sn": "786DEB3BB9ED"
            },
            "device_info": {
                "error": {
                    "msg": "device property not exists",
                    "code": 4041009
                }
            }
        },
        {
            "device": {
                "subscribe_date": "2022-08-29T11:07:09.742Z",
                "is_active": true,
                "role": 0,
                "last_login": "2022-08-30T01:34:29.641Z",
                "firmware_mod": "1",
                "active_code": "e1e582f2ec37865d91556739c07fbd3c",
                "active_date": "2022-08-29T11:07:03.638Z",
                "groups": "",
                "mcu_version": 28,
                "firmware_version": 10215,
                "source": 1,
                "mac": "786DEB3AAB6D",
                "mcu_mod": "1",
                "product_id": "1607d2bc852800011607d2bc85283801",
                "access_key": 777,
                "name": "786DEB3AAB6D",
                "authorize_code": "1e07d4bec66e9a4e",
                "id": 1156033004,
                "is_online": true,
                "sn": "786DEB3AAB6D"
            },
            "device_info": {
                "error": {
                    "msg": "device property not exists",
                    "code": 4041009
                }
            }
        },
        {
            "device": {
                "subscribe_date": "2022-08-29T11:08:07.370Z",
                "is_active": true,
                "role": 0,
                "last_login": "2022-08-30T21:17:04.733Z",
                "firmware_mod": "1",
                "active_code": "456dd1581710cbd318b1e7eb7f2eb13e",
                "active_date": "2022-08-29T11:07:54.821Z",
                "groups": "",
                "mcu_version": 28,
                "firmware_version": 10215,
                "source": 1,
                "mac": "786DEB3AABAF",
                "mcu_mod": "1",
                "product_id": "1607d2bc852800011607d2bc85283801",
                "access_key": 777,
                "name": "786DEB3AABAF",
                "authorize_code": "1e07d2bec66f9e2c",
                "id": 1156037098,
                "is_online": true,
                "sn": "786DEB3AABAF"
            },
            "device_info": {
                "error": {
                    "msg": "device property not exists",
                    "code": 4041009
                }
            }
        }
    ]
}

@nikshriv
Copy link
Owner

Just released a big update. Pretty sure I have plugs and On/Off bulbs and switches functioning as intended. Delete your old installation and download the updated version and reinstall. Let me know if this works for you.

@nylekyland
Copy link

I removed everything from HACS and redownloaded the repo and readded the integration, but still the same result. On/off requests still take roughly 30 seconds to fire. Adjusting the brightness when the lights are on is instant though.

@nikshriv
Copy link
Owner

I removed everything from HACS and redownloaded the repo and readded the integration, but still the same result. On/off requests still take roughly 30 seconds to fire. Adjusting the brightness when the lights are on is instant though.

I believe the bulbs you have are an older generation and they seem to use a slightly different set of command packets than the ones I have, in particular when turning on and off. All of my bulbs, switches, and plugs now work as expected. I thought I had it worked out, but clearly still having some issues.

If you're unable to do a packet capture, one option would be to allow me to do it remotely. If this isn't too invasive for you, you could open a dummy cync account and add one of the troublesome bulbs to that account. You would have to share the username and password with me, but that would allow me to run a packet capture on the bulb and see what's going on. If you're okay with trying this, let me know. If not, no worries.

@marc3k18
Copy link
Author

marc3k18 commented Sep 25, 2022 via email

@nikshriv
Copy link
Owner

The problem is also present for me after all the update for all my switch. Le dim. 25 sept. 2022, 6 h 14 p.m., nikshriv @.> a écrit :

I removed everything from HACS and redownloaded the repo and readded the integration, but still the same result. On/off requests still take roughly 30 seconds to fire. Adjusting the brightness when the lights are on is instant though. I believe the bulbs you have are an older generation and they seem to use a slightly different set of command packets than the ones I have, in particular when turning on and off. All of my bulbs, switches, and plugs now work as expected. I thought I had it worked out, but clearly still having some issues. If you're unable to do a packet capture, one option would be to allow me to do it remotely. If this isn't too invasive for you, you could open a dummy cync account and add one of the troublesome bulbs to that account. You would have to share the username and password with me, but that would allow me to run a packet capture on the bulb and see what's going on. If you're okay with trying this, let me know. If not, no worries. — Reply to this email directly, view it on GitHub <#6 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXKJDQCP3474QNSK5P2MWNLWADFFNANCNFSM6AAAAAAQG7TOVU . You are receiving this because you authored the thread.Message ID: @.
>

I've been working with a new set of bulbs this weekend, and it seems that the strength of the WiFi connection of these bulbs (and probably switches) is affecting their ability to respond to commands. Currently, I send commands directly to switches and bulbs if they are WiFi enabled. I suspect that if the WiFi connection is poor, the devices fail to respond to commands and hence the behavior you are seeing. I'm going to implement steps to check for a response to commands, and if no response within a second, try another WiFi connected device.

@nylekyland
Copy link

nylekyland commented Sep 27, 2022

I ran a traffic capture using the Cync app on iOS + Fiddler on Windows. I was able to see the JSON for the device information, similar to how the cync_data.py script generates. However, turning the lights on/off and adjusting the brightness with the app did not generate any requests for me in Fiddler.

@nikshriv
Copy link
Owner

I think I have finally figured out this bug. Should be working now. Please try downloading again. There was a problem with the on/off command that I didn't see until yesterday.

Another issue that remains is Wi-Fi connectivity of the devices. I will be updating soon to check connectivity of Wi-Fi devices before sending commands. I think that was another issue for some users that was causing commands not to go through.

@marc3k18
Copy link
Author

marc3k18 commented Sep 30, 2022 via email

@nylekyland
Copy link

@nikshriv I removed the existing repo & integration, and redownloaded and set up the new configuration. Unfortunately, requests now are not working at all. I have some errors in the Home Assistant Logs:

Logger: custom_components.cync_lights.cync_hub
Source: custom_components/cync_lights/cync_hub.py:56
Integration: Cync Lights ([documentation](https://github.com/nikshriv/cync_lights))
First occurred: 8:35:27 AM (9 occurrences)
Last logged: 8:39:30 AM

Connection to Cync server reset, restarting in 15 seconds
Logger: homeassistant
Source: custom_components/cync_lights/cync_hub.py:157
Integration: Cync Lights ([documentation](https://github.com/nikshriv/cync_lights))
First occurred: 8:38:11 AM (1 occurrences)
Last logged: 8:38:11 AM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/config/custom_components/cync_lights/cync_hub.py", line 157, in _maintain_connection
    await self.writer.drain()
  File "/usr/local/lib/python3.10/asyncio/streams.py", line 372, in drain
    await self._protocol._drain_helper()
  File "/usr/local/lib/python3.10/asyncio/streams.py", line 171, in _drain_helper
    raise ConnectionResetError('Connection lost')
ConnectionResetError: Connection lost
Logger: aiohttp.server
Source: /usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py:405
First occurred: 8:39:35 AM (1 occurrences)
Last logged: 8:39:35 AM

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 334, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
  File "aiohttp/_http_parser.pyx", line 551, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: 400, message="Bad status line 'Invalid method encountered'"

@nikshriv
Copy link
Owner

nikshriv commented Oct 5, 2022

It looks like your connection to the Cync server was lost. Not sure why, but sometimes the server closes the connection. The integration will automatically reconnect after 15 seconds if that occurs. As for you bulbs not responding, that is probably due to your connection being lost.

Alternatively, in testing, I have found that most of these Cync bulbs are very flaky when it comes to Wi-Fi. Even though they report being connected, they often don't respond to any commands, even with the Cync app. I have a new update that I'll release in the next day or two that periodically checks for connected devices and only sends commands to them. It also will wait and check if the command resulted in action and will then repeat the command if necessary. Hopefully that will fix your issues.

@nikshriv
Copy link
Owner

nikshriv commented Oct 7, 2022

@nikshriv I removed the existing repo & integration, and redownloaded and set up the new configuration. Unfortunately, requests now are not working at all. I have some errors in the Home Assistant Logs:

Logger: custom_components.cync_lights.cync_hub
Source: custom_components/cync_lights/cync_hub.py:56
Integration: Cync Lights ([documentation](https://github.com/nikshriv/cync_lights))
First occurred: 8:35:27 AM (9 occurrences)
Last logged: 8:39:30 AM

Connection to Cync server reset, restarting in 15 seconds
Logger: homeassistant
Source: custom_components/cync_lights/cync_hub.py:157
Integration: Cync Lights ([documentation](https://github.com/nikshriv/cync_lights))
First occurred: 8:38:11 AM (1 occurrences)
Last logged: 8:38:11 AM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/config/custom_components/cync_lights/cync_hub.py", line 157, in _maintain_connection
    await self.writer.drain()
  File "/usr/local/lib/python3.10/asyncio/streams.py", line 372, in drain
    await self._protocol._drain_helper()
  File "/usr/local/lib/python3.10/asyncio/streams.py", line 171, in _drain_helper
    raise ConnectionResetError('Connection lost')
ConnectionResetError: Connection lost
Logger: aiohttp.server
Source: /usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py:405
First occurred: 8:39:35 AM (1 occurrences)
Last logged: 8:39:35 AM

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 334, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
  File "aiohttp/_http_parser.pyx", line 551, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: 400, message="Bad status line 'Invalid method encountered'"

Just updated again. The new update checks to make sure that your Wifi devices are actually connected to the Cync server and respond to commands. If not, commands are routed to other devices that are connected. Response to commands is also checked and if no response, the commands are repeated. Hopefully this will make the integration more reliable. Let me know if this works for you.

@nylekyland
Copy link

@nikshriv I just got the latest version and everything is working perfectly for me now. Turning on/off light requests take effect immediately. Thank you so much for fixing this!

@nikshriv
Copy link
Owner

nikshriv commented Oct 7, 2022

That's awesome! It has taken a lot of tries because these Cync devices are very quirky! Glad it's finally working for you

@marc3k18
Copy link
Author

marc3k18 commented Oct 11, 2022 via email

@ac0mputerguru
Copy link

The only problem I had was when I changed my Cync password. I had to reinstall your integration to get back to the user name/password option. Other than that, works with two bulbs and a switch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants