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

lag spikes in hue sync. filled with errors when enabling music #141

Closed
Cyanogenbot opened this issue Mar 21, 2021 · 8 comments
Closed

lag spikes in hue sync. filled with errors when enabling music #141

Cyanogenbot opened this issue Mar 21, 2021 · 8 comments
Labels
bug Something isn't working

Comments

@Cyanogenbot
Copy link
Contributor

Cyanogenbot commented Mar 21, 2021

    if not username or not await cls.config.async_get_user(username):
  File "/app/emulated_hue/config.py", line 286, in async_get_user
    await self.async_set_storage_value("users", username, user_data)
  File "/app/emulated_hue/config.py", line 245, in async_set_storage_value
    await async_save_json(self.get_path(CONFIG_FILE), self._config)
  File "/app/emulated_hue/utils.py", line 121, in async_save_json
    return await loop.run_in_executor(None, save_json, filename, data)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/app/emulated_hue/utils.py", line 128, in save_json
    os.replace(filename, safe_copy)
FileNotFoundError: [Errno 2] No such file or directory: '/config/hass-emulated-hue/emulated_hue.json' -> '/config/hass-emulated-hue/emulated_hue.json.backup'
2021-03-21 02:24:15,632 ERROR aiohttp.server -- Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
    resp = await self._request_handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle
    resp = await handler(request)
  File "/app/emulated_hue/api.py", line 90, in wrapped_func
    return await func(cls, request)
  File "/app/emulated_hue/api.py", line 448, in async_get_bridge_config
    if not username or not await self.config.async_get_user(username):
  File "/app/emulated_hue/config.py", line 286, in async_get_user
    await self.async_set_storage_value("users", username, user_data)
  File "/app/emulated_hue/config.py", line 245, in async_set_storage_value
    await async_save_json(self.get_path(CONFIG_FILE), self._config)
  File "/app/emulated_hue/utils.py", line 121, in async_save_json
    return await loop.run_in_executor(None, save_json, filename, data)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/app/emulated_hue/utils.py", line 128, in save_json
    os.replace(filename, safe_copy)
FileNotFoundError: [Errno 2] No such file or directory: '/config/hass-emulated-hue/emulated_hue.json' -> '/config/hass-emulated-hue/emulated_hue.json.backup'
2021-03-21 02:25:40,902 ERROR aiohttp.server -- Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
    resp = await self._request_handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle
    resp = await handler(request)
  File "/app/emulated_hue/api.py", line 80, in wrapped_func
    if not username or not await cls.config.async_get_user(username):
  File "/app/emulated_hue/config.py", line 286, in async_get_user
    await self.async_set_storage_value("users", username, user_data)
  File "/app/emulated_hue/config.py", line 245, in async_set_storage_value
    await async_save_json(self.get_path(CONFIG_FILE), self._config)
  File "/app/emulated_hue/utils.py", line 121, in async_save_json
    return await loop.run_in_executor(None, save_json, filename, data)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/app/emulated_hue/utils.py", line 128, in save_json
    os.replace(filename, safe_copy)
FileNotFoundError: [Errno 2] No such file or directory: '/config/hass-emulated-hue/emulated_hue.json' -> '/config/hass-emulated-hue/emulated_hue.json.backup'
2021-03-21 02:26:01,241 ERROR aiohttp.server -- Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
    resp = await self._request_handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle
    resp = await handler(request)
  File "/app/emulated_hue/api.py", line 90, in wrapped_func
    return await func(cls, request)
  File "/app/emulated_hue/api.py", line 448, in async_get_bridge_config
    if not username or not await self.config.async_get_user(username):
  File "/app/emulated_hue/config.py", line 286, in async_get_user
    await self.async_set_storage_value("users", username, user_data)
  File "/app/emulated_hue/config.py", line 245, in async_set_storage_value
    await async_save_json(self.get_path(CONFIG_FILE), self._config)
  File "/app/emulated_hue/utils.py", line 121, in async_save_json
    return await loop.run_in_executor(None, save_json, filename, data)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/app/emulated_hue/utils.py", line 128, in save_json
    os.replace(filename, safe_copy)
FileNotFoundError: [Errno 2] No such file or directory: '/config/hass-emulated-hue/emulated_hue.json' -> '/config/hass-emulated-hue/emulated_hue.json.backup'
2021-03-21 02:30:17,789 INFO  emulated_hue.api -- Stop Entertainment mode for group 4 - params: {'on': False}
2021-03-21 02:30:17,993 INFO  emulated_hue.api -- Stop Entertainment mode for group 4 - params: {'on': True}
2021-03-21 02:30:19,155 INFO  emulated_hue.api -- Stop Entertainment mode for group 4 - params: {'on': False}
2021-03-21 02:30:19,371 INFO  emulated_hue.api -- Stop Entertainment mode for group 4 - params: {'on': True}
2021-03-21 02:30:32,040 INFO  emulated_hue.entertainment -- Start HUE Entertainment Service on UDP port 2100.
2021-03-21 02:37:49,905 ERROR aiohttp.server -- Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
    resp = await self._request_handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle
    resp = await handler(request)
  File "/app/emulated_hue/api.py", line 80, in wrapped_func
    if not username or not await cls.config.async_get_user(username):
  File "/app/emulated_hue/config.py", line 286, in async_get_user
    await self.async_set_storage_value("users", username, user_data)
  File "/app/emulated_hue/config.py", line 245, in async_set_storage_value
    await async_save_json(self.get_path(CONFIG_FILE), self._config)
  File "/app/emulated_hue/utils.py", line 121, in async_save_json
    return await loop.run_in_executor(None, save_json, filename, data)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/app/emulated_hue/utils.py", line 128, in save_json
    os.replace(filename, safe_copy)
FileNotFoundError: [Errno 2] No such file or directory: '/config/hass-emulated-hue/emulated_hue.json' -> '/config/hass-emulated-hue/emulated_hue.json.backup'
2021-03-21 02:37:54,689 INFO  emulated_hue.api -- Stop Entertainment mode for group 4 - params: {'stream': {'active': False}}
2021-03-21 02:37:54,690 INFO  emulated_hue.entertainment -- HUE Entertainment Service stopped.
2021-03-21 02:37:55,839 INFO  emulated_hue.entertainment -- Start HUE Entertainment Service on UDP port 2100.

Describe the bug
jittery lag, lamp takes sometimes long to change and sometimes its instant. tried changing the throttle without any impact

Expected behavior
smoother transitions

Hardware Info:

  • laptop over wifi
  • OS latest hassio 4.12 etc
  • Hardware PI 3b, connected with Lan cable
  • cc2652rb stick
  • 2 Hue playbars connected parallel

Things ill have to test to confirm:

  • Internet speed seems fine but could limit possibly
@Cyanogenbot Cyanogenbot added the bug Something isn't working label Mar 21, 2021
@alexyao2015
Copy link
Member

If you're using hardware that has api rate limits, entertainment will not work very smoothly. Its suggested to use esphome for now as thats the only real supported device for entertainment. There are plans to further augment esphome as well. See #85.

The errors you are seeing do not affect the core issue here, but I'll look into fixing it.

@Cyanogenbot
Copy link
Contributor Author

Cyanogenbot commented Mar 23, 2021

cool thanks for the heads up, after migrating to an old laptop, using ethernet and setting the throttle to 100 hue play bars sync up perfectly. tried around 100 seems to be the sweet spot so that other know haha

errors seem to be related to the hassio build for rpi 3b.

@alexyao2015
Copy link
Member

The raspberry pi simply isn't fast enough to handle the massive influx of packets, so it will lag. It's not recommended to run home assistant on it either because it's too slow.

@Cyanogenbot
Copy link
Contributor Author

Cyanogenbot commented Mar 29, 2021

you are right, my alternate laptop worked fine but I'm getting similar aiohttp problems namely:
all on 0.26. Bridge cant be found anymore either

2021-03-29 20:48:03,879 ERROR aiohttp.server -- Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
resp = await self._request_handler(request)
File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle
resp = await handler(request)
File "/app/emulated_hue/api.py", line 90, in wrapped_func
return await func(cls, request)
File "/app/emulated_hue/api.py", line 492, in get_full_state
"scenes": await self.async_scene_to_full_state(),
File "/app/emulated_hue/api.py", line 479, in async_scene_to_full_state
scene_data["lights"] = groups[scenes_group]["lights"]
KeyError: '0'

@alexyao2015
Copy link
Member

Can you post your config? Seems like you may have a corrupted config.

@Cyanogenbot
Copy link
Contributor Author

Cyanogenbot commented Mar 29, 2021

    "bridge_config": {
        "swupdate2": {
            "checkforupdate": true
        }
    },
    "groups": {
        "1": {
            "action": {
                "on": false
            },
            "area_id": "living_room",
            "class": "Other",
            "enabled": true,
            "lights": [],
            "name": "",
            "sensors": [],
            "state": {
                "all_on": true,
                "any_on": false
            },
            "type": "Room"
        },
        "2": {
            "action": {
                "on": false
            },
            "area_id": "kitchen",
            "class": "Other",
            "enabled": true,
            "lights": [],
            "name": "",
            "sensors": [],
            "state": {
                "all_on": true,
                "any_on": false
            },
            "type": "Room"
        },
        "3": {
            "action": {
                "on": false
            },
            "area_id": "bedroom",
            "class": "Other",
            "enabled": true,
            "lights": [],
            "name": "",
            "sensors": [],
            "state": {
                "all_on": true,
                "any_on": true
            },
            "type": "Room"
        },
        "4": {
            "class": "TV",
            "lights": [
                "1",
                "2"
            ],
            "locations": {
                "1": [
                    -0.643386,
                    0.787302,
                    0
                ],
                "2": [
                    0.645503,
                    0.787302,
                    0
                ]
            },
            "name": "Entertainmentruimte 1",
            "stream": {
                "active": false,
                "owner": "BEEb95d8C9AeDbe6CCbAD1E5eecea0eD327aCbCE",
                "proxymode": "auto",
                "proxynode": "/bridge"
            },
            "type": "Entertainment"
        }
    },
    "lights": {
        "1": {
            "config": {
                "archetype": "sultanbulb",
                "direction": "omnidirectional",
                "function": "mixed",
                "startup": {
                    "configured": true,
                    "mode": "safety"
                }
            },
            "enabled": true,
            "entity_id": "light.0x0017880109869fdd",
            "name": "",
            "throttle": 100,
            "uniqueid": "00:0b:b5:19:4e:87:bb:b8-80"
        },
        "2": {
            "config": {
                "archetype": "sultanbulb",
                "direction": "omnidirectional",
                "function": "mixed",
                "startup": {
                    "configured": true,
                    "mode": "safety"
                }
            },
            "enabled": true,
            "entity_id": "light.0x0017880109869fd9",
            "name": "",
            "throttle": 100,
            "uniqueid": "00:59:a4:d3:56:3e:c8:99-05"
        }
    },
    "scenes": {
        "1": {
            "appdata": {
                "data": "FUz5X_r00_d03",
                "version": 1
            },
            "group": "0",
            "lightstates": {
                "1": {
                    "bri": 254,
                    "ct": 233,
                    "on": true
                },
                "2": {
                    "bri": 254,
                    "ct": 233,
                    "on": true
                }
            },
            "name": "Concentreren",
            "recycle": true,
            "type": "GroupScene"
        }
    },
    "users": {
        "5B8fb076aabAE56c5012c5208B5C7371Ab1F7fEE": {
            "clientkey": "BFB1ED5BCEED3B5B6BDCEAB6ABA1CA99",
            "create date": "2021-03-23T03:04:22",
            "last use date": "2021-03-23T03:08:16",
            "name": "Hue Essentials#Pixel 5",
            "username": "5B8fb076aabAE56c5012c5208B5C7371Ab1F7fEE"
        },
        "BEEb95d8C9AeDbe6CCbAD1E5eecea0eD327aCbCE": {
            "clientkey": "37F4FE09BFBF945570BF2BD4C12BDFBB",
            "create date": "2021-03-23T02:38:14",
            "last use date": "2021-03-29T23:16:48",
            "name": "Hue Sync#Unknown",
            "username": "BEEb95d8C9AeDbe6CCbAD1E5eecea0eD327aCbCE"
        },
        "F3BffFF97568F7cE9Ad2A66bAfd6aBCfBea9F76b": {
            "clientkey": "7AECDBA5CFB6DACAA4C803D3BBB146AA",
            "create date": "2021-03-24T15:04:35",
            "last use date": "2021-03-24T16:49:23",
            "name": "Hue Sync#20192899",
            "username": "F3BffFF97568F7cE9Ad2A66bAfd6aBCfBea9F76b"
        },
        "bAbB2dA5C1c73963EAe45600D7EAc3DC70BbdeAd": {
            "clientkey": "E9797FBAD85BDB4E66FFA41C94EA0644",
            "create date": "2021-03-23T02:39:41",
            "last use date": "2021-03-29T20:47:49",
            "name": "Hue 3#Google Pixel 5",
            "username": "bAbB2dA5C1c73963EAe45600D7EAc3DC70BbdeAd"
        }
    }
}```

@alexyao2015
Copy link
Member

Ok this is related to #62. In your case, you created a scene using some app that used group 0. Would suggest avoiding that app for now. You can either delete your config entirely or simply delete scene 1 from the config.

@alexyao2015
Copy link
Member

@Cyanogenbot I've committed a change to group-0-fix which should resolve the group 0 issue you were having previously. Please give it a try and see if things are working now. You can try this change by using the dev addon and inputting group-0-fix in tag_commit_or_branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants