Hi guys,
after upgrade my OH from 2.5 to 3, my ac python script is not working anymore.
So i decided to change to the http binding, because it is now possible to control the ac with the samsung things rest api.
With postman everything works fine.
But i got stuck with the http binding, because i wasn´t able to send the right json body to the rest api.
There are two different URL´s, one for status, and one for control.
So i made two things which have their own items - one with status items, and one with control items.
The status rest api works well:
Thing http:url:Klima_WZ_Status "Klima WZ Status" [
baseURL="https://api.smartthings.com/v1/devices/<my device>/status",
headers="Authorization=Bearer <my bearer>", "Content-Type=application/json",
refresh=60] {
Channels:
Type string : Betriebsart "Betriebsart" [stateTransformation="jsonpath:$.components.main.airConditionerMode.airConditionerMode.value", commandTransformation="jsonpath:$.components.main.airConditionerMode.airConditionerMode.value"]
Type switch : Schalter "Ein/Aus" [stateTransformation="jsonpath:$.components.main.switch.switch.value", commandTransformation="jsonpath:$.components.main.switch.switch.value", onValue="on", offValue="off"]
Type string : Ventilator "Ventilator_Modus" [stateTransformation="jsonpath:$.components.main.airConditionerFanMode.fanMode.value", commandTransformation="jsonpath:$.components.main.airConditionerFanMode.fanMode.value"]
Type number : Temperatur_Ist "Ist Temperatur" [stateTransformation="jsonpath:$.components.main.temperatureMeasurement.temperature.value", commandTransformation="jsonpath:$.components.main.temperatureMeasurement.temperature.value"]
Type number : Temperatur_Soll "Soll Temperatur" [stateTransformation="jsonpath:$.components.main.thermostatCoolingSetpoint.coolingSetpoint.value", commandTransformation="jsonpath:$.components.main.thermostatCoolingSetpoint.coolingSetpoint.value"]
}
With that state informations, my state itmes triggers - with rules - the corntrol items.
according to the logs, Rules, triggers and Items states also works as expected.
Here is my control thing,
Thing http:url:Klima_WZ_Control "Klima WZ Control" [
baseURL="https://api.smartthings.com/v1/devices/<my device>/commands",
headers="Authorization=<my bearer>", "Content-Type=application/json",
commandMethod="POST",
stateMethod="POST",
refresh=86400] {
Channels:
Type string : Betriebsart_Control "Betriebsart Control" [commandTransformation="jsonpath:$.component.main.capability.airConditionerMode.command.value"]
Type switch : Schalter_Control "Ein/Aus Control" [commandTransformation="JINJA:{\"component\":\"main\", \"capability\":\"switch\",\"command\":\"{{value}}\"}", onValue="on", offValue="off"]
Type string : Ventilator_Control "Ventilator_Modus Control" [commandTransformation="JINJA:{\"component\":\"main\", \"capability\":\"airConditionerFanMode\",\"command\":\"{{value}}\"}"]
Type number : Temperatur_Soll_Control "Soll Temperatur Control" [commandTransformation="JINJA:{\"component\":\"main\", \"capability\":\"thermostatCoolingSetpoint\",\"command\":\"{{value}}\"}"]
}
My Problem is, that i am not able to create the right json body.
i tried with jsonpath - that only works for incomming calls - if i understand it right.
And with JINJA, that should work for post commands, but that also doesn´t work.
in fact it should be quite smiple, but i didn´t find, which parser i had to use and how the string had to look like.
To turn on the AC, the Body in raw format, to the command url above, has to like like this:
[{"component":"main","capability":"switch","command":"on"}]
i hope you can give me some advices
BR
vaillan