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

Color Set #5

Closed
bon-the-one opened this issue Mar 27, 2021 · 13 comments
Closed

Color Set #5

bon-the-one opened this issue Mar 27, 2021 · 13 comments
Labels
enhancement New feature or request waiting-for-requestor Waiting for the requestor to provide more info

Comments

@bon-the-one
Copy link

Hi Aymkdn,

Nice code in tuyacloud-php, and can set brightness, power for a bulb. How can I set a color though please? It is not documented?

Thanks,
Bon

@Aymkdn
Copy link
Owner

Aymkdn commented Mar 27, 2021

Check

* -> "colorSet" (value is hsv_color)

You should be able to use colorSet. I don't use it and I'm not at home this weekend. So try to investigate on your side, and let me know. If you don't understand what to do, I'll try to help you on Tuesday.

@Aymkdn Aymkdn added the waiting-for-requestor Waiting for the requestor to provide more info label Mar 27, 2021
@bon-the-one
Copy link
Author

Hi Aymkdn,

Thanks for reply, have a good weekend!

I'm experimenting with HSV values but none change the bulb. I think it's the format I'm sending the request in, but there is no error trapping, so I'm shooting in the dark. Have sent many different format values before bothering you, and am now stuck!

Tuesday is no prob if you have a chance to experiment then,

Thanks,

Bon

@no-response no-response bot removed the waiting-for-requestor Waiting for the requestor to provide more info label Mar 27, 2021
@Aymkdn
Copy link
Owner

Aymkdn commented Mar 30, 2021

I don't have a lightbulb, but based on https://github.com/PaulAnnekov/tuyaha/blob/5c47ce40062ab388af994299d6cf63c4add4f899/tuyaha/devices/light.py#L145-L154:

        hsv_color = {
            "hue": color[0] if color[1] != 0 else 0,  # color white
            "saturation": color[1] / 100,
        }
        if len(color) < 3:
            hsv_color["brightness"] = cur_brightness
        else:
            hsv_color["brightness"] = color[2]
        # color white
        white_mode = hsv_color["saturation"] == 0

And based on https://github.com/PaulAnnekov/tuyaha/blob/cd9baa85052028fdcf6f1ed222fb6f188016cd06/tuyaha/devices/light.py#L156:

   if self._control_device("colorSet", {"color": hsv_color}):

It seems the hsv_color format should be a JSON object (see this issue for some examples):

{
  "color": {
    "hue":40,
    "saturation":255,
    "brightness":255
  }
}

Then the command might be:

$tuya->setState([
  "name" => "lightbulb 1",
  "command" => "colorSet",
  "value" => [
    "color" => [
      "hue" => 40,
      "saturation" => 255,
      "brightness" => 255
    ]
  ]
]);

But I think it won't work (based on this example).

If it doesn't work, then try to replace

"value" => $value

with:

        "color" => $value

And then call it with:

$tuya->setState([
  "name" => "lightbulb 1",
  "command" => "colorSet",
  "value" => [
    "hue" => 40,
    "saturation" => 255,
    "brightness" => 255
  ]
]);

Please, let me know the result of your tests and I'll update the file based on your feedback.

@Aymkdn Aymkdn added the waiting-for-requestor Waiting for the requestor to provide more info label Mar 30, 2021
@no-response
Copy link

no-response bot commented Apr 4, 2021

This issue has been automatically closed because the requestor didn't provide any additional comment.

@no-response no-response bot closed this as completed Apr 4, 2021
@jonshuttsnap40
Copy link

Just looked at this, but adding "color" => $options['color']' into the tuyacloud.php, then passing in color with the 3 values worked. May try and make a PR

@Aymkdn
Copy link
Owner

Aymkdn commented Apr 6, 2021

OK Great! I'll modify my code by the end of the week!

@Aymkdn Aymkdn reopened this Apr 6, 2021
@Aymkdn Aymkdn added enhancement New feature or request and removed waiting-for-requestor Waiting for the requestor to provide more info labels Apr 6, 2021
Aymkdn added a commit that referenced this issue Apr 10, 2021
@Aymkdn
Copy link
Owner

Aymkdn commented Apr 10, 2021

I've just published a new version: can you try it, please?

It will check if the command is colorSet and in that case it will use color instead of value in what is sent to the server. Also I've added some additional info in the "documentation".

So if you try the below with the new version, it should work:

$tuya->setState([
  "name" => "lightbulb 1",
  "command" => "colorSet",
  "value" => [
    "hue" => 40,
    "saturation" => 255,
    "brightness" => 255
  ]
]);

As well as:

$tuya->setState([
  "name" => "lightbulb 1",
  "command" => "turnOnOff",
  "value" => 0
]);

@Aymkdn Aymkdn added the waiting-for-requestor Waiting for the requestor to provide more info label Apr 10, 2021
@no-response
Copy link

no-response bot commented Apr 15, 2021

This issue has been automatically closed because the requestor didn't provide any additional comment.

@no-response no-response bot closed this as completed Apr 15, 2021
@AndreXori AndreXori mentioned this issue Sep 8, 2021
@cocobln cocobln mentioned this issue Oct 12, 2021
@hochland123
Copy link

Hello,
I've a problem to set brigtness on my dimmer. On/Off works fine. But "colorset" doesn't.

$tuya->setState([ "name" => "PV Dimmer", "command" => "colorSet", "value" => [ "brightness" => 10 ] ]);

@Aymkdn
Copy link
Owner

Aymkdn commented Jul 8, 2022

Did you try to define all hue, saturation and brightness?

$tuya->setState([
  "name" => "PV Dimmer",
  "command" => "colorSet",
  "value" => [
    "hue" => 40,
    "saturation" => 255,
    "brightness" => 255
  ]
]);

@hochland123
Copy link

Yes, but also no function. A dimmer has no hue and saturation.

@Aymkdn
Copy link
Owner

Aymkdn commented Jul 8, 2022

I moved your issue to there: #13

@hochland123
Copy link

What does it mean?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request waiting-for-requestor Waiting for the requestor to provide more info
Projects
None yet
Development

No branches or pull requests

4 participants