control data All questions

I discovered a "control data" option for my white bulbs and it seems as if i can use this to set my bulbs to a variable brightness/temperature value, but i keep getting "Error: type is incorrect" in the sequence log. I've tried a bunch of things, could someone tell me what i am doing wrong?

Triggered manually by user
The Livingroom light 1 control_data was set to {"change_mode":"direct","bright":500,"temperature":800,"h":300,"s":345,"v":485}
 Error: type is incorrect

Triggered manually by user
The Livingroom light 1 control_data was set to { "commands":[ { "code":"control_data", "value":{ "change_mode":"direct", "bright":500, "temperature":800, "h":201, "s":611, "v":999 } } ] }
 Error: type is incorrect

Triggered manually by user
The Livingroom light 1 control_data was set to {"change_mode":"direct","bright":500,"temperature":800,"h":201,"s":61,"v":99}
 Error: type is incorrect
The Livingroom light 1 control_data was set to {"change_mode":"gradient","bright":500,"temperature":800,"h":300,"s":345,"v":485}
 Error: type is incorrect

Asked by vinny on September 13, 2021, at 10:52pm

Hi Vinny, someone else actually asked a similar question at one point.  I provide an answer there but never heard back, so not sure if this will work but let's see!

SEQUEmatic actually adds the "commands" part of the JSON so you don't need that.  You just need the "value" component. Can you try changing the 'value' in the step to the following:

{ "change_mode":"direct", "bright":500, "temperature":800, "h":201, "s":611, "v":999 }

Let me know if that works for you.

Hi, i have already tried without the commands part, but that did not work so i figured i would try it with the commands part included.

I also tried it on different white bulbs (from different brands) but it does not work on either, i also tried to set scene data instead (not that i need that, but just to try) and that also gave an error.

I now also tried the json you suggested in the other question, that also does not work.

the only thing that is working is setting colour data for my RGB bulb.

Bit offtopic, but my white bulbs also have a rhythm/sleep and wake-up mode for the property field but none of those actually change anything to my light.


Triggered manually by user
The Livingroom (RBG) colour_data was set to {"h":0,"s":255,"v":255}
The Livingroom light 1 control_data was set to { "change_mode":"direct", "bright":500, "temperature":800, "h":201, "s":611, "v":999 }
 Error: type is incorrect
The Bathroom light control_data was set to { "change_mode":"direct", "bright":500, "temperature":800, "h":201, "s":611, "v":999 }
 Error: type is incorrect
The Livingroom light 1 scene_data_v2 was set to { "scene_num":5, "scene_units":[ { "unit_change_mode":"static", "unit_switch_duration":20, "unit_gradient_duration":20, "h":201, "s":611, "v":999, "bright":500,
 Error: type is incorrect
The Livingroom light 1 control_data was set to {"change_mode":"direct","bright":500}
 Error: type is incorrect

Hi Vinny, I've looked in the logs but can't see anything more there that would help work out the problem here.  The exact error back from Tuya is "Error: type is incorrect".  They don't provide any more info in their docs either.  It's error code 1104 on this page.

I can only suggest some trial and error here.  Can you try setting the hsv values to match your successful colour_data request?

Also try removing some of the parameters you're passing to change_mode or try different values - eg maybe your device doesn't support brightness of 500, or temperature 800.

Some of these parts of the API can be a bit hit and mess depending on the device. Since they're all made by different manufacturers they don't always support all the APIs.  Ideally options such as change_mode shouldn't be available if the device doesn't support it, but that isn't always the case.

I've tried changing the parameters, but still no luck. I don't know what else i can try, according to that page it should give a different error if the parameters were out of range.. I've send a message to tuya support hopefully they can explain why this is not working..


The Livingroom light 1 control_data was set to { "change_mode":"direct", "bright":50, "temperature":80, "h":20, "s":60, "v":99 }
 Error: type is incorrect

The Livingroom light 1 control_data was set to { "change_mode":"direct", "bright":5, "temperature":8, "h":2, "s":6, "v":9 }
 Error: type is incorrect

Ah ok, that was going to be my next step. Let me know what they come back with.

They are actually responding pretty quickly, i was not expecting that, what i got back this morning was this;


loading...

Tuya engineer09-26 07:37:43
Hello, check the format of the BODY entry parameter for your reference { "commands": [ { "code": "control_data", "value": { "bright":10, "change_mode":"direct", "temperature":572, "h":0, "s":0, "v":0 } } ] }

The order of things is slightly different here, and I've tried this aswell but i'm still getting the same error.

The Livingroom light 1 control_data was set to "value": { "bright":10, "change_mode":"direct", "temperature":572, "h":0, "s":0, "v":0 } } ] }
 Error: type is incorrect
The Livingroom light 1 control_data was set to {"value": { "bright":10, "change_mode":"direct", "temperature":572, "h":0, "s":0, "v":0 } } ] }
 Error: type is incorrect
The Livingroom light 1 control_data was set to { "bright":10, "change_mode":"direct", "temperature":572, "h":0, "s":0, "v":0 }
 Error: type is incorrect
The Livingroom light 1 control_data was set to { "value": { "bright":10, "change_mode":"direct", "temperature":572, "h":50, "s":50, "v":50 } } ] }
 Error: type is incorrect
The Livingroom light 1 control_data was set to { "commands": [ { "code": "control_data", "value": { "bright":10, "change_mode":"direct", "temperature":572, "h":0, "s":0, "v":0 } } ] }
 Error: type is incorrect

The first entry in your post looks correct to me:

"value": { "bright":10, "change_mode":"direct", "temperature":572, "h":0, "s":0, "v":0 } } ] }

I'm having trouble finding this in the logs though. Can you run the sequence again with just that value and then post the timestamp back here so I can check the logs?  I want to make sure SEQUEmatic is converting it into the correct body data for Tuya.

Here you go;


1 - TEST was triggered on Tue 28 Sep at 14:24:38.

Triggered manually by user
The Livingroom light 1 control_data was set to "value": { "bright":10, "change_mode":"direct", "temperature":572, "h":0, "s":0, "v":0 } } ] }
 Error: type is incorrect

Also tried it with slightly different numbers;

1 - TEST was triggered on Tue 28 Sep at 14:25:54.

Triggered manually by user
The Livingroom light 1 control_data was set to "value": { "bright":100, "change_mode":"direct", "temperature":572, "h":100, "s":100, "v":100 } } ] }
 Error: type is incorrect

Ok, here's what was sent in the body of the request to Tuya for the second request.  I think I've found the problem!  SEQUEmatic is adding the "value" parameter so that's not required in what you're typing in.  I've highlighted in red what SEQEUmatic is adding.

{"commands":[{"code":"control_data","value":""value": {"bright":100, "change_mode":"direct", "temperature":572, "h":100, "s":100, "v":100 } } ] }"}]}

So I think all you need is this:

{"bright":100, "change_mode":"direct", "temperature":572, "h":100, "s":100, "v":100 } } ] }

Although looking at your earlier posts I think you've already tried that?

I don't remember if i already tried it like that before, but i have now:


1 - TEST was triggered on Wed 29 Sep at 14:45:00.

Triggered manually by user
The Livingroom light 1 control_data was set to {"bright":100, "change_mode":"direct", "temperature":572, "h":100, "s":100, "v":100 } } ] }
 Error: type is incorrect

But what the tuya support said was to use this:

{"commands": [{"code": "control_data","value":{"bright":10,"change_mode":"direct","temperature":572,"h":0,"s":0,"v":0}}]}
 
And now you say it is sending this:

{"commands":[{"code":"control_data","value":"{"bright":10,"change_mode":"direct","temperature":572,"h":0,"s":0,"v":0}}]}"}]}

Those 5 characters that are highlighted in red don't seem to exist in the example from tuya support, could that be the issue?

Hi Vinny, good pick up! I was reviewing it too late last night and didn't notice these extra characters.  I think you've found a bug here - when creating the JSON, SEQUEmatic is adding additional wrapping that isn't needed.

I've run a few tests on your account, so don't be surprised when you see entries in the sequence log.  I'm hoping I've fixed it now though so don't want to run another test in case it triggers your light.

Can you try running it one more time?

Hmm, i don't know, it seems that something else got messed up now;


1 - TEST was triggered on Thu 30 Sep at 13:43:46.

Triggered manually by user
The Livingroom light 1 control_data was set to {"bright":100, "change_mode":"direct", "temperature":572, "h":100, "s":100, "v":100 }
 Error: param is illegal ,please check it

1 - TEST was triggered on Thu 30 Sep at 13:47:43.

Triggered manually by user
The Livingroom light 1 control_data was set to {"bright":100, "change_mode":"direct", "temperature":572, "h":0, "s":0, "v":0 }
 Error: param is illegal ,please check it

My other sequence, that uses the switch_led option in the property field, is also no longer working;

Livingroom light 1 was triggered on Thu 30 Sep at 13:46:07.

The variable Livingroom light 1 changed from on to off
The value of the variable Livingroom light 1 was off (not on - condition failed)
The value of the variable Livingroom light 1 was off (condition passed)
The Livingroom light 1 switch_led was set to
 Error: param is illegal ,please check it

Ok, I think I see the problem. Can you give it one more try?

IT WORKS NOW!!


1 - TEST was triggered on Thu 30 Sep at 14:44:54.

Triggered manually by user
The Livingroom light 1 control_data was set to {"bright":100, "change_mode":"direct", "temperature":572, "h":0, "s":0, "v":0 }

1 - TEST was triggered on Thu 30 Sep at 14:46:44.

Triggered manually by user
The Livingroom light 1 control_data was set to {"bright":1000, "change_mode":"gradient", "temperature":0, "h":0, "s":0, "v":0 }

1 - TEST was triggered on Thu 30 Sep at 14:46:17.

Triggered manually by user
The Livingroom light 1 control_data was set to {"bright":1000, "change_mode":"gradient", "temperature":1000, "h":0, "s":0, "v":0 }

This is really good, the brightness and temperature are both changing! (I'm not really seeing a difference between gradient and direct change modes)

Thank you very much man! You are the best!

To correct myself:

There actually is a noticeable difference between the direct and gradient change modes, i gues i was just expecting the gradient to be alot longer then half a second.. Crazy that we can do this through sequematic though, the smart life app itself doesn't even have this option..

I just noticed that my other sequence (the one that uses the switch_led property) is still not working though, maybe those 5 extra characters were actually neccecary for the other property's?


Livingroom light 1 was triggered on Thu 30 Sep at 15:12:33.

The variable Livingroom light 1 changed from on to off
The value of the variable Livingroom light 1 was off (not on - condition failed)
The value of the variable Livingroom light 1 was off (condition passed)
The Livingroom light 1 switch_led was set to
 Error: param is illegal ,please check it

Haha you're welcome!  Glad it's working. I wonder if there's a parameter you can set to change the gradient duration?

I should be able to fix your other sequences on the weekend.  I actually only applied the fix yesterday to your account in case it did have adverse side effects.  I might need to add something extra to check on the type of value being passed - if it's JSON don't add the extra bits, and if it's just a single value then add those extra brackets.

I'll reply back over the weekend once it's fixed.

I don't think there is a way to change the gradient duration but that is fine.

I just wanted to say that it is also fine by me if you just leave it as is, i can simply create tap-to-runs in the smartlife app to turn devices on/off and then run those tap-to-runs in sequematic, that still works.

Hi Vinny, sorry I didn't get a chance to come back to this last week. I'm not sure if you've modified Livingroom light 1 but I've made changes so that it should work now.

You should be able to successfully pass JSON for the control_data and also pass a regular string or number in the Livingroom light 1 sequence.

Let me know if it's working as expected.

No problem man, i just tested it again, it still does not work as expected 😛

The work-mode property for my RGB bulb does work again, which is great, but the switch-led property is still giving an error:


Livingroom - Light 1 was triggered on Sat 9 Oct at 13:18:43.

The variable Livingroom light 1 changed from off to on
The value of the variable Livingroom light 1 was on (condition passed)
The Livingroom light 1 switch_led was set to 1
 Error: type is incorrect

I found another way to (sort of) turn my bulb on and off, simply by changing the brightness parameter in the control data json. If i set it to 0 the bulb will dim completely and it looks as if it is turned off, it also looks very smooth to turn it on and off this way because of the gradient mode!

The bulb might use more power this way (being at 0% brightness instead of being turned off), i will test that tommorrow, but that might just be worth it because it looks so good turning on and off. 😆

Clever way to get around it! You could also add another step after that to turn off the light. Visually nothing would happen because brightness would already be 0 but at least you'll know it's off and using the least amount of power possible.

If that command happens too quickly after the brightness adjustment you could add a short pause between the two so the light can fade out first.

That is also very clever! Unfortunately i ran into some problems with this idea..


I have a sequence that returns my lights to 100% brightness at sunrise, so if i were to leave them at 0% they will turn on at sunrise.. 🤣

I also have automations in the smartlife app to turn lights on, because it's alot faster, but smartlife is not very smart, no variables etc.. So if the bulb was set to 0% and then turned off smartlife automations will still turn it on, but it can't remember the previous brightness and it just goes to 1%.

Also for turning on it does not look smooth if it actually has to turn on first, i can see it turn on and then there is a short pause before the brightness starts increasing. (i have not added any pause myself)

I will have to do alot more thinking to see if i can find a way to make this work.. 🤣

Hi there, 

For some reason, the same control_data JSON that worked for Vinny above isn't working for me, even though my Smart Life light has the same JSON specs (as shown in the sequence editor).

I get the following:

Room light full control was triggered on Tue 30 Nov at 17:40:36.

Triggered manually by user
The Gabriel room control_data was set to {"bright":100, "change_mode":"direct", "temperature":572, "h":0, "s":0, "v":0 }
 Error: type is incorrect

I'm not sure if anything can be done to fix this, but I'm rather confused. Any help would be greatly appreciated :)

Hi Gabriel, I've made a small change in the code. Can you try again and let me know if this now works?

It works! Thank you so much! 

Hey, so now I'm trying to control my light with parameters passed from a webhook, and it seems one value is being substituted but not the other.

Room light Powershell script was triggered on Sun 5 Dec at 9:47:34.

Triggered by a custom webhook (https://sequematic.com/trigger-custom-webhook/<removed>/80753/500/500) from IP <removed>
The Gabriel room control_data was set to {"change_mode":"gradient", "bright": {brt}, "temperature": 500, "h":0, "s":0, "v":0}
 Error: param is illegal ,please check it

I have tried multiple different names and orders for the two sequence parameters, and in every case, only the last parameter is substituted correctly, whereas the first stays as {name}. 

Hi Gabriel, you've stumbled across a bug there.  I've fixed this now so your parameters should pass through fine.

All good now, thanks!

Post a reply

The SEQUEmatic bot is still new and learning. If you don't get the answer you need, just ask to speak with Derek and your chat will be transferred.