Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Cleaned Today' history_stats sensor instead of input_boolean #25

Open
JDFS404 opened this issue Jun 6, 2021 · 1 comment
Open

'Cleaned Today' history_stats sensor instead of input_boolean #25

JDFS404 opened this issue Jun 6, 2021 · 1 comment

Comments

@JDFS404
Copy link

JDFS404 commented Jun 6, 2021

Took a lot of inspiration from your YAML (iets met Goede en Grote Kunstenaars...) so I'd figured I return the favor because I just started with HA and we have the same Vacuum cleaner.

My Roborock has a nasty error 13 which says that the charging pads are not clean. Well, they very much are. So almost every day, the Roborock gives me an error when Docked and will undock and therefore lose battery until it's dead. Happened a couple of times now pre-HA, where I just moved the Roborock back to the dock. With HA, I now wrote an automation that returns the Roborock after 1 minute when its status is error.

You'll probably guess by now, but since the status will turn from returning to docked when this error happens, I get spammed with notifications. It was a nice idea working with some kind of input_boolean, but you need to condition for it and write an automation to reset the input_boolean.

So after some rabbit-holing, I came up with a history_stats sensor with the following configuration:

---
# History Statistics Sensor to check if Vacuum has cleaned today. Resets itself during the night.
# 
- platform: history_stats
  name: Cleaned Today
  entity_id: vacuum.roborock_vacuum_s5
  state: 'cleaning'
  type: count
  start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
  end: '{{ now() }}'

This sensor counts the times the Roborock has cleaned. So if it cleans 10m, it will count as 1.

In my automation, I added the following:

---
# Automation to notify devices of succesful cleaning
# 
alias: "Vacuum: stopped cleaning"
id: "vacuum_stopped_cleaning"
trigger:
  platform: state
  entity_id: vacuum.roborock_vacuum_s5
  from: returning
  to: docked
condition:
  alias: "Checks if Vacuum already cleaned today"
  condition: numeric_state
  entity_id: sensor.cleaned_today
  below: 2
action:
  - service: notify.justin
    data:
      title: "Vacuum"
      message: "Cleanup successful after {{ state_attr('vacuum.roborock_vacuum_s5', 'cleaning_time') }} minutes."

A shorter road to Rome and no input_boolean / helper needed!

@basnijholt
Copy link
Owner

Thank you, that is a very good idea. I will implement it soon 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants