Help with Roomba Automation and statistics

I have an automation that runs when roomba finishes and sends me a text and annouces of speakers. Two of the main pieces of data I want for this automation is coming because of the way roomba reports.

When a job completes or I cancel and tell roomba to go home, it is suppose to tell me how long the cleaning session was and how many sq ft were cleaned. However, as soon as the job is done and roomba starts heading home or you cancel and it starts heading home those attributes go away, so there is no way to grab it. How could I grab that information? The automation is set to run when it goes from on to off, and apparently off is when it heads home rather than when it gets home. Here is my code and what i get…

- alias: Roomba Done Summary
  trigger:
    - platform: state
      entity_id: vacuum.roomba
      from: 'on'
      to: 'off'
  action:
    - service: script.say_sonos
      data_template:
        volume: '0.4'
        where: 'living_room, media_player.basement, media_player.bedroom'
        what: 'Dustin, the house is now clean.  It took roomba {{ states.vacuum.roomba.attributes.cleaning_time }} minutes to vacuum and has {{ states.vacuum.roomba.attributes.battery_level }} percent battery remaining.  {{ states.vacuum.roomba.attributes.cleaned_area }} square feet was vacuumed. '
    - service: notify.ios_da
      data:
        message: ' Dustin, the house is now clean.  It took roomba {{ states.vacuum.roomba.attributes.cleaning_time }} minutes to vacuum and has {{ states.vacuum.roomba.attributes.battery_level }} percent battery remaining.  {{ states.vacuum.roomba.attributes.cleaned_area }} square feet was vacuumed. '
    - service: notify.ios_ipad
      data:
        message: 'Dustin, the house is now clean.  It took roomba {{ states.vacuum.roomba.attributes.cleaning_time }} minutes to vacuum and has {{ states.vacuum.roomba.attributes.battery_level }} percent battery remaining.  {{ states.vacuum.roomba.attributes.cleaned_area }} square feet was vacuumed. '
1 Like

I don’t know if there’s an easier way, but based on the fact you’re getting an empty space rather than zero, you could create 2 input_numbers that update everytime the attribute does, thus the value of the input_number when the device goes off will be the last reported value, which you then receive in your message. When the vacuum goes out again and sends 1 the whole thing starts over.

i like it. thank you

1 Like

Hi @Darbos,

Sorry for resurrecting such an old topic :slight_smile:
Did you get the cleaning time and area real values on notifications?
I am trying to achieve this using a sensor template. Both are updated when Roomba is running but as soon as the job ends and Roomba starts homming the values are lost :face_with_raised_eyebrow:

I would be grateful if you (or maybe @anon43302295 ) have any hint regarding how to accomplish this.

Give me the entity_id of the device, the name of the attributes you need and exactly what happens to them during/after the cleaning cycle, and how you want to receive the information and I’ll knock something up in the morning (nearly midnight here and my alarm goes off for work at 5 so I ought to get to bed!) :+1:

Hi @anon43302295,

Thanks for taking time to reply even that late :sleeping:

My Roomba entity_id: vacuum.eva
When idle (at charging station) she has the attributes

screenshot_idle

When running the two attributes I want (cleaning_time && cleaned_area) are shown like so:

screenshot_running

Reading the template documentation, I thought that changing the vacuum_cleaned_area template (code below) so it only stores values while roomba is running.
In this case I am expecting that when Roomba finishes and starts to head home the status will be something different like Stopping or Homming (or something else) so the job values don’t get reset before HA sens the notification.
This is because cleaned_area and cleaning_time attributes get empty after roomba starts to head home, but if she is far away before roomba docks…

- platform: template
  sensors:
    vacuum_cleaning_time:
      friendly_name: "Vacuum cleaning time"
      value_template: >-
        {% if is_state('vacuum.eva.status','Running') %}
          {{ (state_attr('vacuum.eva', 'cleaning_time') ) }}
        {% endif %}

    vacuum_cleaned_area:
      friendly_name: "Vacuum cleaned area"
      value_template: >-
        {{ (state_attr('vacuum.eva', 'cleaned_area') ) }}

I will test this possibility as soon as I can (maybe more than a couple of days).

Any other hint or suggestion will be appreciated.

Hi there,

I’m having the same issue: not being able to capture the cleaned_area attribute since it disappears when the job is finished.

Is there a solution to this?

Thank you for any help you can provide!