Roomba Home Automation with OpenHAB

Hello, i will share with you a example of controlling my Roomba with OpenHAB. The module used with the Roomba is RooWiFI. Here is the OpenHAB config i used for this example(Just replace the IP_ADDRESS with the IP address of your RooWifi module): Rules
var String Roomba_IP     = "http://admin:roombawifi@IP_ADDRESS/" var String myROOMBA_CLEAN =    "rwr.cgi?exec=4" var String myROOMBA_STOP =     "rwr.cgi?exec=6" var String myROOMBA_DOCK =     "rwr.cgi?exec=6" var String myROOMBA_OFF =     "rwr.cgi?exec=7" var String myROOMBA_ON =     "rwr.cgi?exec=10" //#####roomba clean rule "Roomba Clean" when Item Roomba_Clean changed to ON then var String url var String tmp var Integer timeout postUpdate(Roomba_Dock,OFF) postUpdate(Roomba_Clean,OFF) postUpdate(Roomba_Stop,OFF) url = Roomba_IP + myROOMBA_OFF timeout = 0 tmp = sendHttpGetRequest(url) logInfo("rule","URL: " + url + " --> " + tmp) while (!tmp.contains("1") && timeout < 10) { tmp = sendHttpGetRequest(url) Thread::sleep(5000) tmp = sendHttpGetRequest(url) logInfo("rule","(timeout=" + timeout + ") " + url + " --> " + tmp) timeout = timeout + 1 } url = Roomba_IP + myROOMBA_ON timeout = 0 tmp = sendHttpGetRequest(url) logInfo("rule","URL: " + url + " --> " + tmp) while (!tmp.contains("1") && timeout < 10) { tmp = sendHttpGetRequest(url) Thread::sleep(5000) tmp = sendHttpGetRequest(url) logInfo("rule","(timeout=" + timeout + ") " + url + " --> " + tmp) timeout = timeout + 1 } url = Roomba_IP + myROOMBA_CLEAN timeout = 0 tmp = sendHttpGetRequest(url) logInfo("rule","URL: " + url + " --> " + tmp) while (!tmp.contains("1") && timeout < 10) { Thread::sleep(5000) tmp = sendHttpGetRequest(url) logInfo("rule","(timeout=" + timeout + ") " + url + " --> " + tmp) timeout = timeout + 1 } else postUpdate(Roomba_Clean,OFF) end //#####roomba dock rule "Roomba Dock" when Item Roomba_Dock changed to ON then var String url var String tmp var Integer timeout postUpdate(Roomba_Dock,OFF) postUpdate(Roomba_Clean,OFF) postUpdate(Roomba_Stop,OFF) url = Roomba_IP + myROOMBA_OFF timeout = 0 tmp = sendHttpGetRequest(url) logInfo("rule","URL: " + url + " --> " + tmp) while (!tmp.contains("1") && timeout < 10) { tmp = sendHttpGetRequest(url) Thread::sleep(5000) tmp = sendHttpGetRequest(url) logInfo("rule","(timeout=" + timeout + ") " + url + " --> " + tmp) timeout = timeout + 1 } url = Roomba_IP + myROOMBA_ON timeout = 0 tmp = sendHttpGetRequest(url) logInfo("rule","URL: " + url + " --> " + tmp) while (!tmp.contains("1") && timeout < 10) { tmp = sendHttpGetRequest(url) Thread::sleep(5000) tmp = sendHttpGetRequest(url) logInfo("rule","(timeout=" + timeout + ") " + url + " --> " + tmp) timeout = timeout + 1 } url = Roomba_IP + myROOMBA_DOCK timeout = 0 tmp = sendHttpGetRequest(url) logInfo("rule","URL: " + url + " --> " + tmp) while (!tmp.contains("1") && timeout < 10) { Thread::sleep(5000) tmp = sendHttpGetRequest(url) logInfo("rule","(timeout=" + timeout + ") " + url + " --> " + tmp) timeout = timeout + 1 } else postUpdate(Roomba_Dock,OFF) end //#####Roomba Battery status rule "Roomba baterija" when Item roomba_b_capacity received update then var Integer baterija var Integer ukupno=roomba_b_capacity.state as DecimalType var Integer kapacitet=roomba_b_charge.state as DecimalType baterija=(kapacitet/ukupno)*100 roomba_capacity_percent.postUpdate(baterija) end //#####roomba stop rule "Roomba Stop" when Item Roomba_Stop changed to ON then var String url var String tmp var Integer timeout postUpdate(Roomba_Dock,OFF) postUpdate(Roomba_Clean,OFF) postUpdate(Roomba_Stop,OFF) url = Roomba_IP + myROOMBA_OFF timeout = 0 tmp = sendHttpGetRequest(url) logInfo("rule","URL: " + url + " --> " + tmp) while (!tmp.contains("1") && timeout < 10) { tmp = sendHttpGetRequest(url) Thread::sleep(5000) tmp = sendHttpGetRequest(url) logInfo("rule","(timeout=" + timeout + ") " + url + " --> " + tmp) timeout = timeout + 1 } url = Roomba_IP + myROOMBA_ON timeout = 0 tmp = sendHttpGetRequest(url) logInfo("rule","URL: " + url + " --> " + tmp) while (!tmp.contains("1") && timeout < 10) { tmp = sendHttpGetRequest(url) Thread::sleep(5000) tmp = sendHttpGetRequest(url) logInfo("rule","(timeout=" + timeout + ") " + url + " --> " + tmp) timeout = timeout + 1 } end
Sitemap
Text label="Usisavač (Roomba)" icon="roomba" { Frame label="Upravljanje" { Switch item=Roomba_Clean label="Čišćenje" mappings=[ON="Start"] icon="roomba" Switch item=Roomba_Dock label="Punjenje" mappings=[ON="Start"] icon="roomba" Switch item=Roomba_Stop label="Stop" mappings=[ON="Stop"] icon="roomba" } Frame label="Status" { Text item=roomba_charging_state label="Status [MAP(roomba.map):%s]" icon="roomba" Text item=roomba_voltage label="Napon baterije[%.0f mV]" icon="battery" visibility=[roomba_charging_state!="10"] valuecolor=[>13000="green",<13000="red"] Text item=roomba_current label="Struja [%.0f mA]" icon="voltage" visibility=[roomba_charging_state!="10"] valuecolor=[>0="green",<0="red"] Text item=roomba_b_capacity label="Maksimalni kapacitet [%.0f mAh]" icon="battery" visibility=[roomba_charging_state!="10"] Text item=roomba_b_charge label="Trenutni kapacitet [%.0f mAh]" icon="battery" visibility=[roomba_charging_state!="10"] valuecolor=[>1348="green",<1348="orange"] Text item=roomba_capacity_percent label="Stanje baterije [%.0f %%]" icon="battery" visibility=[roomba_charging_state!="10"] valuecolor=[>50="green",<50="red"] }}
Items
Switch Roomba_Clean // cleaning Switch Roomba_Dock // dock Switch Roomba_Stop    // stop Number roomba_voltage          (grp_roomba) { http="<[http://admin:roombawifi@IP_ADDRESS/rwr.xml:5000:REGEX(.*?<r15>(.*?)</r15>.*)]"} Number  roomba_temperature      (grp_roomba) Number  roomba_charging_state   (grp_roomba) { http="<[http://admin:roombawifi@IP_ADDRESS/rwr.xml:5000:REGEX(.*?<r14>(.*?)</r14>.*)]"} Number  roomba_current          (grp_roomba) { http="<[http://admin:roombawifi@IP_ADDRESS/rwr.xml:5000:REGEX(.*?<r16>(.*?)</r16>.*)]"} Number  roomba_b_charge         (grp_roomba) { http="<[http://admin:roombawifi@IP_ADDRESS/rwr.xml:5000:REGEX(.*?<r18>(.*?)</r18>.*)]"} Number  roomba_b_capacity       (grp_roomba) { http="<[http://admin:roombawifi@IP_ADDRESS/rwr.xml:5000:REGEX(.*?<r19>(.*?)</r19>.*)]"} Number  roomba_capacity_percent (grp_roomba)
Vanja Vršić
Vanja Vršić

Facebook YouTube 

Leave a Reply

Your email address will not be published. Required fields are marked *