Hello
After hours of not being successful I take the liberty to post my problem into this community.
I’m trying to access LaMetric via the device API. It works with Python and when testing with Postman but I’m unable to make it work as a rule in openhab. I know that there is a binding for laMetric now, but Im trying to get in work with the API to be more flexible.
my code ist as follows
// LaMetric Test for posting Messages
import java.net.URLEncoder
rule "Testnotifikation LaMetric"
when
Item Xi_TFS_WohnenLinks_OpenStatus changed
then
var String notification_endpoint = "http://192.168.1.xx:8080/api/v2/device/notifications"
var headers = "{Accept: application/json, Authorization: Basic ZGV2OjZmY1Nmz}"
var String request
request = notification_endpoint + headers
request = URLEncoder::encode(request, "ISO-8859-1")
var data = String::format('{
"priority": "warning",
"icon_type":"info",
"lifeTime":<milliseconds>,
"model": {
"cycles": 1,
"frames": [{
"icon": 15795,
"text": "%1$s"
}
],
"sound": {
"category": "notifications",
"id": "letter_email"
}
}
}', Xi_TFS_WohnenLinks_OpenStatus.state.toString)
if (Xi_TFS_WohnenLinks_OpenStatus.state == OPEN) {
sendHttpPostRequest(request, "application/json", data)
logInfo("httpPostTest", "Terrassentüre opened")
}
else {
sendHttpPostRequest(request, "application/json", data)
logInfo("httpPostTest", "Terrassentüre closed")
}
end
It seems to be a problem with the format of the headers. Has someone experience with this?
Thanks a lot in advance.
Jan