You are right.
Now my work around is working like this:
Light Template:
- platform: template
lights:
dicroica_teste_escritorio:
unique_id: dicroica_teste_escritorio
friendly_name: "Dicroica Teste - Escritório"
value_template: "{{ states('input_boolean.status_dicroica_1_escritorio') }}"
level_template: "{{ states('input_number.brilho_dicroica_1_escritorio') | int }}"
turn_off:
- service: input_boolean.turn_off
data_template:
entity_id:
- input_boolean.status_dicroica_1_escritorio
- service: rest_command.status_dicroica_ihost
data: { "sn": "dasdasdas", "n1": "power", "n2": "powerState", "state": "off"}
turn_on:
- service: input_boolean.turn_on
data_template:
entity_id:
- input_boolean.status_dicroica_1_escritorio
- service: rest_command.status_dicroica_ihost
data: { "sn": "dasdasdas", "n1": "power", "n2": "powerState", "state": "on"}
set_level:
- service: input_number.set_value
data:
value: "{{ brightness | int }}"
target:
entity_id: input_number.brilho_dicroica_1_escritorio
- service: rest_command.status_dicroica_ihost
data: >
{
"sn": "dasdasdas",
"n1": "brightness",
"n2": "brightness",
"state": "{{ (brightness * 0.392156862745098) | round(2) }}"
}
set_temperature:
- service: input_number.set_value
data:
value: "{{ color_temp }}"
entity_id: input_number.temperatura_cor_dicroica_1_escritorio
- service: rest_command.status_dicroica_ihost
data: >
{
"sn": "dasdasdas",
"n1": "color-temperature",
"n2": "colorTemperature",
"state": "{{ (100 - ((color_temp | int - 152) / 1.74)) | round(2)}}"
}
set_color:
- service: input_number.set_value
data:
value: "{{ h }}"
entity_id: input_number.hue_dicroica_1_escritorio
- service: input_number.set_value
data:
value: "{{ s }}"
entity_id: input_number.sat_dicroica_1_escritorio
- service: rest_command.color_dicroica_ihost
data: >
{
"sn": "dasdasdas",
"h": {{h}},
"s": {{s}},
"v": {{ states('input_number.brilho_dicroica_1_escritorio') }}
}
And my RESTful Command:
status_dicroica_ihost:
url: http://192.168.xxxxx/open-api/v1/rest/devices/{{sn}}
method: PUT
headers:
Authorization: "Bearer xxxxxxxxxxxxxxxxxxxx"
accept: "application/json, text/html"
payload: >
{
"state": {
{%- if "power" in n1 -%}
"power": {
"powerState": "{{state}}"
}
{%- else -%}
"power": {
"powerState": "on"
},
"{{n1}}": {
"{{n2}}": {{state}}
}
{%- endif -%}
}
}
content_type: 'application/json; charset=utf-8'
verify_ssl: false
color_dicroica_ihost:
url: http://192.168.xxxxx/open-api/v1/rest/devices/{{sn}}
method: PUT
headers:
Authorization: "Bearer xxxxxxxxxxxxxxxxxxxxx"
accept: "application/json, text/html"
payload: >
{
"state": {
"power": {
"powerState": "on"
},
{%- if (((h / 360) * 6) | round(0, 'floor')) % 6 == 0 -%}
"color-rgb": {
"red": {{ ((v / 255) * 255) | round(2, 'ceil') }},
"green": {{ (((v / 255) * (1 - (1 - (((h / 360) * 6) - (((h / 360) * 6) ))) * (s / 100))) * 255) | round(2, 'ceil') }},
"blue": {{ (((v / 255) * (1 - (s / 100))) * 255) | round(2, 'ceil') }}
}
{%- elif (((h / 360) * 6) | round(0, 'floor')) % 6 == 1 -%}
"color-rgb": {
"red": {{ (((v / 255) * (1 - (((h / 360) * 6) - (((h / 360) * 6) )) * (s / 100))) * 255) | round(2, 'ceil') }},
"green": {{ ((v / 255) * 255) | round(2, 'ceil') }},
"blue": {{ (((v / 255) * (1 - (s / 100))) * 255) | round(2, 'ceil') }}
}
{%- elif (((h / 360) * 6) | round(0, 'floor')) % 6 == 2 -%}
"color-rgb": {
"red": {{ (((v / 255) * (1 - (s / 100))) * 255) | round(2, 'ceil') }},
"green": {{ ((v / 255) * 255) | round(2, 'ceil') }},
"blue": {{ (((v / 255) * (1 - (1 - (((h / 360) * 6) - (((h / 360) * 6) ))) * (s / 100))) * 255) | round(2, 'ceil') }}
}
{%- elif (((h / 360) * 6) | round(0, 'floor')) % 6 == 3 -%}
"color-rgb": {
"red": {{ (((v / 255) * (1 - (s / 100))) * 255) | round(2, 'ceil') }},
"green": {{ (((v / 255) * (1 - (((h / 360) * 6) - (((h / 360) * 6) )) * (s / 100))) * 255) | round(2, 'ceil') }},
"blue": {{ ((v / 255) * 255) | round(2, 'ceil') }}
}
{%- elif (((h / 360) * 6) | round(0, 'floor')) % 6 == 4 -%}
"color-rgb": {
"red": {{ (((v / 255) * (1 - (1 - (((h / 360) * 6) - (((h / 360) * 6) ))) * (s / 100))) * 255) | round(2, 'ceil') }},
"green": {{ (((v / 255) * (1 - (s / 100))) * 255) | round(2, 'ceil') }},
"blue": {{ ((v / 255) * 255) | round(2, 'ceil') }}
}
{%- elif (((h / 360) * 6) | round(0, 'floor')) % 6 == 5 -%}
"color-rgb": {
"red": {{ ((v / 255) * 255) | round(2, 'ceil') }},
"green": {{ (((v / 255) * (1 - (s / 100))) * 255) | round(2, 'ceil') }},
"blue": {{ (((v / 255) * (1 - (((h / 360) * 6) - (((h / 360) * 6) )) * (s / 100))) * 255) | round(2, 'ceil') }}
}
{%- endif -%}
}
}
content_type: 'application/json; charset=utf-8'
verify_ssl: false
It’s not pretty, but is working fine.