Hi, I have being attempting to send the instructions "ON' & "OFF' to my air-conditioner utilising the Codesys WebClient and a Sensibo controller. Sensibo's RESTful API is built on HTTP and it accepts and returns JSon in the HTTP body.
Whilst I can log into the Sensibo site https://home.sensibo.com/api/v2/users/me/pods?fields=*&apiKey={api_key}utilising with my API key issued by Sensibo, I cannot send the ON/Off instructions. I believe this is meant to happen via the wsPostValue : WSTRING(100) in WebClient but I cannot make this work. The 'curl-X POST' expression supplied by Sensibo is:curl -X POST https://home.sensibo.com/api/v2/pods//acStates?apiKey={api_key} -d "{\"acState\":{\"on\":true}}"`
I have tried every variation of "{\"acState\":{\"on\":true}}" as a string in wsPostValue to no avail.... but as is probably becoming obvious, I am no programmer.
I am using SP17 & a RPi and receive no errors accept those relating to the wsPostValue. This issue stands between me and a successful home heating automation outcome. Any help would be appreciated.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Just updating my understanding till now. The WebClient wsPostValue ie'load' required to Post instructions is written as a WSTRING. In Codesys, WSTRINGS must be written between double quote marks " ". However, Jason also requires the use of double quotes around "names" & "values". The clash is, Codesys will not accept a double quote mark inside a WSTRING and so a valid Json command cannot be written as a WSTRING in the Codesys WebClient. I read on one post that placing a $ sign before the inner double quote solves this but that has not worked for me. Json apparently uses a back slash for this purpose also, but Codesys rejects that too. Any ideas guys?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The saga continues: So I can now send a Json string to Sensibo the from Codesys webClient if I send:
"{$"acState$":{$"on$":true}}" instead of "{"acState":{"on":TRUE}}"
But Sensibo does not respond to this string !!!! Apparently using \ instead of the $ is recognised by Sensibo, but Codesys rejects the \ in the WSTRING.
Any (polite)suggestions would be gratefully received.
Bernie_BBQ
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I can now control my AC from a RPI 2 utilisng Codesys and its webClient. Usernames or passwords are not required. I modified the BasicAuthWebClient function as shown.
Hi, I have being attempting to send the instructions "ON' & "OFF' to my air-conditioner utilising the Codesys WebClient and a Sensibo controller. Sensibo's RESTful API is built on HTTP and it accepts and returns JSon in the HTTP body.
Whilst I can log into the Sensibo site https://home.sensibo.com/api/v2/users/me/pods?fields=*&apiKey={api_key}
utilising with my API key issued by Sensibo, I cannot send the ON/Off instructions. I believe this is meant to happen via the wsPostValue : WSTRING(100) in WebClient but I cannot make this work. The 'curl-X POST' expression supplied by Sensibo is:
curl -X POST https://home.sensibo.com/api/v2/pods//acStates?apiKey={api_key} -d "{\"acState\":{\"on\":true}}"`I have tried every variation of "{\"acState\":{\"on\":true}}" as a string in wsPostValue to no avail.... but as is probably becoming obvious, I am no programmer.
I am using SP17 & a RPi and receive no errors accept those relating to the wsPostValue. This issue stands between me and a successful home heating automation outcome. Any help would be appreciated.
Just updating my understanding till now. The WebClient wsPostValue ie'load' required to Post instructions is written as a WSTRING. In Codesys, WSTRINGS must be written between double quote marks " ". However, Jason also requires the use of double quotes around "names" & "values". The clash is, Codesys will not accept a double quote mark inside a WSTRING and so a valid Json command cannot be written as a WSTRING in the Codesys WebClient. I read on one post that placing a $ sign before the inner double quote solves this but that has not worked for me. Json apparently uses a back slash for this purpose also, but Codesys rejects that too. Any ideas guys?
The saga continues: So I can now send a Json string to Sensibo the from Codesys webClient if I send:
"{$"acState$":{$"on$":true}}" instead of "{"acState":{"on":TRUE}}"
But Sensibo does not respond to this string !!!! Apparently using \ instead of the $ is recognised by Sensibo, but Codesys rejects the \ in the WSTRING.
Any (polite)suggestions would be gratefully received.
Bernie_BBQ
OK, success at last! "{$"acState$":{$"on$":true}}" instead of "{"acState":{"on":TRUE}}" does work with the following sURL:
'https://home.sensibo.com/api/v2/pods/{deviceID}/acStates?apiKey={API_key_supplied_by_Sensibo}'
I can now control my AC from a RPI 2 utilisng Codesys and its webClient. Usernames or passwords are not required. I modified the BasicAuthWebClient function as shown.