Closed tylerwmarrs closed 2 years ago
I think that this is related to the websockets version. Not sure how you're setup, but if you're using v10, you're probably experiencing this issue: https://github.com/aaugustin/websockets/issues/1065. I think that either moving to 9.1 or 10.1 should hopefully resolve what you're seeing.
Thanks for the reference. I am using 10.1. You can see this in the user agent line.
User-Agent: Python/3.9 websockets/10.1
I'll play around with the compression setting that the post you linked to suggests. Once I have a solution, I'll try to provide a PR. Cheers
Ha, sorry didn't notice that! I'm still using 9.1 in my development environment, perhaps 10.1 isn't quite fixed for this use case? I know HA also locked to 9.1, but not sure that has changed recently. Thanks for looking into it.
I tested with 9.1 and still have the same issue. Do you have any other ideas on what to try?
➜ python websocket_example.py
2022-02-05 10:04:33,246 DEBUG Using selector: EpollSelector
/home/tyler/src/gehome/examples/websocket_example.py:74: DeprecationWarning: The object should be created within an async function
session = aiohttp.ClientSession()
2022-02-05 10:04:33,247 DEBUG Getting OAuth2 token
2022-02-05 10:04:33,252 DEBUG Client changed state: GeClientState.INITIALIZING to GeClientState.AUTHORIZING_OAUTH
2022-02-05 10:04:35,406 DEBUG Getting WS credentials
2022-02-05 10:04:35,408 DEBUG Client changed state: GeClientState.AUTHORIZING_OAUTH to GeClientState.AUTHORIZING_CLIENT
2022-02-05 10:04:36,015 INFO Starting GE Appliances client
2022-02-05 10:04:36,043 DEBUG Client changed state: GeClientState.AUTHORIZING_CLIENT to GeClientState.CONNECTING
2022-02-05 10:04:36,158 DEBUG client - state = CONNECTING
2022-02-05 10:04:36,303 DEBUG client - event = connection_made(<asyncio.sslproto._SSLProtocolTransport object at 0x7fa1683ad4c0>)
2022-02-05 10:04:36,304 DEBUG client > GET /?access_token=ue1cpgcmnax3oitxgfg2128gux8d0ire HTTP/1.1
2022-02-05 10:04:36,305 DEBUG client > Headers([('Host', 'ws-us-east-1.brillion.geappliances.com'), ('Upgrade', 'websocket'), ('Connection', 'Upgrade'), ('Sec-WebSocket-Key', '6EAmcCKCctSNn5QcpgQhUw=='), ('Sec-WebSocket-Version', '13'), ('User-Agent', 'Python/3.9 websockets/9.1')])
2022-02-05 10:04:36,635 DEBUG client - event = data_received(<166 bytes>)
2022-02-05 10:04:36,635 DEBUG client < HTTP/1.1 101 Switching Protocols
2022-02-05 10:04:36,635 DEBUG client < Headers([('Date', 'Sat, 05 Feb 2022 16:03:44 GMT'), ('Connection', 'upgrade'), ('upgrade', 'websocket'), ('sec-websocket-accept', 'h/Evfu1vdk8woNYX+DGJSWRdUeg=')])
2022-02-05 10:04:36,636 DEBUG client - state = OPEN
2022-02-05 10:04:36,636 DEBUG client > Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"kind": "websocket#subscribe", "action": "subscribe", "resources": ["/appliance/*/erd/*"]}', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:04:36,637 DEBUG client > Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"kind": "websocket#api", "action": "api", "host": "api.brillion.geappliances.com", "method": "GET", "path": "/v1/appliance", "id": "List-appliances"}', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:04:36,637 DEBUG Client changed state: GeClientState.CONNECTING to GeClientState.CONNECTED
2022-02-05 10:04:36,754 DEBUG client - event = data_received(<47 bytes>)
2022-02-05 10:04:36,755 DEBUG client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"kind":"websocket#subscribe","success":true}', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:04:36,897 DEBUG client - event = data_received(<45 bytes>)
2022-02-05 10:04:36,897 DEBUG client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"kind":"websocket#connect","success":true}', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:04:36,910 DEBUG client - event = data_received(<246 bytes>)
2022-02-05 10:04:36,910 DEBUG client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"kind":"websocket#api","id":"List-appliances","request":{"host":"api.brillion.geappliances.com","method":"GET","path":"/v1/appliance"},"success":true,"code":200,"body":{"kind":"appliance#applianceList","userId":"seyu0ek6oaw2843","items":[]}}', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:04:37,146 DEBUG client - event = data_received(<99 bytes>)
2022-02-05 10:04:37,147 DEBUG client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"resource":"/appliance/*/erd/*","kind":"websocket#subscription","success":true,"change":"ADDED"}', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:04:56,645 DEBUG client > Frame(fin=True, opcode=<Opcode.PING: 9>, data=b'$\xceRu', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:04:56,704 DEBUG client - event = data_received(<6 bytes>)
2022-02-05 10:04:56,705 DEBUG client < Frame(fin=True, opcode=<Opcode.PONG: 10>, data=b'$\xceRu', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:04:56,705 DEBUG client - received solicited pong: 24ce5275
2022-02-05 10:05:06,639 DEBUG Sending keepalive ping
2022-02-05 10:05:06,640 DEBUG client > Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"kind": "websocket#ping", "id": "keepalive-ping", "action": "ping"}', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:05:06,725 DEBUG client - event = data_received(<49 bytes>)
2022-02-05 10:05:06,725 DEBUG client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"kind":"websocket#pong","id":"keepalive-ping"}', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:05:16,713 DEBUG client > Frame(fin=True, opcode=<Opcode.PING: 9>, data=b'\x8eq\x84X', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:05:16,776 DEBUG client - event = data_received(<6 bytes>)
2022-02-05 10:05:16,776 DEBUG client < Frame(fin=True, opcode=<Opcode.PONG: 10>, data=b'\x8eq\x84X', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:05:16,776 DEBUG client - received solicited pong: 8e718458
2022-02-05 10:05:36,661 DEBUG Sending keepalive ping
2022-02-05 10:05:36,661 DEBUG client > Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"kind": "websocket#ping", "id": "keepalive-ping", "action": "ping"}', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:05:36,750 DEBUG client - event = data_received(<49 bytes>)
2022-02-05 10:05:36,750 DEBUG client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"kind":"websocket#pong","id":"keepalive-ping"}', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:05:36,778 DEBUG client > Frame(fin=True, opcode=<Opcode.PING: 9>, data=b'\x0b\xb1\x19\xbe', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:05:36,842 DEBUG client - event = data_received(<6 bytes>)
2022-02-05 10:05:36,843 DEBUG client < Frame(fin=True, opcode=<Opcode.PONG: 10>, data=b'\x0b\xb1\x19\xbe', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:05:36,843 DEBUG client - received solicited pong: 0bb119be
2022-02-05 10:05:56,863 DEBUG client > Frame(fin=True, opcode=<Opcode.PING: 9>, data=b'~\xab\x05\xab', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:05:56,926 DEBUG client - event = data_received(<6 bytes>)
2022-02-05 10:05:56,926 DEBUG client < Frame(fin=True, opcode=<Opcode.PONG: 10>, data=b'~\xab\x05\xab', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:05:56,926 DEBUG client - received solicited pong: 7eab05ab
2022-02-05 10:06:06,663 DEBUG Sending keepalive ping
2022-02-05 10:06:06,663 DEBUG client > Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"kind": "websocket#ping", "id": "keepalive-ping", "action": "ping"}', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:06:06,740 DEBUG client - event = data_received(<49 bytes>)
2022-02-05 10:06:06,740 DEBUG client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"kind":"websocket#pong","id":"keepalive-ping"}', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:06:16,936 DEBUG client > Frame(fin=True, opcode=<Opcode.PING: 9>, data=b'\x06(\xad\xcc', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:06:17,000 DEBUG client - event = data_received(<6 bytes>)
2022-02-05 10:06:17,000 DEBUG client < Frame(fin=True, opcode=<Opcode.PONG: 10>, data=b'\x06(\xad\xcc', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:06:17,000 DEBUG client - received solicited pong: 0628adcc
2022-02-05 10:06:36,666 DEBUG Sending keepalive ping
2022-02-05 10:06:36,667 DEBUG client > Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"kind": "websocket#ping", "id": "keepalive-ping", "action": "ping"}', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:06:36,750 DEBUG client - event = data_received(<49 bytes>)
2022-02-05 10:06:36,750 DEBUG client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"kind":"websocket#pong","id":"keepalive-ping"}', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:06:37,001 DEBUG client > Frame(fin=True, opcode=<Opcode.PING: 9>, data=b'\xaa\x83\x82s', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:06:37,060 DEBUG client - event = data_received(<6 bytes>)
2022-02-05 10:06:37,061 DEBUG client < Frame(fin=True, opcode=<Opcode.PONG: 10>, data=b'\xaa\x83\x82s', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:06:37,061 DEBUG client - received solicited pong: aa838273
2022-02-05 10:06:57,070 DEBUG client > Frame(fin=True, opcode=<Opcode.PING: 9>, data=b'3}\xc6\xfc', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:06:57,132 DEBUG client - event = data_received(<6 bytes>)
2022-02-05 10:06:57,132 DEBUG client < Frame(fin=True, opcode=<Opcode.PONG: 10>, data=b'3}\xc6\xfc', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:06:57,133 DEBUG client - received solicited pong: 337dc6fc
2022-02-05 10:07:06,676 DEBUG Sending keepalive ping
2022-02-05 10:07:06,677 DEBUG client > Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"kind": "websocket#ping", "id": "keepalive-ping", "action": "ping"}', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:07:06,757 DEBUG client - event = data_received(<49 bytes>)
2022-02-05 10:07:06,757 DEBUG client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"kind":"websocket#pong","id":"keepalive-ping"}', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:07:17,144 DEBUG client > Frame(fin=True, opcode=<Opcode.PING: 9>, data=b'\xe4\xc8k\x1c', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:07:17,217 DEBUG client - event = data_received(<6 bytes>)
2022-02-05 10:07:17,218 DEBUG client < Frame(fin=True, opcode=<Opcode.PONG: 10>, data=b'\xe4\xc8k\x1c', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:07:17,218 DEBUG client - received solicited pong: e4c86b1c
2022-02-05 10:07:36,698 DEBUG Sending keepalive ping
2022-02-05 10:07:36,698 DEBUG client > Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"kind": "websocket#ping", "id": "keepalive-ping", "action": "ping"}', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:07:36,775 DEBUG client - event = data_received(<49 bytes>)
2022-02-05 10:07:36,775 DEBUG client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"kind":"websocket#pong","id":"keepalive-ping"}', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:07:37,219 DEBUG client > Frame(fin=True, opcode=<Opcode.PING: 9>, data=b'\x9d \xd6\xa1', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:07:37,285 DEBUG client - event = data_received(<6 bytes>)
2022-02-05 10:07:37,285 DEBUG client < Frame(fin=True, opcode=<Opcode.PONG: 10>, data=b'\x9d \xd6\xa1', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:07:37,285 DEBUG client - received solicited pong: 9d20d6a1
2022-02-05 10:07:57,286 DEBUG client > Frame(fin=True, opcode=<Opcode.PING: 9>, data=b'\xcf\x9fU\x19', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:07:57,352 DEBUG client - event = data_received(<6 bytes>)
2022-02-05 10:07:57,352 DEBUG client < Frame(fin=True, opcode=<Opcode.PONG: 10>, data=b'\xcf\x9fU\x19', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:07:57,352 DEBUG client - received solicited pong: cf9f5519
2022-02-05 10:08:06,709 DEBUG Sending keepalive ping
2022-02-05 10:08:06,710 DEBUG client > Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"kind": "websocket#ping", "id": "keepalive-ping", "action": "ping"}', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:08:06,788 DEBUG client - event = data_received(<49 bytes>)
2022-02-05 10:08:06,788 DEBUG client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"kind":"websocket#pong","id":"keepalive-ping"}', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:08:17,363 DEBUG client > Frame(fin=True, opcode=<Opcode.PING: 9>, data=b'Ry\xbay', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:08:17,424 DEBUG client - event = data_received(<6 bytes>)
2022-02-05 10:08:17,424 DEBUG client < Frame(fin=True, opcode=<Opcode.PONG: 10>, data=b'Ry\xbay', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:08:17,424 DEBUG client - received solicited pong: 5279ba79
2022-02-05 10:08:36,728 DEBUG Sending keepalive ping
2022-02-05 10:08:36,728 DEBUG client > Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"kind": "websocket#ping", "id": "keepalive-ping", "action": "ping"}', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:08:36,804 DEBUG client - event = data_received(<49 bytes>)
2022-02-05 10:08:36,805 DEBUG client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"kind":"websocket#pong","id":"keepalive-ping"}', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:08:37,426 DEBUG client > Frame(fin=True, opcode=<Opcode.PING: 9>, data=b'\x8e#2\xaa', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:08:37,487 DEBUG client - event = data_received(<6 bytes>)
2022-02-05 10:08:37,487 DEBUG client < Frame(fin=True, opcode=<Opcode.PONG: 10>, data=b'\x8e#2\xaa', rsv1=False, rsv2=False, rsv3=False)
2022-02-05 10:08:37,487 DEBUG client - received solicited pong: 8e2332aa
I figured it out. My wife set up the appliances again with her account. XD I can confirm that websockets 9.1 and 10.1 both work as expected. Cheers
For anyone else that comes across this issue: Smarthq removes appliances set up on an account and exist only in the last account to register the devices. The only way to share devices is by sharing credentials.
I am trying to integrate with Home Assistant and noticed that the devices never listed. They are listed in Smart HQ and I tried using the websocket_example.py script without success. See the log below: