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

Reset Bulb to white #7

Closed
RadioBon opened this issue May 3, 2021 · 13 comments
Closed

Reset Bulb to white #7

RadioBon opened this issue May 3, 2021 · 13 comments
Labels
waiting-for-requestor Waiting for the requestor to provide more info

Comments

@RadioBon
Copy link

RadioBon commented May 3, 2021

Hi again Aymkdn,

Sorry man, I'm just playing with colorSet, works great, thank you!

I wonder though, is there a quick shortcut to reset the bulb to standard white? In the Tuya app you can select all colors, as the api lets us, but you can also set the bulb back to a standard "white". Is there a quick way to do that in TuyaCloud? I think in the app it just disables the color LED's and uses the white ones only?

Thanks,

Ian

@Aymkdn
Copy link
Owner

Aymkdn commented May 3, 2021

Maybe you can set the different values to the "white" numbers?

I'm not sure, but it could be:

  • "hue" => 0
  • "saturation" => 0
  • "brightness" => 255

@RadioBon
Copy link
Author

RadioBon commented May 3, 2021

Hey mate,

0,0,255 gives a kind of sickly blue! Do you have any code that will query the HSB settings of a bulb? Then I can set it to the default warm white from the app, and query the settings to clone them into my script?

Thanks,

Ian

@Aymkdn
Copy link
Owner

Aymkdn commented May 3, 2021

You may want to change down the brightness. Check this HSB Color Picker https://codepen.io/HunorMarton/details/eWvewo?

Maybe by using getState() or getDevices() will get you the info about the light color?

@RadioBon
Copy link
Author

RadioBon commented May 3, 2021

I'm looking at the JSON object returned. If I've been tampering with the HSB values in the app, the bulb returns ;

stdClass Object
(
    [data] => stdClass Object
        (
            [brightness] => 255
            [color_mode] => colour
            [online] => 1
            [state] => true
        )

    [name] => Kitchen Ceiling
    [icon] => https://images.tuyaeu.com/smart/icon/1467167733_0.png
    [id] => 7577######
    [dev_type] => light
    [ha_type] => light
)

but if I set it to standard White in the app, then scan it, it returns this ;

stdClass Object
(
    [data] => stdClass Object
        (
            [brightness] => 255
            [color_mode] => white
            [online] => 1
            [state] => false
        )

    [name] => Kitchen Ceiling
    [icon] => https://images.tuyaeu.com/smart/icon/1467167733_0.png
    [id] => 7577######
    [dev_type] => light
    [ha_type] => light
)

So, the [color_mode] is changed, but tuyacloud-php doesn't handle that object. I think it needs a trap somewhere around line 155 to detect a call for color_mode being set to the default white to switch it back from the HSB color mode? Any thoughts?

Ian

@Aymkdn
Copy link
Owner

Aymkdn commented May 3, 2021

OK, good to know. In the Python code, there are some stuff related to it. I'll need to have a look.

@RadioBon
Copy link
Author

RadioBon commented May 3, 2021

Ok, I'll keep playing, and if I solve it I'll chuck you a patch proposal, but I'm rubbish at hacking other peoples work!

@Aymkdn
Copy link
Owner

Aymkdn commented May 3, 2021

I'm not sure it's possible to change from color to white with the API.

Maybe look at these two comments to see if it helps:

If yes, let me know.

@Aymkdn Aymkdn added the waiting-for-requestor Waiting for the requestor to provide more info label May 3, 2021
@RadioBon
Copy link
Author

RadioBon commented May 3, 2021

I'll keep experimenting, no success so far. It's just about changing the mode, and pushing back to the api 'color_mode'.

@no-response no-response bot removed the waiting-for-requestor Waiting for the requestor to provide more info label May 3, 2021
@RadioBon
Copy link
Author

RadioBon commented May 3, 2021

I think we need to alter this? ;

function setState($options) {
// by default we want to turn on or off
if (!isset($options['command'])) $options['command']='turnOnOff';
// transform "on" and true to 1
// transform "off" and false to 0
$value = $options['value'];
if ($value === true || $value === 'on') $value=1;
else if ($value === false || $value === 'off') $value=0;

From onOff to mode, and add an option, perhaps we need it to be 'off', 'color' or 'white'? Off is obvious and remains as is, On should go, 'color' should call the HSB value as was stored on the server, and 'white' should kick it to the standard white state?

@Aymkdn
Copy link
Owner

Aymkdn commented May 3, 2021

Based on the conversations I told you to read, I don't think it's possible...

@RadioBon
Copy link
Author

RadioBon commented May 3, 2021

I'm working on it... (It's raining and a bank holiday here in UK, in covid lockdown, it's the most interesting thing to do today!)

@Aymkdn
Copy link
Owner

Aymkdn commented May 4, 2021

Any progress?

Did you try to play with brightness values as suggested in the comment?

I've noticed that if I force my lights to use the larger brightness range (10-1000) in the integration settings in HA I can force them to switch back from color mode to white mode

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

no-response bot commented May 9, 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 May 9, 2021
@AndreXori AndreXori mentioned this issue Sep 8, 2021
@cocobln cocobln mentioned this issue Oct 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-for-requestor Waiting for the requestor to provide more info
Projects
None yet
Development

No branches or pull requests

2 participants