The binding is awesome work however I not using currently as wife uses old remote and I use the google home sometimes.
I have 2 Sensibo Sky units working currently in my rules. These update all states to openhab periodically. So you can send Sensibo the command that the state the aircon is in. Sensibo ignores this so to me that’s ok.
Rules
/*** openHAB Sensibo Rules ***/
// Goto the website https://home.sensibo.com/me/api first and create APIKey
val String APIKey = "<Enter API key>"
var PodID_01 = "<enter your pod id here>" //Living Room
var PodID_02 = "<enter your pod id here>" //Bedroom
rule "Read Sensibo State PodID_01"
when
System started or
Time cron "0 0/5 * * * ?" //Update states from senibo every 5 min
then
//Thread::sleep(1000)
try {
var String PodStatus
do {
Thread::sleep(5000)
PodStatus = executeCommandLine('curl -sSH "Accept: application/json" "https://home.sensibo.com/api/v2/pods/' + PodID_01 + '/acStates?apiKey=' + APIKey + '&limit=1&fields=acState"', 5000)
//logInfo("Sensibo result - PodStatus", PodStatus)
} while (!PodStatus.contains('"status": "success"'))
val String PodOn = (transform("JSONPATH", "$.result[0].acState.on", PodStatus))
val String PodMode = (transform("JSONPATH", "$.result[0].acState.mode", PodStatus))
val Number PodTarget = new Integer(transform("JSONPATH", "$.result[0].acState.targetTemperature", PodStatus))
val String PodFan = (transform("JSONPATH", "$.result[0].acState.fanLevel", PodStatus))
postUpdate(Sensibo_Living_State, PodOn)
postUpdate(Sensibo_Living_Target, PodTarget)
postUpdate(Sensibo_Living_Mode, PodMode)
postUpdate(Sensibo_Living_Fan, PodFan)
if (PodStatus.contains('"swing": ')) {
val String PodSwing = (transform("JSONPATH", "$.result[0].acState.swing", PodStatus))
postUpdate(Sensibo_Living_Swing, PodSwing)
}
}
catch(Throwable t) {
logError("Sensibo read state", "Error was caught: {}", t)
}
end
rule "Read Sensibo Measurements PodID_01"
when
Time cron "0 0/5 * * * ?" //Update states from senibo every 5 min
then
try {
var String PodMeasurements
do {
PodMeasurements = executeCommandLine('curl -sSH "Accept: application/json" "https://home.sensibo.com/api/v2/pods/' + PodID_01 + '/measurements?apiKey=' + APIKey + '&fields=temperature,humidity,batteryVoltage"', 5000)
//logInfo("Sensibo result - PodMeasurements", PodMeasurements)
Thread::sleep(5000)
} while (!PodMeasurements.contains('"status": "success"'))
var PodTemperature = new Double(transform("JSONPATH", "$.result[0].temperature", PodMeasurements))
var PodHumidity = new Double(transform("JSONPATH", "$.result[0].humidity", PodMeasurements))
postUpdate(Sensibo_Living_Temp, PodTemperature)
postUpdate(Sensibo_Living_Humidity, PodHumidity)
if (!PodMeasurements.contains('"batteryVoltage": null')) {
val Number PodBattery = new Integer(transform("JSONPATH", "$.result[0].batteryVoltage", PodMeasurements))
postUpdate(Sensibo_Living_Battery, PodBattery)
}
}
catch(Throwable e) {
logError("Sensibo measurements", "Error was caught: {}", e)
}
end
rule "Write Sensibo State PodID_01"
when
Item Sensibo_Living_State received command or
Item Sensibo_Living_Mode received command or
Item Sensibo_Living_Fan received command or
Item Sensibo_Living_Swing received command or
Item Sensibo_Living_Target received command
then
try {
//Thread::sleep(1000) // Avoid race condition where state has not yet been updated
var CommandURL = 'https://home.sensibo.com/api/v2/pods/' + PodID_01 + '/acStates?apiKey=' + APIKey
var CommandState = '{"acState":{"on":' + Sensibo_Living_State.state + ','
var CommandMode = '"mode":"' + Sensibo_Living_Mode.state + '",'
var CommandFan = '"fanLevel":"' + Sensibo_Living_Fan.state + '",'
var CommandSwing = ""
if (Sensibo_Living_Swing.state != "")
{ CommandSwing = '"swing":"' + Sensibo_Living_Swing.state + '"}}' }
var String CommandTemp = '"targetTemperature":' + (Sensibo_Living_Target.state as DecimalType).intValue + ','
var String CommandTempUnit = '"temperatureUnit":"C",'
var String CommandData = CommandState + CommandMode + CommandFan + CommandTemp + CommandTempUnit + CommandSwing
var String UpdateResult
var Number Attempts = 0
var CommandExec = 'curl@@-sSH@@"Accept: application/json"@@-H@@"Content-Type: application/json"@@-X@@POST@@-d@@' + CommandData + '@@' + CommandURL
do {
Attempts += 1
//logInfo("Sensibo command", CommandData)
UpdateResult = executeCommandLine(CommandExec, 10000)
//logInfo("Sensibo result", UpdateResult)
Thread::sleep(5000)
} while (!UpdateResult.contains('"status": "success"') && Attempts < 5)
if (Attempts == 5) {
logError("Sensibo write", "5 failures updating Sensibo")
}
}
catch(Throwable t) {
logError("Sensibo write", "Error was caught: {}", t)
}
end
/*** Bedroom Sensibo ***/
rule "Read Sensibo State PodID_02"
when
System started or
Time cron "0 0/5 * * * ?" //Update states from senibo every 5 min
then
//Thread::sleep(1000)
try {
var String PodStatus
do {
Thread::sleep(5000)
PodStatus = executeCommandLine('curl -sSH "Accept: application/json" "https://home.sensibo.com/api/v2/pods/' + PodID_02 + '/acStates?apiKey=' + APIKey + '&limit=1&fields=acState"', 5000)
//logInfo("Sensibo result - PodStatus", PodStatus)
} while (!PodStatus.contains('"status": "success"'))
val String PodOn = (transform("JSONPATH", "$.result[0].acState.on", PodStatus))
val String PodMode = (transform("JSONPATH", "$.result[0].acState.mode", PodStatus))
val Number PodTarget = new Integer(transform("JSONPATH", "$.result[0].acState.targetTemperature", PodStatus))
val String PodFan = (transform("JSONPATH", "$.result[0].acState.fanLevel", PodStatus))
postUpdate(Sensibo_Bedroom_State, PodOn)
postUpdate(Sensibo_Bedroom_Target, PodTarget)
postUpdate(Sensibo_Bedroom_Mode, PodMode)
postUpdate(Sensibo_Bedroom_Fan, PodFan)
if (PodStatus.contains('"swing": ')) {
val String PodSwing = (transform("JSONPATH", "$.result[0].acState.swing", PodStatus))
postUpdate(Sensibo_Bedroom_Swing, PodSwing)
}
}
catch(Throwable t) {
logError("Sensibo read state", "Error was caught: {}", t)
}
end
rule "Read Sensibo Measurements PodID_02"
when
Time cron "0 0/5 * * * ?" //Update states from senibo every 5 min
then
try {
var String PodMeasurements
do {
PodMeasurements = executeCommandLine('curl -sSH "Accept: application/json" "https://home.sensibo.com/api/v2/pods/' + PodID_02 + '/measurements?apiKey=' + APIKey + '&fields=temperature,humidity,batteryVoltage"', 5000)
//logInfo("Sensibo result - PodMeasurements", PodMeasurements)
Thread::sleep(5000)
} while (!PodMeasurements.contains('"status": "success"'))
var PodTemperature = new Double(transform("JSONPATH", "$.result[0].temperature", PodMeasurements))
var PodHumidity = new Double(transform("JSONPATH", "$.result[0].humidity", PodMeasurements))
postUpdate(Sensibo_Bedroom_Temp, PodTemperature)
postUpdate(Sensibo_Bedroom_Humidity, PodHumidity)
if (!PodMeasurements.contains('"batteryVoltage": null')) {
val Number PodBattery = new Integer(transform("JSONPATH", "$.result[0].batteryVoltage", PodMeasurements))
postUpdate(Sensibo_Bedroom_Battery, PodBattery)
}
}
catch(Throwable e) {
logError("Sensibo measurements Bedroom", "Error was caught: {}", e)
}
end
rule "Write Sensibo State PodID_02"
when
Item Sensibo_Bedroom_State received command or
Item Sensibo_Bedroom_Mode received command or
Item Sensibo_Bedroom_Fan received command or
Item Sensibo_Bedroom_Swing received command or
Item Sensibo_Bedroom_Target received command
then
try {
//Thread::sleep(1000) // Avoid race condition where state has not yet been updated
var CommandURL = 'https://home.sensibo.com/api/v2/pods/' + PodID_02 + '/acStates?apiKey=' + APIKey
var CommandState = '{"acState":{"on":' + Sensibo_Bedroom_State.state + ','
var CommandMode = '"mode":"' + Sensibo_Bedroom_Mode.state + '",'
var CommandFan = '"fanLevel":"' + Sensibo_Bedroom_Fan.state + '",'
var CommandSwing = ""
if (Sensibo_Bedroom_Swing.state != "")
{ CommandSwing = '"swing":"' + Sensibo_Bedroom_Swing.state + '"}}' }
var String CommandTemp = '"targetTemperature":' + (Sensibo_Bedroom_Target.state as DecimalType).intValue + ','
var String CommandTempUnit = '"temperatureUnit":"C",'
var String CommandData = CommandState + CommandMode + CommandFan + CommandTemp + CommandTempUnit + CommandSwing
var String UpdateResult
var Number Attempts = 0
var CommandExec = 'curl@@-sSH@@"Accept: application/json"@@-H@@"Content-Type: application/json"@@-X@@POST@@-d@@' + CommandData + '@@' + CommandURL
do {
Attempts += 1
//logInfo("Sensibo command", CommandData)
UpdateResult = executeCommandLine(CommandExec, 10000)
//logInfo("Sensibo result", UpdateResult)
Thread::sleep(5000)
} while (!UpdateResult.contains('"status": "success"') && Attempts < 5)
if (Attempts == 5) {
logError("Sensibo write", "5 failures updating Sensibo")
}
}
catch(Throwable t) {
logError("Sensibo write", "Error was caught: {}", t)
}
end
Items
String Sensibo_Living_State
Number Sensibo_Living_Temp
Number Sensibo_Living_Humidity
Number Sensibo_Living_Battery
Number Sensibo_Living_Target
String Sensibo_Living_Fan
String Sensibo_Living_Mode
String Sensibo_Living_Swing
String Sensibo_Bedroom_State
Number Sensibo_Bedroom_Temp
Number Sensibo_Bedroom_Humidity
Number Sensibo_Bedroom_Battery
Number Sensibo_Bedroom_Target
String Sensibo_Bedroom_Fan
String Sensibo_Bedroom_Mode
String Sensibo_Bedroom_Swing
Sitemap Example
sitemap sensibo label="Sensibo" {
Frame label="Sensibo Living" {
Switch item=Sensibo_Living_State label="Sensibo_Living_State" mappings=["true"="ON", "false"="OFF"] icon="switch"
Switch item=Sensibo_Living_Mode label="Mode" icon="heating" mappings=[cool="Cool",heat="Heat",fan="Fan"]
Setpoint item=Sensibo_Living_Target label="Target [%.0f ºC]" icon="temperature" minValue=18 maxValue=26 step=1.0
Switch item=Sensibo_Living_Fan label="Fan" icon="fan" mappings=[low="Low",medium="Med",high="High",auto="Auto"]
Switch item=Sensibo_Living_Swing label="Swing" icon="fan" mappings=[stopped="Stop",fixedMiddle="Middle",fixedTop="High",rangeFull="Swing"]
Text item=Sensibo_Living_Temp label="Temperature [%.1f ºC]" icon="temperature"
Text item=Sensibo_Living_Humidity label="Humidity [%.0f %%]" icon="water"
// Text item=Sensibo_Living_Battery label="Battery [%d mV]" icon="energy"
}
Frame label="Sensibo Bedroom" {
Switch item=Sensibo_Bedroom_State label="Sensibo Bedroom State" mappings=["true"="ON", "false"="OFF"] icon="switch"
Switch item=Sensibo_Bedroom_Mode label="Mode" icon="heating" mappings=[cool="Cool",heat="Heat",fan="Fan"]
Setpoint item=Sensibo_Bedroom_Target label="Target [%.0f ºC]" icon="temperature" minValue=18 maxValue=26 step=1.0
Switch item=Sensibo_Bedroom_Fan label="Fan" icon="fan" mappings=[low="Low",medium="Med",high="High",auto="Auto"]
Switch item=Sensibo_Bedroom_Swing label="Swing" icon="fan" mappings=[stopped="Stop",fixedMiddle="Middle",fixedTop="High",rangeFull="Swing"]
Text item=Sensibo_Bedroom_Temp label="Temperature [%.1f ºC]" icon="temperature"
Text item=Sensibo_Bedroom_Humidity label="Humidity [%.0f %%]" icon="water"
// Text item=Sensibo_Bedroom_Battery label="Battery [%d mV]" icon="energy"
}
}
I hard coded the api and pod_id because you only do it once.
However @Zodiarc Looks like he is doing a binding that will fill in that data for you. I am new to this and am quickly learning how to do stuff. Also @Zodiarc “I’ll add the rest as soon as I can solve my current problem” maybe it is something we can help you with. I probably won’t be able to help but if I know what the problem is I or others may be able to help. If it all comes together in binding I won’t have to rewrite all of my rules to use PATCH instead of posting all of the commands again to Sensibo
Keep up the good work. I have a solution running and am not trying to hurry you at all.