iRobot 9xx on openHAB

Awesome! With a little effort I managed to get the following rule working. Basically I have OpenHAB2 connected to my Roomba 980 (Dorita REST interface), Asterisk PBX and numerous Amazon Echo’s via my Alexa-HA project. The intent was to have voice control over the house vacuum, including automatically turning on all the lights and fans/air purifiers whenever house cleaning is underway and have it automatically pause/resume when an active phone call starts/completes. Here is how I pulled it off. The ‘roombaActive’ item is just a basic virtual Switch that toggles other items throughout the house as needed:

rule "Start house cleaning job"
when
	Item roombaActive received command ON
then
	// Set light levels and turn all lights on 
    sendCommand(Light_Group_Color_All, "80,80,80")
    sendCommand(Light_Group_Switch_All, ON)
    
    // Turn on all the fans
    sendCommand(GF_Fans,ON)
    
    // Start Roomba cleaning mission
    sendCommand(roombaMission,ON)
    roombaDock.postUpdate(OFF)
    
    // Announce
	say("Cleaning your house, sir...")
end

rule "Stop cleaning the house"
when
	Item roombaActive received command OFF
then
	// Turn off all lights
    sendCommand(Light_Group_Switch_All, OFF)
    
    // Turn off all fans
    sendCommand(GF_Fans,OFF)
    
    // Cancel Roomba cleaning mission
    sendCommand(roombaMission,OFF)
    
    // Return Roomba to its dock
    sendCommand(roombaDock,ON)
    
    // Announce
	say("Canceling cleaning job, sorry for the disturbance, sir...")
end

rule "Pause cleaning the house during active phone call"
	when
		Item Incoming_Call received update
	then
	    if (Incoming_Call.state == ON && roombaMission.state == ON && roombaActive.state == ON) {
    		// Turn off all fans
    		sendCommand(GF_Fans,OFF)
    		
    		// Pause Roomba cleaning mission
    		sendCommand(roombaPause,ON)
    	}
    	if (Incoming_Call.state == OFF && roombaPause.state == ON && roombaActive.state == ON) {
    		// Turn on all fans
    		sendCommand(GF_Fans,ON)
 
    		// Resume Roomba cleaning mission
    		sendCommand(roombaPause,OFF)
    	}
end
4 Likes