jparthum
(Jason Parthum)
March 6, 2019, 9:12am
1
In Dev Tools/Services, this works:
Service: light.turn_on
Entity: light.0620011084f3eb43a8d0
Service Data:
{
"entity_id": "light.0620011084f3eb43a8d0",
"brightness": "255",
"transition": "2"
}
…but this…
Service Data:
{
"entity_id": "light.0620011084f3eb43a8d0",
"brightness": "255",
"transition": "2",
"rgb_color": "[255, 255, 255]"
}
…results in “Failed to call service light/turn_on.”
I’ve also tried "hs_color": "[0,0]"
and "xy_color": "[0.323,0.329]"
and get the same failure message.
No errors are generated in the log file.
All three color attributes are listed in Dev Tools/States:
What am I doing wrong?
Pippyn
March 6, 2019, 9:24am
2
dont include the brackets. It should be:
"rgb_color": "255,255,255"
jparthum
(Jason Parthum)
March 6, 2019, 9:37am
3
Sorry I didn’t mention it in the OP but I tried that too out of desperation and it also failed.
I thought CSVs (or at least comma separated numerals) had to be enclosed in brackets…?
Pippyn
March 6, 2019, 9:43am
4
I’m sorry I got it wrong.
I just tested it, it should be no quotes…
"rgb_color": [255,255,255]
jparthum
(Jason Parthum)
March 6, 2019, 9:48am
5
That’s it!
Man, I thought tried every conceivable syntax but I never would have guessed the quotes should be omitted.
Thank you, Pippyn .
1 Like
m0wlheld
(Christoph Dahlen)
March 6, 2019, 10:35am
6
With quotes, it’s a string, without quotes but with square brackets, it’s an array (of numbers in this case).
jparthum
(Jason Parthum)
March 6, 2019, 10:48am
7
I thought the brackets were needed for arrays but I thought the quotes were needed (additionally) as a syntax requirement in JSON. But I guess now that I think about it, the curly brackets {}
already designate the data parsed as JSON…?
jparthum
(Jason Parthum)
March 6, 2019, 8:28pm
9
Ha! So – as I just learned and confirmed by testing – this also works:
“transition”: 2
Great tips. Thanks, m0wlheld .