Need help to control iRobot Roomba

I am planing to buy an iRobot Roomba vacuum cleaner and buy a wifi module to control it via wifi.
It would be great to control it in HA so when no one is home it starts to clean.

It can be controlled via python and AJAX.
AJAX: http://www.roowifi.com/controlling-your-irobot-roomba-using-ajax/
Python: http://www.roowifi.com/sample-python-gtk/

Im not that very good att adding plugins and functions to HA, and might need some help.

Can i add a button in HA that trigger for example this adress “http:// Roomba_Wifi_Remote_IP /roomba.cgi?button=CLEAN” to start the cleaning?
Or add it in an automation so when state is not_home it start to clean, and when some one is home it goes back to dock.

Did you ever got this to work. It is a good idea

I dont have the roowifi yet so its not tested.

I do think that curl command in homeassistant might work tho.

The 900 series roomba’s have wifi built in, and there was code out there to control them via python. Unfortunately with the last release of roomba’s firmware, they switched to what I believe is a rest API and have not published the API. I believe some people in the smart things board are looking at hacking it but I haven’t seen any updates lately from them.

Any updated info on this? The 900’s series had a huge update Q1 of 2017 and allowed integration with Alexa/Google Home.

I have solved this by using shell_command and “curl http://192.168.1.73/roomba.cgi?button=CLEAN”.

Then i created an automation that triggers the clean command when no one is home.
And when someone comes home it returns to the charging station.

Ive setup some REST with Roowifi:

- platform: rest
  resource: !secret roomba_resource
  authentication: basic
  username: !secret roomba_username
  password: !secret roomba_password
  name: Roomba Status
  value_template: >
     {%- if value_json.response.r16.value < '-1' and value_json.response.r14.value == '0' or value_json.response.r14.value == '4' -%}
       Cleaning
     {%- elif value_json.response.r16.value > '-1' and (value_json.response.r14.value == '2' or value_json.response.r14.value == '1' or value_json.response.r14.value == '3' or value_json.response.r14.value == '2') -%}
       Docked
     {% else %}
       Unknown
     {%- endif -%}

- platform: rest
  resource: !secret roomba_resource      
  authentication: basic
  username: !secret roomba_username
  password: !secret roomba_password
  name: Roomba Charging State
  value_template: >
     {%- if value_json.response.r14.value == '0' -%}
       Not charging
     {%- elif value_json.response.r14.value == '1' -%}
       Charging Recovery
     {%- elif value_json.response.r14.value == '2' -%}
       Charging
     {%- elif value_json.response.r14.value == '3' -%}
       Trickle Charging
     {%- elif value_json.response.r14.value == '4' -%}
       Waiting
     {%- elif value_json.response.r14.value == '5' -%}
       Charging Error
     {% else %}
       N/A
     {%- endif -%}

- platform: rest
  resource: !secret roomba_resource      
  authentication: basic
  username: !secret roomba_username
  password: !secret roomba_password
  name: Roomba Current
  value_template: "{{ value_json.response.r16.value }}"
  unit_of_measurement: mA

- platform: rest
  resource: !secret roomba_resource      
  authentication: basic
  username: !secret roomba_username
  password: !secret roomba_password
  name: Roomba Charge
  value_template: "{{ value_json.response.r18.value }}"
  unit_of_measurement: mAh

- platform: rest
  resource: !secret roomba_resource      
  authentication: basic
  username: !secret roomba_username
  password: !secret roomba_password
  name: Roomba Capacity
  value_template: "{{ value_json.response.r19.value }}"
  unit_of_measurement: mAh

- platform: rest
  resource: !secret roomba_resource      
  authentication: basic
  username: !secret roomba_username
  password: !secret roomba_password
  name: Roomba Temperature
  value_template: "{{ value_json.response.r17.value }}"
  unit_of_measurement: C

- platform: rest
  resource: !secret roomba_resource      
  authentication: basic
  username: !secret roomba_username
  password: !secret roomba_password
  name: Roomba Charge Percent
  value_template: "{{ (float(value_json.response.r18.value) / float(value_json.response.r19.value)) | multiply(100) | round(1) }}"
  unit_of_measurement: '%'
2 Likes

This is great @roflmao, this is very helpful to get the state of the roomba.
I figured out that when the Roomba is cleaning you need to run the CLEAN command once more before you can dock it.
Or if it goes down in stand by mode in the middle of the floor you need to wake it with the CLEAN command, and then run the CLEAN command to stop the cleaning and then run the DOCK command.

I’ve tried using this method to automate my roomba with little luck. It seems to go to sleep and cannot be woken using a shell command unless you connect to the unit via web browser to wake it, then it will respond to shell commands.

Any idea if I can create a shell command that will login and wake the roomba? I’ve tried using -GET and even ping with no luck.

Have you ever got this to work ? If so can you share

I play with it a little bit and now it’s working perfectly.
sensor info from RooWifi device:
add this to “configuration.yaml” file:
be aware that default RooWifi username and password is used below if you have different one please change “admin” to the correct username and “roombawifi” to the correct password.

sensor:
  - platform: rest
    resource: http://"your_roowifi_ip"/roomba.json
    authentication: basic
    username: admin
    password: roombawifi
    name: Roomba Status
    value_template: >
     {% if float(value_json.response.r16.value) < -2 and float(value_json.response.r16.value) > -200 and (value_json.response.r14.value == '0' or value_json.response.r14.value == '4') %}
      Stop
     {% elif float(value_json.response.r16.value) < -201 and (value_json.response.r14.value == '0' or value_json.response.r14.value == '4') %}
      Cleaning  
     {% elif float(value_json.response.r16.value) > -1 and (value_json.response.r14.value == '1' or value_json.response.r14.value == '2' or value_json.response.r14.value == '3') %}
      Docked
     {% else %}
      Unknown
     {% endif %}
 
  - platform: rest
    resource: http://"your_roowifi_ip"/roomba.json     
    authentication: basic
    username: admin
    password: roombawifi
    name: Roomba Charging State
    value_template: >
     {%- if value_json.response.r14.value == '0' -%}
       Not charging
     {%- elif value_json.response.r14.value == '1' -%}
       Charging Recovery
     {%- elif value_json.response.r14.value == '2' -%}
       Charging
     {%- elif value_json.response.r14.value == '3' -%}
       Trickle Charging
     {%- elif value_json.response.r14.value == '4' -%}
       Waiting
     {%- elif value_json.response.r14.value == '5' -%}
       Charging Error
     {% else %}
       N/A
     {%- endif -%}
     
  - platform: rest
    resource: http://"your_roowifi_ip"/roomba.json     
    authentication: basic
    username: admin
    password: roombawifi
    name: Roomba Current
    value_template: "{{ value_json.response.r16.value }}"
    unit_of_measurement: mA

  - platform: rest
    resource: http://"your_roowifi_ip"/roomba.json      
    authentication: basic
    username: admin
    password: roombawifi
    name: Roomba Charge
    value_template: "{{ value_json.response.r18.value }}"
    unit_of_measurement: mAh

  - platform: rest
    resource: http://"your_roowifi_ip"/roomba.json      
    authentication: basic
    username: admin
    password: roombawifi
    name: Roomba Capacity
    value_template: "{{ value_json.response.r19.value }}"
    unit_of_measurement: mAh
    
  - platform: rest
    resource: http://"your_roowifi_ip"/roomba.json      
    authentication: basic
    username: admin
    password: roombawifi
    name: Roomba Temperature
    value_template: "{{ value_json.response.r17.value }}"
    unit_of_measurement: C
    
  - platform: rest
    resource: http://"your_roowifi_ip"/roomba.json      
    authentication: basic
    username: admin
    password: roombawifi
    name: Roomba Charge Percent
    value_template: "{{ (float(value_json.response.r18.value) / float(value_json.response.r19.value)) | multiply(100) | round(1) }}"
    unit_of_measurement: '%'


shell_command:
  roomba_clean: curl http://admin:roombawifi@"your_roowifi_ip"/roomba.cgi?button=CLEAN
  roomba_dock: curl http://admin:roombawifi@"your_roowifi_ip"/roomba.cgi?button=DOCK

add this to “automations.yaml”:


- id: '1563198581377'
  alias: Roomba Clean
  trigger: []
  condition: []
  action:
  - service: shell_command.roomba_clean
  - delay: '1'
  - service: shell_command.roomba_clean
- id: '1563198769781'
  alias: Roomba Dock
  trigger: []
  condition: []
  action:
  - service: shell_command.roomba_clean
  - delay: '1'
  - service: shell_command.roomba_dock
2 Likes