HASS-sonoff-ewelink
HASS-sonoff-ewelink copied to clipboard
Two B1 bulbs added ok while other 3 added as switch
Hi! I have 5 the same B1 bulbs. After installing the integration (latest master), 2 of them working perfectly while other 3 somewhat determined as switches and don't work. What could be the problem? Tried comment integration in configuration.yaml and then re-apply it. Doesn't help. Thanks in advance.
2 of them working perfectly while other 3 somewhat determined as switches and don't work.
i find it hard to believe that 2 of them are even working at all with master
branch, as it has NO support for B1 currently, try this thread https://github.com/peterbuga/HASS-sonoff-ewelink/issues/165
Oops! Sorry for mislead. I meant dev branch of course. I tried this branch exactly after reading through thread #165. Thank you again, it worked perfectly, BUT... As I already said for 2 of my 5 bulbs. Any hint for me to fix this?
@murlex clearly the other 3 bulbs are not the same (and that's a fact) with the working 2 or they are using a different firmware version, hard to tell exactly.
if you'll be willing to enable the debug
switch/mode (read the documentation section about this) and provide the full output i'll be more than glad to re-open this issue and hopefully find a solution
Thanks! I'll do it today.
Finally tried sonoff debug script. Something went wrong though :-( could you point what possibly happened? Here ssh session transcript.
core-ssh:/config/python_scripts# python3 sonoff-debug.py '[email protected]' 'my-password-is-hidden' >devices.json core-ssh:/config/python_scripts# cat devices.json { "error": 400, "msg": "params incomplete" }
Found this: https://github.com/skydiver/ewelink-api/issues/21 I fill it could help.
@murlex looks like we had a small misunderstanding coupled with a small not-updated code and you got the error above 😄
sonoff-debug.py
is/was used in the first place to capture the data from the people who mainly struggled to install & make it work inside HA (and by the looks of it i forgot to update it 😅)
the DEBUG part i was referring was this https://github.com/peterbuga/HASS-sonoff-ewelink#debug-log-generation--new-device--new-features-requests and it automatically integrates the original sonoff-debug.py
script + more features (try to execute some commands for one of the non-working bulbs just like i mention in the instructions as i get valuable information from there). it'll be better if you share only 1 non-working bulb to a 2nd account and do this debug-process => smaller/better output 👍
Found this: skydiver/ewelink-api#21 I fill it could help.
this guy is/was shamelessly copying my code without a minimal reference to it, i don't mind copying (i'm doing it myself all the time) but it's common way to acknowledge & support the community. by the looks of it, it seems he didn't figure out the problem yet... 👎
Finally found time for some experimenting. So, according to debug section, here the results. I've experimented with 2 identical bulbs. One called "Right lamp" (all is good about it) and 2nd "Bedroom ceiling lamp 1" (this one shown as switch in hassio and doesn't work when activated in hassio). Here the notification area's debug outputs.
From ewelink app "Right lamp". On/off/settings - all working:
--------------COPY-FROM-HERE-------------- 2019-11-13 23:42:52.353 [s] {"device_id": "10005c4661", "params": {"state": "off"}}
2019-11-13 23:42:52.355 [W] {"action": "update", "apikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "deviceid": "10005c4661", "params": {"state": "off"}, "sequence": "1573681371060", "tempRec": "10005c4661", "ts": 0, "userAgent": "app"}
2019-11-13 23:43:12.211 [s] {"device_id": "10005c4661", "params": {"state": "on"}}
2019-11-13 23:43:12.212 [W] {"action": "update", "apikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "deviceid": "10005c4661", "params": {"state": "on"}, "sequence": "1573681390447", "tempRec": "10005c4661", "ts": 0, "userAgent": "app"}
2019-11-13 23:43:34.623 [s] {"device_id": "10005c4661", "params": {"sledOnline": "off"}}
2019-11-13 23:43:34.624 [W] {"action": "update", "apikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "deviceid": "10005c4661", "params": {"sledOnline": "off"}, "sequence": "1573681412648", "tempRec": "10005c4661", "ts": 0, "userAgent": "app"}
2019-11-13 23:43:53.245 [s] {"device_id": "10005c4661", "params": {"sledOnline": "on"}}
2019-11-13 23:43:53.247 [W] {"action": "update", "apikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "deviceid": "10005c4661", "params": {"sledOnline": "on"}, "sequence": "1573681431758", "tempRec": "10005c4661", "ts": 0, "userAgent": "app"}
---------------END-OF-COPY----------------`
From ewelink app "Bedroom ceiling lamp 1". On/off/settings - all working:
.` --------------COPY-FROM-HERE--------------
2019-11-13 23:46:14.182 [s] {"device_id": "1000516b13", "params": {"state": "off"}}
2019-11-13 23:46:14.183 [W] {"action": "update", "apikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "deviceid": "1000516b13", "params": {"state": "off"}, "sequence": "1573681572930", "tempRec": "1000516b13", "ts": 0, "userAgent": "app"}
2019-11-13 23:46:30.245 [s] {"device_id": "1000516b13", "params": {"state": "on"}}
2019-11-13 23:46:30.246 [W] {"action": "update", "apikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "deviceid": "1000516b13", "params": {"state": "on"}, "sequence": "1573681588666", "tempRec": "1000516b13", "ts": 0, "userAgent": "app"}
2019-11-13 23:46:46.153 [s] {"device_id": "1000516b13", "params": {"sledOnline": "off"}}
2019-11-13 23:46:46.155 [W] {"action": "update", "apikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "deviceid": "1000516b13", "params": {"sledOnline": "off"}, "sequence": "1573681604630", "tempRec": "1000516b13", "ts": 0, "userAgent": "app"}
2019-11-13 23:46:58.951 [s] {"device_id": "1000516b13", "params": {"sledOnline": "on"}}
2019-11-13 23:46:58.953 [W] {"action": "update", "apikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "deviceid": "1000516b13", "params": {"sledOnline": "on"}, "sequence": "1573681617499", "tempRec": "1000516b13", "ts": 0, "userAgent": "app"}
---------------END-OF-COPY----------------`
From hassio "Right lamp" (shown as bulb). On/off - all working: .` --------------COPY-FROM-HERE-------------- 2019-11-13 23:48:42.971 [S] {"device_id": "10005c4661", "params": {"state": "off"}}
2019-11-13 23:48:43.634 [W] {"apikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "deviceid": "10005c4661", "error": 0, "sequence": "15736817229690433"}
2019-11-13 23:48:48.167 [S] {"device_id": "10005c4661", "params": {"state": "on"}}
2019-11-13 23:48:48.820 [W] {"apikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "deviceid": "10005c4661", "error": 0, "sequence": "15736817281625316"}
---------------END-OF-COPY----------------`
From hassio "Bedroom ceiling lamp 1" (shown as switch). On/off - NOT working: . `--------------COPY-FROM-HERE-------------- 2019-11-13 23:49:36.883 [S] {"device_id": "1000516b13", "params": {"switch": "on"}}
2019-11-13 23:49:37.658 [W] {"apikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "deviceid": "1000516b13", "error": 0, "sequence": "15736817768804574"}
2019-11-13 23:49:42.807 [S] {"device_id": "1000516b13", "params": {"switch": "off"}}
2019-11-13 23:49:43.502 [W] {"apikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "deviceid": "1000516b13", "error": 0, "sequence": "15736817828047132"}
---------------END-OF-COPY----------------`
If it helps, in Google Home app all they are working and shown as lights icon.
Here on these images you can see all of them in my hassio.
hi @murlex the outputs are definitely really good 👍 but unfortunately one crucial information was missed that i really needed in order to figure out what your bulb structure, therefore i need for you to replicate the "Bedroom ceiling lamp 1" output but this time let debug switch on for at least 1-2 minutes (or minimum the period you set it up for scan_interval
) you don't even need to switch it on/off or do anything else.
the important part is that you need to capture a line that'll have a [D] in it, for example 2019-11-13 23:48:48.820 [D] ....
and in theory should be longer (more data than the others) and easily recongnizable, sorry for all this fuss but this is the only way i can think of debugging these problems
Thank you for taking your time to understand my problem. I did it, though I can't see D record in the output unfortunately. Am I understand you right? I should switch on debug switch, go prepare and drink some coffee :-), than switch debug switch off and take output. If so, that exactly what I did. Btw, my scan interval is 60. Here is the output, though as I said no any D in it :-(
. --------------COPY-FROM-HERE--------------
2019-11-14 00:51:25.261 [s] {"device_id": "1000517339", "params": {"rssi": -68}}
2019-11-14 00:51:25.262 [W] {"action": "update", "apikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "deviceid": "1000517339", "from": "device", "params": {"rssi": -68}, "ts": 0, "userAgent": "device"}
2019-11-14 00:51:35.310 [s] {"device_id": "1000517339", "params": {"online": false}}
2019-11-14 00:51:35.310 [W] {"action": "sysmsg", "apikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "deviceid": "1000517339", "params": {"online": false}, "ts": 0}
2019-11-14 00:51:39.352 [s] {"device_id": "1000517339", "params": {"online": true}}
2019-11-14 00:51:39.354 [W] {"action": "sysmsg", "apikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "deviceid": "1000517339", "params": {"online": true}, "ts": 0}
2019-11-14 00:51:40.016 [s] {"device_id": "1000517339", "params": {"channel0": "0", "channel1": "0", "channel2": "255", "channel3": "233", "channel4": "0", "fwVersion": "2.6.0", "rssi": -77, "staMac": "xx:xx:xx:xx:xx:xx", "state": "on"}}
2019-11-14 00:51:40.018 [W] {"action": "update", "apikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "deviceid": "1000517339", "from": "device", "params": {"channel0": "0", "channel1": "0", "channel2": "255", "channel3": "233", "channel4": "0", "fwVersion": "2.6.0", "rssi": -77, "staMac": "xx:xx:xx:xx:xx:xx", "state": "on"}, "ts": 0, "userAgent": "device"}
---------------END-OF-COPY----------------
@murlex that is very odd, it should definitely show up... are you using a 2nd ewelink account with shared devices? if not: close ewelink app on mobile, restart home assistant, activate the debug switch for 5 minutes (just to be sure) and do not open the ewelink app all this time! i suspect you're ending up in the grace-period and that's why the [D] (which is the polling of the devices, also the state update fallback) is not showing up... i really need this information :( !
I find it odd too. Yes, I am using 2 accounts. Hassio configured with account called "murlex" (my main account) while I log in to ewelink app with just created account called "alexander" having these only 2 lamps ("good" and "bad") shared from main "murlex" account. In ewelink app both account are capable control all these lights with no problem.
BTW, if I use the same account, I am getting kicked off from ether hassio (with JSON error messages in notification) or from ewelink app that asks from me to-relogin. Then (RTFM :) I've created that 2nd "alexander" account and made all the experimenting above with both these. Today evening, I'll try to restart my mobile and hassio, switch on debug and wait 5 minutes. I am pretty aware you need that [D] info. I am a developer too (for ~30 years already :) though my world is Windows/.NET/C#, so I understand you perfectly :)
the oddness increases 🤕
alternatively try to use this https://github.com/peterbuga/HASS-sonoff-ewelink/tree/master/sonoff-debug
it's the 1st version of debug i've made, pretty much returns only the [D]-related information. (ps: some people reported not working due to some api changes, sometimes it works sometimes it doesn't, but i was lazy to updated due to all-in-one debug-switch 😅. if it still doesn't work i'll update it later today)
Thanx! I'll try in a few hours.
Hi again! Still no good news. Tried both reboots and then 10 minutes of debug switch turned on. Still no D-records :-( Downloaded sonoff-debug.py from master. No success, this time I afraid you really need to update code. This is the error written into devices.json:
{ "error": 400, "msg": "params incomplete" }
(I tried both accounts: murlex and alexander)
What do you think of the idea to try one of these 3 bulbs re-add into ewelink app? Just to see what happens. I can do it tomorrow.
What do you think of the idea to try one of these 3 bulbs re-add into ewelink app? Just to see what happens.
no, don't worry. i'll just fix the sonoff-debug.py
script and let you know
Ok. No problem. Thanks!
hi @murlex i've updated the sonoff-debug.py
script can you please try this version https://raw.githubusercontent.com/peterbuga/HASS-sonoff-ewelink/dev/sonoff-debug/sonoff-debug.py (didn't realized and i pushed it to dev branch 🙈)
the weirder part on all of this is that for me the the sonoff-debug.py
worked just fine as it was without any change to be done. for some reason, for some accounts it works for some it doesn't. could you please tell me in what region are you (us/eu/as/cn) and if your account's username is in email or phone number format? thx
Thank you for fix. It worked finally! Here is my devices.json created. I am in region "as" and my account is in email format.
{
"devicelist": [
{
"__v": 0,
"_id": "[hidden]",
"apikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"brandLogoUrl": "https://as-ota.coolkit.cc/logo/KRZ54OifuGmjoEMxT1YYM3Ybu2fj5K2C.png",
"brandName": "Sonoff",
"createdAt": "xxxx-xx-xxxxx:xx:xx.xxx",
"devConfig": {},
"devGroups": [],
"deviceStatus": "0",
"deviceUrl": "https://as-api.coolkit.cc/api/detail/5a2e1aff0cf772f92c342efc_en.html",
"deviceid": "[hidden]",
"devicekey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"extra": {
"_id": "[hidden]",
"extra": {
"apmac": "xx:xx:xx:xx:xx:xx",
"brandId": "58e5f344baeb368720e25469",
"description": "WO1818645",
"mac": "xx:xx:xx:xx:xx:xx",
"manufacturer": "\u6df1\u5733\u677e\u8bfa\u6280\u672f\u6709\u9650\u516c\u53f8",
"model": "PSF-BLB-GL",
"modelInfo": "5a2e1aff0cf772f92c342efc",
"staMac": "xx:xx:xx:xx:xx:xx",
"ui": "RGB\u4e94\u8272\u7403\u6ce1\u706f",
"uiid": 22
}
},
"group": "",
"groups": [],
"ip": "[hidden]",
"location": "",
"name": "[hidden]",,
"offlineTime": "xxxx-xx-xxxxx:xx:xx.xxx",
"online": false,
"onlineTime": "xxxx-xx-xxxxx:xx:xx.xxx",
"params": {
"bindInfos": {
"gaction": [
"22107b6f-dde9-4531-96e3-a99448250ce3_ewelink-google-home-v1"
]
},
"channel0": "0",
"channel1": "0",
"channel2": "0",
"channel3": "0",
"channel4": "255",
"fwVersion": "2.6.0",
"partnerApikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"rssi": -63,
"sledOnline": "on",
"staMac": "xx:xx:xx:xx:xx:xx",
"state": "on",
"type": "middle",
"zyx_mode": 2
},
"productModel": "B1_R2",
"settings": {
"alarmNotify": 1,
"opsHistory": 1,
"opsNotify": 0
},
"sharedBy": {
"apikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"email": "[email protected]",
"permit": 15,
"shareTime": 1573580246728
},
"showBrand": true,
"type": "10",
"uiid": 22
},
{
"__v": 0,
"_id": "[hidden]",
"apikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"brandLogoUrl": "https://as-ota.coolkit.cc/logo/KRZ54OifuGmjoEMxT1YYM3Ybu2fj5K2C.png",
"brandName": "Sonoff",
"createdAt": "xxxx-xx-xxxxx:xx:xx.xxx",
"devConfig": {},
"devGroups": [],
"deviceStatus": "",
"deviceUrl": "https://as-api.coolkit.cc/api/detail/5927cd536ea4362d439a1d7a_en.html",
"deviceid": "[hidden]",
"devicekey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"extra": {
"_id": "[hidden]",
"extra": {
"apmac": "xx:xx:xx:xx:xx:xx",
"brandId": "58e5f344baeb368720e25469",
"description": "WO18585 WO18586",
"mac": "xx:xx:xx:xx:xx:xx",
"manufacturer": "\u6df1\u5733\u677e\u8bfa\u6280\u672f\u6709\u9650\u516c\u53f8",
"model": "PSF-BLB-GL",
"modelInfo": "5927cd536ea4362d439a1d7a",
"staMac": "xx:xx:xx:xx:xx:xx",
"ui": "RGB\u4e94\u8272\u7403\u6ce1\u706f",
"uiid": 22
}
},
"group": "",
"groups": [
"5d1f7c1c993e0dfd70f0f9b6"
],
"ip": "[hidden]",
"location": "",
"name": "[hidden]",,
"offlineTime": "xxxx-xx-xxxxx:xx:xx.xxx",
"online": true,
"onlineTime": "xxxx-xx-xxxxx:xx:xx.xxx",
"params": {
"bindInfos": {
"gaction": [
"178166b6-a373-4fa4-941e-da6868156447_ewelink-google-home-v1"
]
},
"channel0": "0",
"channel1": "0",
"channel2": "0",
"channel3": "0",
"channel4": "255",
"fwVersion": "2.6.0",
"partnerApikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"rssi": -61,
"sledOnline": "on",
"staMac": "xx:xx:xx:xx:xx:xx",
"state": "off",
"switch": "off",
"type": "middle",
"zyx_mode": 2
},
"productModel": "B1",
"settings": {
"alarmNotify": 1,
"opsHistory": 1,
"opsNotify": 0,
"wxAlarmNotify": 0
},
"sharedBy": {
"apikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"email": "[email protected]",
"permit": 15,
"shareTime": 1573580246728
},
"showBrand": true,
"type": "10",
"uiid": 22
}
],
"error": 0
}
Peter edit: removed an email reference
finally 🙌 thanks (looks like servers from cn/as regions might have a slight different software, that's why you couldn't run previous sonoff-debug.py
)
anyhow, the dump sort of confirms what i was suspecting all (but i had to be sure), one last question though: on the bulbs that are showing up as switches, can you turn them on/off from HA or not? if you can, then you'll have to wait for an update because as there's no consistency in itead devices 😓
Hi! I am happy you finally came to some conclusions :) What about the answer to your question: no. these switches in HA don't work. They are not grayed though and I can switch them but they do nothing.
Pfew! that's some good news for you :P i'll push an update (read: patch) later on these days so that you can use the other bulbs too ;)
Hooray! :-) Could you shed some light on what was the problem? I am curious as any developer could be :-)
sure thing ;)
i'm gonna try to keep it brief: all the sonoff-like devices (except RF Bridge, SC for obvious reasons) use params.switch
to set/get the on/off
values, but for reasons yet unknown to humanity the B1 that i implemented before had no params.switch
and instead used params.state
for on/off and i used this particular distinction to decide if it's a bulb or a switch-capable entity. your new bulbs have both of them switch
and state
but use params.state
to turn it ON/OF
and this is basically the entire itead API, devices with the same functionality use different params and it makes absolutely no sense :dizzy_face:
as another example sonoff L1 could just as easily work with the code for sonoff B1s but instead they are using different params for the colors entity and whatnot ... because why not ¯\_(ツ)_/¯
(if you want to kill a couple of neurons i suggest to decompile the ewelink apk file (it's a .js) and take a look a the thousands of IFs and SWITCHes inside the code to accommodate all these changes)
needless to say, i need to rewrite the component to define some kind of device-mapping-to-code as of now everything gets out of hand :confused:
Oh... it sounds sooooo much familiar! Spaghetti code written by someone usually not in out reach :) That's what we're all handling pretty much every day during hours! I just feel sorry for you :) Understand you pretty well :)
Hello.
Sorry English (translator), I don't speak English ...
I don't know if I'm talking bullshit, but I noticed that the firmwares follow a pattern in which I saw the following excerpt in debug ("model": "PSF-BLB-GL" ) and ewelink in settings -> firmware: PSF-BLB-GL. Would LB be from Light Bulb? I have other devices:
2x Sonoff B1: PSF-BLB-GL (one as light and one as switch);
1x Sonoff TX3C: PSF-B04-GL;
4x Sonoff MINI: PSF-BD1-GL;
1x Sonoff 4CH pro R1: PSF-A04-GL;
1x Sonoff RF: "PSF-BRA-GL".
Could this information not be used to define the type devices?
@Robson-BR i thought of this a long time ago until i came across the decompiled apk i talked above and trust me there are thousands of this kind of product codes around there all with rules & whatnot. i don't want to get in the mess of hardcoded strings instead i'll try to rely on a sort of mapper of device capabilities. there are devices that are like hybrid, that expose the lights but also the switch (ex: humidifiers) therefore i have to explode this frankenstein-of-a-device into multiple HA entities, each with its properties.
thanks tho!
Ok @peterbuga. I'm like the same problem as @murlex. I will be following the discussion, hoping for a solution. Congratulations on your commitment to developing solutions.