peterbuga / HASS-sonoff-ewelink

Home Assistant component to control Sonoff/eWeLink devices with original firmware
MIT License
795 stars 293 forks source link

New Device: Sonoff B1 Bulb #34

Closed gregcsw closed 5 years ago

gregcsw commented 5 years ago

Hi,

Thank you for your work on this. Is it possible to look at adding the Sonoff B1.

Sonoff-debug info attached

Thanks Greg sonoffB1.txt

gregcsw commented 5 years ago

After installing the component in home assistant, I currently get the following error when the Sonoff B1 has power, light can be on or off. (It is the only device loaded on the Ewelink app) The error goes away when the bulb is turned off, ie no power to the globe so it is completely off and disconnected.

Log Details (ERROR) Wed Jan 09 2019 11:45:57 GMT+0200 (South Africa Standard Time)

Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 232, in async_update_ha_state state = self.state File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 426, in state return STATE_ON if self.is_on else STATE_OFF File "/config/custom_components/switch/sonoff.py", line 48, in is_on self._state = self.get_state() File "/config/custom_components/sonoff.py", line 414, in get_state return device['params']['switch'] == 'on' if device else False KeyError: 'switch'

peterbuga commented 5 years ago

Hi @gregcsw thanks for reaching out! this is the only way for me to add new devices and i'm constantly surprised (not in a good way!) how the developers behind sonoff products keep changing the API logic of various devices.

Long story short: I will definitely fix the error above soon πŸ˜‰ but you'll have to test it and report back (cuz' you're the only one with the device so far πŸ˜‹ )

I see that this device is an RGB light, I will appreciate if you could do a few more device dumps (the first one is perfect btw) so that I figure out which values control the colour/brightness: basically i need a dump for each of a full red/blue/green/yellow + brightness 100%, white-brightness 100% and white-brightness 1% (don't forget to label the dumps accordingly) This way I could implement also the brightness/colour changing automation in HA in the future, only if you're willing to do the request above 😊 !

gregcsw commented 5 years ago

Thank you for your quick response. Here are the dumps as requested. The bulb has 3 white modes, cool white, warm white and cool+warm white (both cool and warm leds are on)

blue100.txt cool_white_100.txt cool_white_min.txt cool+warm_white_min.txt

green100.txt off.txt red100.txt warm_white_100.txt warm_white_min.txt

peterbuga commented 5 years ago

Wow, I wasn't expecting the dumps so fast πŸ˜„!

They're exactly what I needed/requested. For reference I watched this video https://youtu.be/eBUtXQ8N4Cw to see exactly what are the options and how they match with the dumps. For starters I'll update the component soon-ish to avoid throwing the errors and give you the ability to change the state ON/OFF of the light (i'll let you know)

The brightness/colour part, I have to admit, I have no idea right how needs to be implemented and/or how much it'll take but for sure I'll make it work πŸ˜‰

This might sound weird, but are you able to change bulb's brightness when using the colour mode of the light (it's not totally clear for me from video)? If not, it think this might be an extra feature that I could add.

peterbuga commented 5 years ago

@gregcsw looks like the on/off update has been a basic one, give a try with this branch https://github.com/peterbuga/HASS-sonoff-ewelink/tree/sonoff-bulb and let me know if it works (just to be sure, update all the sonoff.py files from this branch)

gregcsw commented 5 years ago

Wow Awesome. Yes that works. Turns on to whatever colour or brightness was last used in the app. Just one small thing, it is showing up as a switch in home assistant instead of a light.

For your previous question, no you can't change the brightness when using the RGB colours, you can only choose the colour from the wheel. For white there is a 3 position switch for choosing cool white, mixed or warm white and a brightness slider.

Functionality in the app is not great, so anything you can do will be nice.

Thank you img_1650 img_1651

gregcsw commented 5 years ago

And the error message is gone. Thank you

peterbuga commented 5 years ago

Great πŸ™Œ, glad it works!

Behind the scenes a light entity is actually a physical-switch + physical-light. It's gonna show up as a light later after I work more on on it, but if you really really need to show up as a light you can either customize the switch or use this component https://www.home-assistant.io/components/light.switch/

I'll keep you up-to-date with my progress, again... you're the only one who can test it so far πŸ˜…

superjasiek commented 5 years ago

Hi! Thanks for your grate work! Works well with bulb B1! In general that was the integration with HA what I was looking for. Can't wait for other options available. In case i can be a second beta-tester! Take care!

peterbuga commented 5 years ago

@superjasiek i'll definitely need more people to test it, i'm sort of blindly coding this component due to the fact i don't have the devices to do the tests on my side 😞 . otherwise the development of it was much much faster! i'll keep you up to date when i make more progress πŸ˜‰

max-rh commented 5 years ago

Hi @peterbuga, First of all, thanks alot for this absolutely amazing integration, its exactly what i need. I have the multiple sonoff devices (including the bulb and the RF bridge and multiple door and motion devices), and i am happy to help with the integration, please update me with what u need and how may i assist.

Just a note: i did try the branch for the bulb and it works fine so far, but i still get the following error:

Traceback (most recent call last):, File "/usr/src/app/homeassistant/helpers/entity.py", line 232, in async_update_ha_state, state = self.state, File "/usr/src/app/homeassistant/helpers/entity.py", line 426, in state, File "/config/custom_components/switch/sonoff.py", line 48, in is_on, return STATE_ON if self.is_on else STATE_OFF, self._state = self.get_state(), File "/config/custom_components/sonoff.py", line 418, in get_state, return device['params'][state_key] == 'on' if device else False, KeyError: 'switch'

Happy to be of any assist :)

peterbuga commented 5 years ago

@max-rh soo funny thing πŸ˜… the sonoff-bulb branch has (currently) basic ON/OFF support for Sonoff B1 but just yesterday someone else who has a Sonoff RF Bridge contacted me regarding the integration of this device and I pushed some patches to master branch.

i did not expect someone to have B1 + Bridge in the same account and try to use this component. i merged everything right now into sonoff-bulb branch so please update the files from here, but no RF device will be displayed right now (basically the Bridge is ignored)

i would highly appreciate if you could send me a sonoff-debug.py dump following these steps https://github.com/peterbuga/HASS-sonoff-ewelink/tree/master/sonoff-debug and post the output in the thread of this issue https://github.com/peterbuga/HASS-sonoff-ewelink/issues/38

The process is tedious because I cannot test myself what I'm actually coding, but for sure Sonoff B1 will have the brightness/colour options added in the future and also the "Alarm" devices from Sonoff Bridge (i don't think it'll make sense to add the key fob buttons from bridge, same thing can be simulated in HA, and for curtains I really have no idea how it works πŸ˜… )

max-rh commented 5 years ago

Thanks @peterbuga, I am trying to collect the logs for you, but i keep getting python errors while i run sonoff-debug.py, its because i am running this on a different platform than the one my HA is running on (i am using a docker image on HA on my server), so can you please tell me what python image are u using and if i need to have any additional libraries.

currently i am getting the following error:

Traceback (most recent call last): File "sonoff-debug.py", line 90, in <module> devices_json = get_devices() File "sonoff-debug.py", line 69, in get_devices headers.update({'Authorization' : 'Bearer ' + user_details['at']}) KeyError: 'at'

Thanks

peterbuga commented 5 years ago

@max-rh thanks for followup you can run the sonoff-debug.py from any place, it's not mandatory to be on the same environment as HA install, in the end the output is the same.

the error above occurs when you mistype the username/password, please make sure you use ' around the login details, like here python sonoff-debug.py 'email@used.com' 'password' OR by any chance, are you using a phone number as your username instead of an email? because in this case sonoff-debug.py is not working πŸ˜…. this script is a slimmed-down version of the main component which supports both login with an email or phone number but i'm not always updating it due to low usage

max-rh commented 5 years ago

Hi peter, Yes my account is linked to a phone number not an email... so is there a script for a phone number?

peterbuga commented 5 years ago

so is there a script for a phone number?

@max-rh it wasn't but there is now. try with this updated version of the script https://github.com/peterbuga/HASS-sonoff-ewelink/tree/master/sonoff-debug

you should run it like this python sonoff-debug.py '+1234567890' 'pa55w0rd' (notice that i've changed email argument to username now for a better meaning)

max-rh commented 5 years ago

Hi Peter, I am using the master script but the Bulb is showing up as an error image

and i am getting this error in the logs:

Traceback (most recent call last): File "/usr/src/app/homeassistant/helpers/entity.py", line 232, in async_update_ha_state state = self.state File "/usr/src/app/homeassistant/helpers/entity.py", line 426, in state return STATE_ON if self.is_on else STATE_OFF File "/config/custom_components/switch/sonoff.py", line 48, in is_on self._state = self.get_state() File "/config/custom_components/sonoff.py", line 414, in get_state return device['params']['switch'] == 'on' if device else False KeyError: 'switch'

any advice ?

*Edit: The entity error turned out to be because the bulb is no longer showing up.

peterbuga commented 5 years ago

hi @max-rh can you please give a bit more details about the part "The entity error turned out to be because the bulb is no longer showing up" ? does this mean you had Sonoff Bulb in your eWeLink account and then you removed it?

i've been a bit busy lately, so i didn't had to do so many updates as i would've liked but i'm definitely going to implement/fix this one too πŸ’ͺ

max-rh commented 5 years ago

Hi Peter, no, the bulb has always been on my account, but it was offline lately (i plugged it in recently) and it showed the error i mentioned before, but today i checked HA again and it showed up as unavailable although i can see it online in the eWelink app.

imjcube commented 5 years ago

Hi,

I have just recived the Sonoff L1 (light strip) and it shows up as a switch so I figured it may belong to this thread. If you need anything I am happy to help.

Thanks for making this!

stephanerosi commented 5 years ago

@peterbuga Hi! Any reason why sonoff-bulb branch hasn't yet been merged into master? I've just tried it with my B1 and it works fine, along with my other sonoff switches. But it doesn't work if I'm on master (key error).

peterbuga commented 5 years ago

@stephanerosi it's not completed yet, i wanted to finish it instead of just patch-ing it into master

peterbuga commented 5 years ago

@gregcsw @max-rh @imjcube @stephanerosi @superjasiek hi everyone, i've been doing some work regarding this issue (and hopefully i'll get the time to finish it too) if by any chance one of gets the time to do a quick test and let me know if even works i'll highly appreciate it. please use this branch https://github.com/peterbuga/HASS-sonoff-ewelink/tree/sonoff-bulb (and if you have any kind of custom changed of sonoff component don't forget to backup it) the best way to install it is to completely remove the old sonoff files and this one (works only with HA0.88+)

i would like to mention that this is not complete (if it even works) and the bulb settings are not saved anywhere (i.e. between HA restarts the bulb's values will reset). just try to play with on-off/brightness/color temp/color and let me know how it behaves ps: keep an eye on HA logs too

thanks :)

superjasiek commented 5 years ago

Hey! Just tested new files and it seems to work perfect. I'm not at home but i have a preview from camera and all functions works fine. Thanks to this solution maybe i will use this bulb as a wake-up light - is dimming with automation possible now? . Thank you for your work and time!

peterbuga commented 5 years ago

@superjasiek ohh wow thanks! unbelievable great news (more for me than it might be for you) because i've done literally 0 testing of it due to not having the device πŸ˜… so everything was just theoretical (also, i think i might've added new bugs due to refactoring so further testing needs to be done for all the devices)

as i've said earlier the implementation is not complete and i'm relying on you guys to give me some feedback on it.

from what i gather the dimming is not supported by default on this (or any similar) device, but it could be simulated by sending progressing increasing/decreasing values over a defined amount of time, i'll probably create a service call for more-or-less power users willing to achieve this πŸ˜‰ . because it's like an extra feature first i want to be sure all the basic functions work as intended and then i'll look into it (btw, i never played with a dimming/color bulb so i'm not sure if it'll have a flicker effect or not)

looking forward for more feedback! πŸ™Œ

superjasiek commented 5 years ago

So far i'm able to change color, and mode (color or white), change brightness up and down. Can't see if white color changes from warm to cool but i will check it and let you know. Also no errors in home assistant log - only standard warning about using custom components. Have a grate day! main_color warmcool

peterbuga commented 5 years ago

another extra feature that i've just noticed based on one above comment of @gregcsw is that i might be able to use brightness on RGB mode also and/or combine warm-cool light with RGB in the same (with different brightness levels for both) if that makes any sense, i hope i'm not wrong believing this is currently missing from eWeLink app. so if you guys want/need it i could implement it πŸ’ͺ

gregcsw commented 5 years ago

Hi Peter,

Was just busy testing and it works great. The features you mention below of using brightness with color would be much appreciated. You are correct that this is missing from the app.

The current version on the component give the same functionality as the ewe link app.

Thanks Greg

On Apr 8, 2019, at 12:12, Peter Buga notifications@github.com wrote:

another extra feature that i've just noticed based on one above comment of @gregcsw https://github.com/gregcsw is that i might be able to use brightness on RGB mode also and/or combine warm-cool light with RGB in the same (with different brightness levels for both) if that makes any sense, i hope i'm not wrong believing this is currently missing from eWeLink app. so if you guys want/need it i could implement it πŸ’ͺ

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/peterbuga/HASS-sonoff-ewelink/issues/34#issuecomment-480771245, or mute the thread https://github.com/notifications/unsubscribe-auth/Ap2-_liTTYA3Q7eem2PEdLrvsLB75A7Aks5vexYrgaJpZM4Z3Irq.

peterbuga commented 5 years ago

got a little excited and I quickly added support RGB brightness, just the light.py needs to be updated, let me know how it works.

just to be sure, because trust me i'm walking sort of blind here, someone please confirm or not these features work as intended:

* to mention that first time after you restart HA some values might have a default hardcoded value, please change some settings before testing the above list. this part it's still work in progress

gregcsw commented 5 years ago

This is great, Peter.

Please see my responses below.

On Apr 8, 2019, at 14:20, Peter Buga notifications@github.com wrote:

got a little excited and I quickly added support RGB brightness, just the light.py needs to be updated, let me know how it works.

just to be sure, because trust me i'm walking sort of blind here, someone please confirm or not these features work as intended:

turning ON / OFF color temperature (100% brightness), the slider works like this: YES 100% left side = 100% cool + 0% warm, YES 75% left side = 75% cool + 25% warm YES 25% left side = 25% cool + 75% warm YES middle = 100% cool + 100% warm YES 25% right side = 75% cool + 25% warm YES 75% right side = 25% cool + 75% warm YES 100% right side = 0% cool + 100% warm YES color temperature + brightness levels YES RGB colors (100% brightness) YES, when switching to color mode, the bulb turns on to the last remembered color at 100% brightness, but the brightness slider shows 0% RGB colors + brightness levels YES, you can change the brightness of the color, but if you change colors after setting brightness lower than 100%, the new color is at 100% and as above the brightness slider goes back to showing 0%. restoring the state between warmcool and color modes YES

to mention that first time after you restart HA some values might have a default hardcoded value, please change some settings before testing the above list. this part it's still work in progress β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/peterbuga/HASS-sonoff-ewelink/issues/34#issuecomment-480808231, or mute the thread https://github.com/notifications/unsubscribe-auth/Ap2-_qZIbKHJv5cfItoQ0gCxHmjB5l42ks5vezPzgaJpZM4Z3Irq.

gregcsw commented 5 years ago

Tested a bit more, and if I look on the dev-state panel when the bulb is in color mode, the brightness value is 0, and doesn’t change when the slider is moved. The bulb gets brighter or dimmer but the brightness value in HA stays at 0.

If I do the same thing in CoolWarm mode, the brightness value in HA changes with the slider and the bulb.

I hope that makes sense.

On Apr 8, 2019, at 14:20, Peter Buga notifications@github.com wrote:

got a little excited and I quickly added support RGB brightness, just the light.py needs to be updated, let me know how it works.

just to be sure, because trust me i'm walking sort of blind here, someone please confirm or not these features work as intended:

turning ON / OFF color temperature (100% brightness), the slider works like this: 100% left side = 100% cool + 0% warm, 75% left side = 75% cool + 25% warm 25% left side = 25% cool + 75% warm middle = 100% cool + 100% warm 25% right side = 75% cool + 25% warm 75% right side = 25% cool + 75% warm 100% right side = 0% cool + 100% warm color temperature + brightness levels RGB colors (100% brightness) RGB colors + brightness levels restoring the state between warmcool and color modes to mention that first time after you restart HA some values might have a default hardcoded value, please change some settings before testing the above list. this part it's still work in progress β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/peterbuga/HASS-sonoff-ewelink/issues/34#issuecomment-480808231, or mute the thread https://github.com/notifications/unsubscribe-auth/Ap2-_qZIbKHJv5cfItoQ0gCxHmjB5l42ks5vezPzgaJpZM4Z3Irq.

peterbuga commented 5 years ago

thanks! that's a really good catch, i'll follow up and test it myself.

i was actually wondering why the brightness 0% problem occurs because i never change it in the code. too soon to tell but it might be a HA bug πŸ˜… worst case scenario you'll be able to change it in automations only Β―_(ツ)_/Β―

really appreciate the prompt replies!

gregcsw commented 5 years ago

Hi, Changed Line 74 of light.py to: return self._brightness

And now the brightness reads correctly in color mode.

On Apr 8, 2019, at 15:05, Greg Wrench gswrench@gmail.com wrote:

Tested a bit more, and if I look on the dev-state panel when the bulb is in color mode, the brightness value is 0, and doesn’t change when the slider is moved. The bulb gets brighter or dimmer but the brightness value in HA stays at 0.

If I do the same thing in CoolWarm mode, the brightness value in HA changes with the slider and the bulb.

I hope that makes sense.

On Apr 8, 2019, at 14:20, Peter Buga <notifications@github.com mailto:notifications@github.com> wrote:

got a little excited and I quickly added support RGB brightness, just the light.py needs to be updated, let me know how it works.

just to be sure, because trust me i'm walking sort of blind here, someone please confirm or not these features work as intended:

turning ON / OFF color temperature (100% brightness), the slider works like this: 100% left side = 100% cool + 0% warm, 75% left side = 75% cool + 25% warm 25% left side = 25% cool + 75% warm middle = 100% cool + 100% warm 25% right side = 75% cool + 25% warm 75% right side = 25% cool + 75% warm 100% right side = 0% cool + 100% warm color temperature + brightness levels RGB colors (100% brightness) RGB colors + brightness levels restoring the state between warmcool and color modes to mention that first time after you restart HA some values might have a default hardcoded value, please change some settings before testing the above list. this part it's still work in progress β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/peterbuga/HASS-sonoff-ewelink/issues/34#issuecomment-480808231, or mute the thread https://github.com/notifications/unsubscribe-auth/Ap2-_qZIbKHJv5cfItoQ0gCxHmjB5l42ks5vezPzgaJpZM4Z3Irq.

peterbuga commented 5 years ago

haha my bad πŸ˜„ totally forgot about that!

gregcsw commented 5 years ago

That fixed the other problems i reported as well.

On Apr 8, 2019, at 15:14, Peter Buga notifications@github.com wrote:

haha my bad πŸ˜„ totally forgot about that!

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/peterbuga/HASS-sonoff-ewelink/issues/34#issuecomment-480826297, or mute the thread https://github.com/notifications/unsubscribe-auth/Ap2-_hPlmQG4NGDL6qMgDiMzv6ikQhaDks5ve0ClgaJpZM4Z3Irq.

gregcsw commented 5 years ago

Only 2 problems I am still having, but I don’t think either of them have to do with the component:

  1. If I turn the bulb on with an automation, neither Ewelink or HA register the bulb as on, or if it is on and I change the color with an automation, neither Ewelink or HA register the change, although in both cases the bulb itself changes to settings called in the automation.

  2. I can’t set the brightness from an automation.

Other than these 2 issues, it is working just like I want it too.

Thank you for the awesome work on this.

On Apr 8, 2019, at 15:14, Peter Buga notifications@github.com wrote:

haha my bad πŸ˜„ totally forgot about that!

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/peterbuga/HASS-sonoff-ewelink/issues/34#issuecomment-480826297, or mute the thread https://github.com/notifications/unsubscribe-auth/Ap2-_hPlmQG4NGDL6qMgDiMzv6ikQhaDks5ve0ClgaJpZM4Z3Irq.

max-rh commented 5 years ago

Hi Peter, So sorry i was a bit busy, just tested it and its Absolutely Amazing, incredible work; thanks alot.

Was reading the guys responses, looks like most of the bugs are fixed; i am not having any bugs so far, didn't test the automation bug that @gregcsw mentioned will try it soon.

but i have a little issue; i have an automation that monitors the state of all my switches in case any of them went offline, and i noticed that the automation sends that the sonoff switches went offline "Unavailable" from time to time, but when i check on them they seem online; does the code lose connectivity or state tracking from time to time ?

again, thanks alot, this just saved me alot of work in my automations.

peterbuga commented 5 years ago

@gregcsw i'll have to do some more testing on my side, just yesterday i've learned how to add a light to HA and even though it's similar to a switch it is a bit more complex

@max-rh thanks for follow up too! regarding the unavailable stuff, i'll prefer if we keep this in a separated thread. also i think it's better to start from scratch, use the latest code available and start reporting from there (i don't know if you used the polling version - that was more prone to errors - or websocket version)

stephanerosi commented 5 years ago

Hi, thanks for the good work!

I've noticed a few inconsistencies in the color and slider (tested with a sonoff B1)

1/ I think the brightness slider should be more logarithmic than linear (eg. on the far left, a small change, makes a big change in the brightness

/ on the right this is the countrary) 2/ The color picker works, but the real color on the light is different than the one chosen (eg. When chosing yellow, I get green)

I've attached a zip containing screenshots of HA interface and actual color/brightness on the lamp to help you.

Bulb.zip https://drive.google.com/file/d/187FlUHCLsvrcIbmLfZV7khBEgCavt0yi/view?usp=drivesdk

Otherwise, the rest works fine :-)

Le lun. 8 avr. 2019 Γ  16:05, Peter Buga notifications@github.com a Γ©crit :

@gregcsw https://github.com/gregcsw i'll have to do some more testing on my side, just yesterday i've learned how to add a light to HA and even though it's similar to a switch it is a bit more complex

@max-rh https://github.com/max-rh thanks for follow up too! regarding the unavailable stuff, i'll prefer if we keep this in a separated thread. also i think it's better to start from scratch, use the latest code available and start reporting from there (i don't know if you used the polling version - that was more prone to errors - or websocket version)

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/peterbuga/HASS-sonoff-ewelink/issues/34#issuecomment-480845619, or mute the thread https://github.com/notifications/unsubscribe-auth/AF-g9DWlCbXHmbkwkVRG80fE5AVFPMo7ks5ve0yQgaJpZM4Z3Irq .

peterbuga commented 5 years ago

@gregcsw regarding the mentioned problems above: 1) i pushed an update regarding this but i have to admit, without a testing bulb i feel like i'm becoming the victim of my own creation :((. i did create a basic automation so that my dummy-test light to copy the state of another switch and it works on my side when I toggle the parent switch from inside HA or the mobile app 2) i really don't know why this doesn't work - maybe the 1) fixed this too. have you tried to define the automation like here https://community.home-assistant.io/t/individual-brightness-in-automation/15105/2 ? again, i tried it on my side same setup as 1) and the brightness value changes accordingly and the request that changes the bulb is executed also ps: right now the brightness/color temp is not sent back from ewelink app to HA, i'm aware of this but i'm tired & hungry right now, will be fixed ;)

@stephanerosi 1) i think the variation in the light are due to inconsistencies in the leds power, code-wise as you mentioned everything is linear (no testing device can't tell what's the output :P). right now i'm focused on having everything working as expected and then we'll work out the finishing touches later 2) i literally have no idea what i'm sending here :)) i'm using a conversion function of values provided by HA on hoped for the best. just like 1) i will later send some instructions over on how to provided some needed data to sync them. ps: cannot access the files, can you make them public? or just post them somewhere else with a password, like https://send.firefox.com

global ps: i think i broke the compatibility with devices that have more outlets like sonoff ch4, soo until i can confirm it still works please do not use this branch for everyday use

stephanerosi commented 5 years ago

Here is the link : https://drive.google.com/file/d/187FlUHCLsvrcIbmLfZV7khBEgCavt0yi/view?usp=drivesdk

Happy to help when you'll fine-tune everything :-)

Le lun. 8 avr. 2019 Γ  22:02, Peter Buga notifications@github.com a Γ©crit :

@gregcsw https://github.com/gregcsw regarding the mentioned problems above:

  1. i pushed an update regarding this but i have to admit, without a testing bulb i feel like i'm becoming the victim of my own creation :((. i did create a basic automation so that my dummy-test light to copy the state of another switch and it works on my side when I toggle the parent switch from inside HA or the mobile app
  2. i really don't know why this doesn't work - maybe the 1) fixed this too. have you tried to define the automation like here https://community.home-assistant.io/t/individual-brightness-in-automation/15105/2 ? again, i tried it on my side same setup as 1) and the brightness value changes accordingly and the request that changes the bulb is executed also ps: right now the brightness/color temp is not sent back from ewelink app to HA, i'm aware of this but i'm tired & hungry right now, will be fixed ;)

@stephanerosi https://github.com/stephanerosi

  1. i think the variation in the light are due to inconsistencies in the leds power, code-wise as you mentioned everything is linear (no testing device can't tell what's the output :P). right now i'm focused on having everything working as expected and then we'll work out the finishing touches later
  2. i literally have no idea what i'm sending here :)) i'm using a conversion function of values provided by HA on hoped for the best. just like 1) i will later send some instructions over on how to provided some needed data to sync them. ps: cannot access the files, can you make them public? or just post them somewhere else with a password, like https://send.firefox.com

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/peterbuga/HASS-sonoff-ewelink/issues/34#issuecomment-480985205, or mute the thread https://github.com/notifications/unsubscribe-auth/AF-g9CUBMOLamK7FFaPA9lo0vAOQOushks5ve6BOgaJpZM4Z3Irq .

peterbuga commented 5 years ago

@stephanerosi i got to look at the photos, nicely done πŸ‘ it really gives me a real life view of what's happening. what i can say right now is that i have no idea how to quickly fix the colour offset, as it implies some type of conversion from hue/saturation + offset to RGB and i must admit i'm not quite in the mood to figure it out right now πŸ˜… but for sure it'll be fixed!

peterbuga commented 5 years ago

@stephanerosi i see that you're quite into helping soo regarding the rgb-offset problem do you think you can generate a more detailed debug log file for me?

here's what i need you to do:

redo the same steps (a different log) for the brightness part on warm/cold lightning... if you want obviously! thanks

2016for commented 5 years ago

@peter love your suggestion of using 2nd account (I have been doing that) however if someone doesn't want to do that and you still want the debug, you could maybe ask them to use Google Home/Alexa to change things on sonoff devices. :)

Just a suggestion for those who are unable to create multiple accounts.

On Tue, Apr 9, 2019 at 9:30 PM Peter Buga notifications@github.com wrote:

@stephanerosi https://github.com/stephanerosi i see that you're quite into helping soo regarding the rgb-offset problem do you think you can generate a more detailed debug log file for me?

here's what i need you to do:

  • download and install the latest master branch version, this will not have the sonoff b1 listed as a light (but as the old style as a switch, simply just ignore it for now)
  • in the project's documentation there's a new section regarding a new flag debug: True, read carefully the explanation and it'll be perfect if could use the shared sonoff device to a 2nd account setup.
  • after everything above is setup here comes the tricky part: i need you to execute an action on eWeLink app and right after that to take a screenshot of the colour represented on mobile app. it's very important that you execute 1 action and take 1 screenshot for it otherwise the log gets desynced. this way i will be able to match the expected colour with the data sent by mobile app and calculate the HA offset.

redo the same steps (a different log) for the brightness part on warm/cold lightning... if you want obviously! thanks

β€” You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/peterbuga/HASS-sonoff-ewelink/issues/34#issuecomment-481314223, or mute the thread https://github.com/notifications/unsubscribe-auth/AqJgbFHIMHl4NgeQvd6WOpaEq4hnV-Ltks5vfLkRgaJpZM4Z3Irq .

stephanerosi commented 5 years ago

@peterbuga Yes, I will do it and send the log/pictures.

One question : I'm not sure I understand what the 2nd account is for. Is it to limit the debug output to the bulb only ? Thanks

peterbuga commented 5 years ago

yes, limiting the log to only 1 device is one part of making the log lighter to read.

long story short-ish the 2nd account is to be able to control and query the device with HA and mobile application in the same time. due to a stupid limitation you can either connect to HA or to eWeLink app with the same account (you might've noticed that you need to login all the time into the app, that's because HA keep re-login in :P and kicking you out of the app, with shared devices you can be stay all the time logged in the app ;) )

stephanerosi commented 5 years ago

Ahah, I was wondering why the ewelink app was so buggy ;-)

Nevertheless, the following link contains the screenshots and the corresponding logs : https://drive.google.com/file/d/13UIm6bd4W6qdnXlAyCNGZzbJHCI9fpxQ/view?usp=drivesdk

peterbuga commented 5 years ago

@stephanerosi the logs are good but you didn't follow the steps as I mentioned them :P it would've been much easier for you + a richer log i'm highly interested in the websocket messages sent back by coolkit servers to communicate with the app (might be my lack of properly explaining it, i'll try to make it somehow clear πŸ˜“) for the record I was talking about this part from documentation:

debug if enabled this will give you the ability to generate a log of messages from ewelink that can be easily posted here to debug/implement new devices. it works by creating a pseudo switch switch.sonoff_debug (notice it won't show up automatically in frontend in lovelace you have to manually add it or toggle it manually from Developer tools > Services section). to generate a sonoff debug log toggle the pseudo-switch ON, the capture of messages starts in the background. now pick up the phone -> open eWeLink app and start changing settings of your Sonoff device but not faster than 10 seconds, when you finish, toggle the pseudo-switch OFF and a new (very long) persistent notification will show up, go to Developer tools > States section and look for a persistent_notification.notification entity (impossible to miss) and copy the message from there (to remove this notifications and others Dismiss them from main HA notifications area and you can restart the process if needed). INFORMATION: it'll be better if you share the device-to-debugged to a 2nd eWeLink account and use this in HA and main one in mobile app NOTICE: you should NOT leave debug-mode enabled for everyday use, please just please don't!

stephanerosi commented 5 years ago

@peterbuga My mistake, I wasn't the right debug section :-) (I was reading the one in sonoff-debug...)

Here is the log :

------------COPY-FROM-HERE-------------- 2019-04-10 21:53:42.432 [W] {"action": "update", "ts": 0, "deviceid": "1000371541", "userAgent": "app", "sequence": "1554926022755", "params": {"channel0": "0", "channel4": "0", "zyx_mode": 2, "channel1": "0", "channel3": "0", "channel2": "255", "type": "middle"}, "apikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "tempRec": "1000371541"} 2019-04-10 21:53:57.022 [W] {"action": "update", "ts": 0, "deviceid": "1000371541", "userAgent": "app", "sequence": "1554926037344", "params": {"channel0": "0", "channel4": "173", "channel1": "0", "channel3": "0", "channel2": "255", "zyx_mode": 2}, "apikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "tempRec": "1000371541"} 2019-04-10 21:54:10.953 [W] {"action": "update", "ts": 0, "deviceid": "1000371541", "userAgent": "app", "sequence": "1554926051256", "params": {"channel0": "0", "channel4": "255", "channel1": "0", "channel3": "0", "channel2": "111", "zyx_mode": 2}, "apikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "tempRec": "1000371541"} 2019-04-10 21:54:12.026 [W] {"action": "update", "ts": 0, "deviceid": "1000371541", "userAgent": "app", "sequence": "1554926052339", "params": {"channel0": "0", "channel4": "255", "channel1": "0", "channel3": "0", "channel2": "127", "zyx_mode": 2}, "apikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "tempRec": "1000371541"} 2019-04-10 21:54:28.330 [W] {"action": "update", "ts": 0, "deviceid": "1000371541", "userAgent": "app", "sequence": "1554926068632", "params": {"channel0": "0", "channel4": "255", "channel1": "0", "channel3": "71", "channel2": "0", "zyx_mode": 2}, "apikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "tempRec": "1000371541"} 2019-04-10 21:54:40.620 [W] {"action": "update", "ts": 0, "deviceid": "1000371541", "userAgent": "app", "sequence": "1554926080958", "params": {"channel0": "0", "channel4": "255", "channel1": "0", "channel3": "244", "channel2": "0", "zyx_mode": 2}, "apikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "tempRec": "1000371541"} 2019-04-10 21:54:55.059 [W] {"action": "update", "ts": 0, "deviceid": "1000371541", "userAgent": "app", "sequence": "1554926095370", "params": {"channel0": "0", "channel4": "95", "channel1": "0", "channel3": "255", "channel2": "0", "zyx_mode": 2}, "apikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "tempRec": "1000371541"} 2019-04-10 21:55:07.596 [W] {"action": "update", "ts": 0, "deviceid": "1000371541", "userAgent": "app", "sequence": "1554926107909", "params": {"channel0": "0", "channel4": "0", "channel1": "0", "channel3": "255", "channel2": "123", "zyx_mode": 2}, "apikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "tempRec": "1000371541"} 2019-04-10 21:55:18.846 [W] {"action": "update", "ts": 0, "deviceid": "1000371541", "userAgent": "app", "sequence": "1554926119198", "params": {"channel0": "0", "channel4": "0", "channel1": "0", "channel3": "215", "channel2": "255", "zyx_mode": 2}, "apikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "tempRec": "1000371541"} 2019-04-10 21:55:33.356 [W] {"action": "update", "ts": 0, "deviceid": "1000371541", "userAgent": "app", "sequence": "1554926133661", "params": {"channel0": "0", "channel4": "10", "channel1": "0", "channel3": "0", "channel2": "255", "zyx_mode": 2}, "apikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "tempRec": "1000371541"} ---------------END-OF-COPY----------------

Or via the states attributes

{ "title": "Sonoff debug", "message": ".\n--------------COPY-FROM-HERE--------------\n\n2019-04-10 21:53:42.432 [W] {\"action\": \"update\", \"ts\": 0, \"deviceid\": \"1000371541\", \"userAgent\": \"app\", \"sequence\": \"1554926022755\", \"params\": {\"channel0\": \"0\", \"channel4\": \"0\", \"zyx_mode\": 2, \"channel1\": \"0\", \"channel3\": \"0\", \"channel2\": \"255\", \"type\": \"middle\"}, \"apikey\": \"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\", \"tempRec\": \"1000371541\"}\n\n2019-04-10 21:53:57.022 [W] {\"action\": \"update\", \"ts\": 0, \"deviceid\": \"1000371541\", \"userAgent\": \"app\", \"sequence\": \"1554926037344\", \"params\": {\"channel0\": \"0\", \"channel4\": \"173\", \"channel1\": \"0\", \"channel3\": \"0\", \"channel2\": \"255\", \"zyx_mode\": 2}, \"apikey\": \"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\", \"tempRec\": \"1000371541\"}\n\n2019-04-10 21:54:10.953 [W] {\"action\": \"update\", \"ts\": 0, \"deviceid\": \"1000371541\", \"userAgent\": \"app\", \"sequence\": \"1554926051256\", \"params\": {\"channel0\": \"0\", \"channel4\": \"255\", \"channel1\": \"0\", \"channel3\": \"0\", \"channel2\": \"111\", \"zyx_mode\": 2}, \"apikey\": \"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\", \"tempRec\": \"1000371541\"}\n\n2019-04-10 21:54:12.026 [W] {\"action\": \"update\", \"ts\": 0, \"deviceid\": \"1000371541\", \"userAgent\": \"app\", \"sequence\": \"1554926052339\", \"params\": {\"channel0\": \"0\", \"channel4\": \"255\", \"channel1\": \"0\", \"channel3\": \"0\", \"channel2\": \"127\", \"zyx_mode\": 2}, \"apikey\": \"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\", \"tempRec\": \"1000371541\"}\n\n2019-04-10 21:54:28.330 [W] {\"action\": \"update\", \"ts\": 0, \"deviceid\": \"1000371541\", \"userAgent\": \"app\", \"sequence\": \"1554926068632\", \"params\": {\"channel0\": \"0\", \"channel4\": \"255\", \"channel1\": \"0\", \"channel3\": \"71\", \"channel2\": \"0\", \"zyx_mode\": 2}, \"apikey\": \"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\", \"tempRec\": \"1000371541\"}\n\n2019-04-10 21:54:40.620 [W] {\"action\": \"update\", \"ts\": 0, \"deviceid\": \"1000371541\", \"userAgent\": \"app\", \"sequence\": \"1554926080958\", \"params\": {\"channel0\": \"0\", \"channel4\": \"255\", \"channel1\": \"0\", \"channel3\": \"244\", \"channel2\": \"0\", \"zyx_mode\": 2}, \"apikey\": \"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\", \"tempRec\": \"1000371541\"}\n\n2019-04-10 21:54:55.059 [W] {\"action\": \"update\", \"ts\": 0, \"deviceid\": \"1000371541\", \"userAgent\": \"app\", \"sequence\": \"1554926095370\", \"params\": {\"channel0\": \"0\", \"channel4\": \"95\", \"channel1\": \"0\", \"channel3\": \"255\", \"channel2\": \"0\", \"zyx_mode\": 2}, \"apikey\": \"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\", \"tempRec\": \"1000371541\"}\n\n2019-04-10 21:55:07.596 [W] {\"action\": \"update\", \"ts\": 0, \"deviceid\": \"1000371541\", \"userAgent\": \"app\", \"sequence\": \"1554926107909\", \"params\": {\"channel0\": \"0\", \"channel4\": \"0\", \"channel1\": \"0\", \"channel3\": \"255\", \"channel2\": \"123\", \"zyx_mode\": 2}, \"apikey\": \"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\", \"tempRec\": \"1000371541\"}\n\n2019-04-10 21:55:18.846 [W] {\"action\": \"update\", \"ts\": 0, \"deviceid\": \"1000371541\", \"userAgent\": \"app\", \"sequence\": \"1554926119198\", \"params\": {\"channel0\": \"0\", \"channel4\": \"0\", \"channel1\": \"0\", \"channel3\": \"215\", \"channel2\": \"255\", \"zyx_mode\": 2}, \"apikey\": \"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\", \"tempRec\": \"1000371541\"}\n\n2019-04-10 21:55:33.356 [W] {\"action\": \"update\", \"ts\": 0, \"deviceid\": \"1000371541\", \"userAgent\": \"app\", \"sequence\": \"1554926133661\", \"params\": {\"channel0\": \"0\", \"channel4\": \"10\", \"channel1\": \"0\", \"channel3\": \"0\", \"channel2\": \"255\", \"zyx_mode\": 2}, \"apikey\": \"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\", \"tempRec\": \"1000371541\"}\n\n---------------END-OF-COPY----------------" }

And the screenshots Screenshots.zip

peterbuga commented 5 years ago

Perfect, thanks! I'll take a swing to it these days, I'm curious to see if I can sort it out πŸ˜…

@gregcsw could you please retry to test the bugs you reported above on the https://github.com/peterbuga/HASS-sonoff-ewelink/issues/34#issuecomment-480831044 they should be fixed by now... should