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

[miio] Improve yeelight RGB with brightness, introduce substitutions #10984

Merged
merged 6 commits into from
Jul 17, 2021

Conversation

marcelrv
Copy link
Contributor

@marcelrv marcelrv commented Jul 12, 2021

Main changes

  • Introduce substitutions to allow to send commands containing current timestamp, deviceId or values from existing channels.
  • Allow more complex conversions to use values from other channels (in this case used for yeelight rgb channel)
  • Use generic way to call the asyncCommunication module
  • Fix mapping of yeelights color channel
  • Fix unit for yeelight delay

Signed-off-by: Marcel Verpaalen marcel@verpaalen.com

marcelrv added 4 commits July 12, 2021 15:31
This will allow to send right commands for gateway and lumi devices

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
@marcelrv marcelrv added the enhancement An enhancement or new feature for an existing add-on label Jul 12, 2021
@marcelrv marcelrv requested a review from fwolter July 12, 2021 20:08
}

public int queueCommand(String command, String params, String cloudServer)
public int queueCommand(String command, String params, String cloudServer, String sender)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: the String sender is used in the next coming PR. already adding it to avoid merge issues while completing the development of the PR.

Copy link
Contributor

@mesetka mesetka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did the same changes in my fork few hours ago and tested with Yeelight lightstrip plus, worked properly. But i'm still in doubt, if there is a different logic in methods and status report.
And a question about Color mode channel - as I see it's supposed to run a method "set_power", "on", "smooth", "$value", so Yeelight device should react to channel switch by powering on in that color state? It doesn't. The channel is changing value only when i send rgb or ct commands.

@marcelrv
Copy link
Contributor Author

Did the same changes in my fork few hours ago and tested with Yeelight lightstrip plus, worked properly. But i'm still in doubt, if there is a different logic in methods and status report.
And a question about Color mode channel - as I see it's supposed to run a method "set_power", "on", "smooth", "$value", so Yeelight device should react to channel switch by powering on in that color state? It doesn't. The channel is changing value only when i send rgb or ct commands.

Yes, the command is send as that is according the yeelight spec ( https://www.yeelight.com/download/Yeelight_Inter-Operation_Spec.pdf begin page 12), and (prior this PR) I don't know the values for the color/temperature when I just switch mode. Now with this PR in place, indeed we may change the logic and indeed use the set_rgb / set_ct_abx methods instead if that solves the issue

@marcelrv
Copy link
Contributor Author

different logic in methods and status report

note the strange part in the spec regarding the mode... according the spec, you switch on with these values:
1: Turn on and switch to CT mode.
2: Turn on and switch to RGB mode.

however, in status and other commands it is actually reported as 1: RGB, 2: CT. which is why I fixed the mapping in this PR

@marcelrv
Copy link
Contributor Author

NOTE: Jenkins build error is unrelated to the PR

@mesetka
Copy link
Contributor

mesetka commented Jul 13, 2021

different logic in methods and status report

note the strange part in the spec regarding the mode... according the spec, you switch on with these values:
1: Turn on and switch to CT mode.
2: Turn on and switch to RGB mode.

however, in status and other commands it is actually reported as 1: RGB, 2: CT. which is why I fixed the mapping in this PR

Tested! No errors in docs - it's indeed like described! In method power_on 1 is for CT and 2 is for RGB, and in status report 1 is for RGB and 2 is for CT. I guess you should apply some further changes to fix mapping for power_on method.
Why I am adressing this - I try to adopt community-made widget for Yeelight control and have some issues trying to switch between RGB and CT modes. I had to create an unlinked Color mode item - then this widget works properly, switching between modes and just sending RGB or CT values to Yeelight through your binding, but I think it's not a totally correct way.

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
@marcelrv
Copy link
Contributor Author

@mesetka I pushed now a change that works for me locally using the alternative commands.
The number now corrosponds with the right text and is switching when clicked

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
@kaikreuzer kaikreuzer added rebuild Triggers Jenkins PR build and removed rebuild Triggers Jenkins PR build labels Jul 15, 2021
Copy link
Member

@fwolter fwolter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fwolter fwolter merged commit 5671f09 into openhab:main Jul 17, 2021
@fwolter fwolter added this to the 3.2 milestone Jul 17, 2021
@marcelrv marcelrv deleted the miio-substitutions_v2 branch July 18, 2021 18:22
dw-8 pushed a commit to dw-8/openhab-addons that referenced this pull request Jul 25, 2021
…penhab#10984)

* [miio] add deviceId and timestamp substitutions

This will allow to send right commands for gateway and lumi devices

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>

* [miio] update brightness in yeelight RGB channel

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>

* [miio] Use generic way to call the asyncCommunication module

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>

* [miio] Fix mapping yeelight

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>

* [miio] Improve Yeelight colormode mapping

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>

* [miio] yeelight fix unit for delayed off

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
Signed-off-by: dw-8 <davy.wong.on+github@gmail.com>
dw-8 added a commit to dw-8/openhab-addons that referenced this pull request Jul 25, 2021
dw-8 pushed a commit to dw-8/openhab-addons that referenced this pull request Jul 25, 2021
…penhab#10984)

* [miio] add deviceId and timestamp substitutions

This will allow to send right commands for gateway and lumi devices

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>

* [miio] update brightness in yeelight RGB channel

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>

* [miio] Use generic way to call the asyncCommunication module

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>

* [miio] Fix mapping yeelight

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>

* [miio] Improve Yeelight colormode mapping

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>

* [miio] yeelight fix unit for delayed off

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
Signed-off-by: dw-8 <davy.wong.on+github@gmail.com>
dw-8 added a commit to dw-8/openhab-addons that referenced this pull request Jul 25, 2021
…tutions (openhab#10984)"

This reverts commit afe9142.

Signed-off-by: dw-8 <davy.wong.on+github@gmail.com>
@marcelrv marcelrv mentioned this pull request Aug 15, 2021
26 tasks
frederictobiasc pushed a commit to frederictobiasc/openhab-addons that referenced this pull request Oct 26, 2021
…penhab#10984)

* [miio] add deviceId and timestamp substitutions

This will allow to send right commands for gateway and lumi devices

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>

* [miio] update brightness in yeelight RGB channel

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>

* [miio] Use generic way to call the asyncCommunication module

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>

* [miio] Fix mapping yeelight

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>

* [miio] Improve Yeelight colormode mapping

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>

* [miio] yeelight fix unit for delayed off

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
thinkingstone pushed a commit to thinkingstone/openhab-addons that referenced this pull request Nov 7, 2021
…penhab#10984)

* [miio] add deviceId and timestamp substitutions

This will allow to send right commands for gateway and lumi devices

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>

* [miio] update brightness in yeelight RGB channel

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>

* [miio] Use generic way to call the asyncCommunication module

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>

* [miio] Fix mapping yeelight

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>

* [miio] Improve Yeelight colormode mapping

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>

* [miio] yeelight fix unit for delayed off

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
marcfischerboschio pushed a commit to bosch-io/openhab-addons that referenced this pull request May 5, 2022
…penhab#10984)

* [miio] add deviceId and timestamp substitutions

This will allow to send right commands for gateway and lumi devices

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>

* [miio] update brightness in yeelight RGB channel

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>

* [miio] Use generic way to call the asyncCommunication module

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>

* [miio] Fix mapping yeelight

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>

* [miio] Improve Yeelight colormode mapping

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>

* [miio] yeelight fix unit for delayed off

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature for an existing add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants