iRobot Roomba i7+ Configuration using Rest980

during the last run the log was populated but no green lines

so not an error as such as i would not in normal access the page

oki, it was a bit confusing to beging with

How do the offset work? what is x and what is y? and what do positive numbers do?

its late here. 2.00 in the morning so will not be able to do a run but would like to get ready for one in the morning

right now the log is 5kb so quite a bit,
$overlay_image = ‘floor_new.png’; # Background Layer
and the file is there,


yet the map is “dead”

image.php <?php//error_reporting(E_ALL);//ini_set('display_errors', 1);// ADJUST T - Pastebin.com
log Home Assistant notifications (Log started: 2021-01-11T18:55:44.219717+00:00)-- - Pastebin.com

You dont need to keep running it.

for getting the map right, you can use the existing vacuum.log file and just edit the attriburtes and refresh. simply open your browser and navigate to the image file directly

the only catch is - make sure to delete the latest.png file in the vacuum directory otherwise it will just use this image instead of showing you the changes.

using your vacuum.log file i was abvle to get the current set of lines in the middle of the map usng the following attributes

$map_width = 1050; # Ensure overlay and wall images match this size
$map_height = 900; # Ensure overlay and wall images match this size
$x_offset = 200;
$y_offset = 200;

you will need to flip/rotate in order to get it to line up with your intended floor plan however.

that one i knew :slight_smile:

hmm the png is larger than that,

image

can that be negative numbers too?

but progress

is that just the blank picture? or your floor plan? it can be what ever size you want, ideally just needs to match what your floorplan picture is so it overlays correctly.

yeah, it should work, just work in small increments and make sure its doing what you expect :+1:

its my floorplan, rather big in pixels i know

it seems the closer i get to the right numbers i got from paint it either takes longer or fails

at that size the roomba lines just looked quite small, but if they line up to your floor plan, then all good !

well i think i have to scale it also

i did the clean in our entrance as that is the smallest room

when i rotate will that be arround the starting point? just so i have an idea of what it will do

in theory yes, as from the roombas perspective, home base should be (0,0,0) but then the rotate will factor in any offsets you have defined.

does your code with a gurantee that people dont loose their sanity? :smiley:

for the map line, what is the difference between white and green?

Will try this. Question, if this happen, will be consistent across all run? (so I just need to change $set_first_coordinate one time, like other variables)

I cant gurantee anything :rofl: though for the most part its a set and forget type deal… until you move house :flushed:

by default, the image.php file is set to gradually change color from green to white so you can somewhat see the path your roomba is taking. you can set this to suit your preference by updating lines 29-31

// Line Color - RGB
// -1 represents gradual increase from 0 to 255 based on number of logged locations
//
$color_red = -1;
$color_green = 255;
$color_blue = -1;
//
// Examples
// red = -1 , green = 255 , blue = -1  ---> Green to White Fade
// red = 0 , green = -1 , blue = 255   ---> Blue to Aqua Fade
// red = 0 , green = 0 , blue = 255    ---> Solid Blue
//

yes, once you update the value in image.php it will be used on each run going forward.

1 Like

@boelle This comment may be redundant. When I was building my map and figuring the offsets and scaling, I would save the log by area. I would either save the log based on opportunity or run it on purpose. Once you have a good set, then it is a matter of placing the one in question and then seeing how it looks. The first time is not perfect but once you get a few samples of different areas, then you can start to refine it.

@Syrius Earlier in the thread, I was asking about tracking when an area was done. The goal was to create an automation that when we left the house and it has been x day, clean the area. Before I could focus too much on that, I need to get the vacuum and presence detection working. Now my wife is running the vacuum from love-lace and the lights are being turned off when we leave. Now back to combining the two. My question was to track it from either HA or the Roomba app. Since we now have HA working, we never use the app. At least to command a clean.

So now any thoughts on tracking date/time assuming only HA is being used.

If on the selective room cleaning, we added a text box using the text-divider-row. What I am trying to look at is how to update the text box when “clean rooms” is picked or if trigger by some other automation.

Can anyone think of a way of modifying the “clean room” automation, to update text boxes based on the input_text.vacuum_rooms?

i beat you too it, but it was painfull to rotate, scale and offset the first room.
i ended up doing the living room first as that was the biggest one. the rest was fine once i did a full clean

I did a full clean and used this as the basis for creating my map - many ways to achieve the end result :wink:

i think i suggested it before, but you could track the last triggered state of each input boolean which would at least give you an idea of when the last clean was attempted? i dont really have a definitive way of identifing if an actual room has been cleaned :thinking:

I have not deconstructed your rest980, so without knowing how and/or how much you wrap the dorita980, we do know the region number and in theory, link that to a room. So I started a proof of concept. The rest API is called from one automation, so I just put a step in there to set an input_text value to the date for each of the rooms. I will share where I am at, just keep in mind this is a work in progress and I am not trying to optimize anything. So don’t laugh too hard at the code. :slight_smile:

A little context of my thought. You have an input_text and input_boolean for each room. The format is vaccum_clean_‘RoomName’. So I created an input_text with that same format and added date for the last time it was run for that room.
There are two python scripts.
One (vacuum_set_last_run_date.py) runs during the clean room automation. It is after the rest api is called and before any of the booleans are changed. It reads the input_text.current_rooms and sets the current date to what is stored there.
The other (vacuum_test_and_run.py) takes 3 parameters ({‘rooms’:‘front_bar_area,living_room’,‘days’:‘3’,‘one_room_only’:‘false’}). Then it will loop through the ‘rooms’ and anything equal to or older than ‘days’ will toggle the input_boolean.vacuum_clean
’RoomName’. Once toggled on, then the clean room automation can be trigger via a service call. So the “no one home” automation, can call the ‘vacuum_test_and_run.py’ python script, then trigger clean room. I added the ‘one_room_only’ thinking that you could pass the room list in a “priority to clean” order and the loop would exit as soon as it turns on one.

I could see the issue if the clean room is called and there are no rooms to clean. If that is an issue, we could just call the rest API from the python script.

Again just thinking out loud and picking all the brains on this thread.

image

vacuum_set_last_run_date.py

logger.info("Start - vacuum_set_last_run_date")
rooms = hass.states.get('input_text.vacuum_rooms').state.split(',')
logger.info("Rooms selected:" + str(rooms))
current_time = datetime.datetime.now()
date = f'{current_time.month:02}' + "/" + f'{current_time.day:02}' + "/" + f'{current_time.year:04}'
#date = '{}'.format(curent_time,'%m/%d/%Y')
logger.info("Will set date to: " + date)
for room in rooms:
  logger.info("Running set for " + room)
  if len(room)>0:
    service_data = {"entity_id": "input_text.vacuum_clean_" + room + "_date", "value": date}
    hass.services.call("input_text", "set_value", service_data, False)
logger.info("Finish - vacuum_set_last_run_date")

vacuum_test_and_run.py

logger.info("Start - vacuum_test_and_run")
rooms = data.get('rooms').split(',')
days = data.get('days')
one_room_only = data.get('one_room_only')
logger.info("Rooms to selected: " + str(rooms) + ", if more than " + days + " day(s) old, and do one room only: " + str(one_room_only).lower() + ".")
current_time = datetime.datetime.now()
for room in rooms:
  logger.info("Testing " + room + " room")
  if len(room)>0:
    room_last_run = hass.states.get("input_text.vacuum_clean_" + room + "_date").state
    room_last_run_date = datetime.datetime.strptime(room_last_run, '%m/%d/%Y')
    days_diff = (current_time-room_last_run_date).days
    if days_diff >= days_diff:
      #service_data = {"entity_id": "input_boolean.vacuum_clean_" + room, "value": 'false'}
      service_data = {"entity_id": "input_boolean.vacuum_clean_" + room}
      logger.info("Service data: " + str(service_data))
      hass.services.call("input_boolean", "turn_on", service_data, False)
      if str(one_room_only).lower() == 'true':
        break
    else:
      logger.info(room + " not run: " + str(days_diff))    
logger.info("Finish - vacuum_test_and_run")
1 Like

**Reposting as I think this got lost in the discussion. :wink: Hi Everyone - I’m new to HA and don’t have much programming experience. I love this integration and got it to work with my Roomba i3+. However, most of the status displays as “unavailable” but I am able to connect to my roomba and also start, pause, and also dock it. Here’s a screenshot for reference. Any ideas what else I need to do to get this to work? Thanks in advance!

I also want to pick brains as my next step after getting it working is to have lights turn on if they are off and turn them off when done (and if they are on just leave them on after vacuum is done)

in winter that is usefull but in summer it might not be needed

of course this can be either all lights or on a per room basis

any ideas or pointers where i should go next?

From https://github.com/koalazak/rest980 page I saw below example to clean a room:

curl -X POST http://192.168.1.110:3000/api/local/action/cleanRoom -H 'Content-Type: application/json' -d '{"ordered": 0, "pmap_id": "123456", "regions": [{"region_id":"5", "region_name":"Hallway","region_type":"hallway"}], "user_pmapv_id": "987654"}'

What are the values of “region_name” and “region_type” come from? What is the meaning of “ordered”:0?

Thanks.

With a status of “docked” i assumne your using this built-in roomba plugin, not my custom rest980 implementation, which isnt compatible with this interfsce. You need to follow the steps in my GH repo to get the data to populate this card.

if your using the example automations for scheduled cleans, you can add an extra action to turn on the lights first

Refer here to obtain. you should have these defined in your secrets file already if you have followed the steps correctly.

my understanding is that this is used to determine if you want the rooms to be cleaned in the specific order. values are 0 (false) or 1 (true)

you can also skip adding this, its not needed.