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

Strange behavior with moonlight mode in homekit scenes #68

Closed
spn91 opened this issue Feb 23, 2020 · 9 comments
Closed

Strange behavior with moonlight mode in homekit scenes #68

spn91 opened this issue Feb 23, 2020 · 9 comments
Labels

Comments

@spn91
Copy link

spn91 commented Feb 23, 2020

Hello @vieira and @okonet,

maybe one of you could help me with my problem. The plugin is working really well, but i have observed a strange behavior when transitioning from normal mode to moonlight or vice versa.
When i set in a scene, that it should turn on moonlight mode, but i also want to change the brightness of the moonlight, this is not always working. Most of the time, just the normal light mode stays activated and nothing happens. But for other ceiling lights which are in the same scene, this is working.
Maybe this have something to do with the sequence how the commands are sent to the light.
I am using the models ceiling3 and ceiling15.

@okonet
Copy link
Collaborator

okonet commented Feb 23, 2020

Yeah I’m aware of that behavior. It’s because setting the moonlight mode is being a setting the brightness with a special arguments. That’s why the second set brightness overrides it I believe. I would need to spend more time investigating but one solution I thought I’d try is to only use brightness and make last 10% of it act as moonlight mode. That should theoretically solve this issue. Maybe you could try implementing it as well?

@spn91
Copy link
Author

spn91 commented Feb 25, 2020

Ok, that is fine that you are already aware of it. I can have a look at it, but I have absolut no experience with programming for homebridge.
Something I have also noticed today. I have different scenes at homekit. One is to have a warm white light with the ceiling lamps and another one is for having a cold light for concentrating. The scene with warm white was active -> I activated a scene which turns off all my lights in the living room -> Then i came back and activated the scene for concentrating -> Just one ceiling light turned on and changed to orange, the other two turned on and stayed at blue.
Are you also aware of this problem? It happens not always, but sometimes.

@okonet
Copy link
Collaborator

okonet commented Feb 25, 2020

No. Sounds like a separate one though. You’d need to take a look at logs

@okonet
Copy link
Collaborator

okonet commented Feb 25, 2020

As for experience: I didn’t have any either. Check out the readme as I tried to make it as simple as possible.

@okonet
Copy link
Collaborator

okonet commented Feb 25, 2020

@malmentm
Copy link

malmentm commented Mar 4, 2020

It might be better to let the moonight switch turn of the lamp completely instead of just turn off the moonlight mode. I also have trouble make this work any good in automations

@bendobos
Copy link

Hi @okonet,
I am experiencing the same issue and took a look at it myself, with the intention to implement the "last 10%" solution you suggested.

I did some tests first using the Debug mode and I am not sure if this really is the correct solution.
I set up an automation using a switch, that sets both Moonlight mode on and a brightness. According to the logs, I get these requests:

[3/11/2020, 7:39:24 PM] [Yeelight] nl_br is not supported in Homekit, skipping.
  EventedHTTPServer [::ffff:192.168.86.20] Sending HTTP event '2.14' with data: {"characteristics":[{"aid":2,"iid":14,"value":true}]} +6s
  EventedHTTPServer [::ffff:192.168.86.37] Sending HTTP event '2.14' with data: {"characteristics":[{"aid":2,"iid":14,"value":true}]} +0ms
  EventedHTTPServer [::ffff:192.168.86.20] Sending HTTP event '2.14' with data: {"characteristics":[{"aid":2,"iid":14,"value":false}]} +103ms
  EventedHTTPServer [::ffff:192.168.86.37] Sending HTTP event '2.14' with data: {"characteristics":[{"aid":2,"iid":14,"value":false}]} +1ms
[3/11/2020, 7:39:24 PM] [Yeelight] active_bright is not supported in Homekit, skipping.

If I understand correctly, iid: 14 is the requests for setting moonlight mode. It seems weird to me that it is set to true, then to false immediately.

When I run the automation with moonlight mode disabled, I get this:

  EventedHTTPServer [::ffff:192.168.86.20] Sending HTTP event '2.10' with data: {"characteristics":[{"aid":2,"iid":10,"value":80}]} +11s
  EventedHTTPServer [::ffff:192.168.86.37] Sending HTTP event '2.10' with data: {"characteristics":[{"aid":2,"iid":10,"value":80}]} +1ms

I'm asking myself why the requests are so weird when setting both at the same time. I'd expect to see a request for setting moonlight mode on, and a request for setting the brightness.

It's my first time working with homebridge, so some more pointers would be appreciated.

@okonet
Copy link
Collaborator

okonet commented Mar 11, 2020

@bendobos thanks for working on it. I believe the issue you're seeing is exactly why it is an issue with the current implementation. For some reason, there is no API for moonlight mode Yeelight provide developers with so basically to turn this mode on or off you're forced to use set_power command:

params: ['on', 'smooth', transition, state ? 5 : 1],

See the spec: https://www.yeelight.com/download/Yeelight_Inter-Operation_Spec.pdf

I don't know why setting the brightness interfere with it but my idea was, instead of calling two commands, to only call set_power when the change of mode is detected. Maybe this will help.

I propose you draft a PR and I'll take a look at it when I have a bit more time.

@okonet okonet closed this as completed in 535c7c1 Aug 29, 2020
@github-actions
Copy link

🎉 This issue has been resolved in version 2.2.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants