NickWaterton / eWeLink-mqtt

Bridge to control Sonoff Devices via MQTT
MIT License
19 stars 5 forks source link

KeyError: 'familyList' #9

Closed FhemiR closed 7 months ago

FhemiR commented 7 months ago

Hi there, I get the following error while running the script,my device is a 4CHPROR3. I have py3.12.0 running on Raspberry 4.

I started the server as follow pi@rasp:~/eWeLink-mqtt $ ./ewelink.py **** **** -b 192.111.111.17 -d 1001f96h99 The following error appears.

[2023-12-16 21:25:36,253] INFO MQTT library v1.0.2 [2023-12-16 21:25:36,254] INFO Connecting to MQTT broker: 192. [2023-12-16 21:25:36,264] INFO MQTT broker connected [2023-12-16 21:25:36,265] INFO Connecting, login: *, password: ***, appid(v2): [2023-12-16 21:25:36,266] INFO subscribing to: /ewelink_command/# [2023-12-16 21:25:38,753]ERROR 'familyList' Traceback (most recent call last): File "/home/pi/eWeLink-mqtt/./ewelink.py", line 297, in start_connection homes = await self.get_homes() ^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/eWeLink-mqtt/custom_components/sonoff/core/ewelink/cloud.py", line 179, in get_homes return {i["id"]: i["name"] for i in resp["data"]["familyList"]}


KeyError: 'familyList'

Any idea what how can i fix it?
Thanks & Regards
NickWaterton commented 7 months ago

Do you have the latest https://github.com/AlexxIT/SonoffLAN/tree/master installed?

If so, run eWeLink.py again with the -D (debug) option, and post the output here.

I have a feeling that the app ID and secret do not have permission to access the get_homes api, which is why you are seeing this.

FhemiR commented 7 months ago

Yes it is the latest. It seems the error comes from here eWeLink-mqtt/custom_components/sonoff/core/ewelink/cloud.py {'error': 407, 'msg': 'the path of request is not allowed with appid:4s1FXKC9FaGfoqXhmXSJneb3qcm1gOak', 'data': {}}

I added a # in like 41 now it works as expected.

BTW do you have a hint for me, how one can turn on off each switch for a 4CH pro device?I mean how to send a comand that e.g switch1 goes on and at the same time all other off? "mosquitto_pub -t "/ewelink_command/1000861ac4/switch" -m off"?

NickWaterton commented 7 months ago

Yes, the app ID does not have permission to access the homes api. Not sure why this is, but I should probably take a look at it.

as far as I remember, (and it’s been a long time), it would be:

mosquitto_pub -t /ewelink_command/1000861ac4/switches -m “0 off”
mosquitto_pub -t /ewelink_command/1000861ac4/switches -m “0 on 1 off 2 off 3 off”
mosquitto_pub -t /ewelink_command/1000861ac4/switches -m “3 on”

And so on. The second example is what you asked for. Switches are numbered from 0.