Hi there,
I’m pretty new to automations and templating in Home Assistant.
I’m trying to achieve a new condition for my roomba automation.
I’m trying to read the attribute “completed” from the entity “sensor.noo_noo_cleaning_history” from todays cleaning jobs (Attribute block starts with date + Starttime) which will be “false” or “true” depending, if the roomba finished cleaning or not.
To do so, I’ve read a lot about templating but the issue is, I can not simply read the attribute without specifying the date and start-time of the cleaning job, because the completed attribute is part of the whole Cleaning-Job attribute. The value will change each time a cleaning job is started, and I would like to regex for todays date.
Something like
{{state_attr(‘sensor.noo_noo_cleaning_history’,$(today.completed)) }}
Here’s what I came up with so far:
In the template section I’m able to read the attribute by defining the actual cleaning job in a specific format
{{state_attr(‘sensor.noo_noo_cleaning_history’,‘09-23 13:30’) }}
which will give me:
{‘timestamp’: 1727091007.0, ‘cleaning_time’: ‘0 min’, ‘cleaned_area’: ‘1 m²’, ‘status’: ‘Cleaning’, ‘completed’: False, ‘water_tank’: ‘Not installed’}
The issue is I only need the attribute “completed” of this output and I also want to read the attributes of all of the cleaning jobs of today without knowing the exact time. e.g. “09-23 *”.
To simplify:
I just need the information if any cleaning-job of today has been completed.
How do I extract this sub-attribute from my entity?
Screenshot of the entity with the attributes:
The automation looks like this:
alias: Roomba Automation V 2.0
description: >-
When nobody is at home, or by 13:30 everyday, the roomba will check if today was already cleaned. If not, it will do so.
trigger:
- platform: state
entity_id:
- zone.home
to: "0"
from: "1"
- platform: time
at: "13:30:00"
condition:
- condition: or
conditions:
- condition: template
value_template: >-
{{states.sensor.noo_noo_cleaning_history.last_changed.day !=
now().day}}
- condition: and
conditions:
- condition: template
value_template: >-
{{states.sensor.noo_noo_cleaning_history.last_changed.day ==
now().day}}
- condition: numeric_state
entity_id: sensor.noo_noo_cleaned_area
below: 30
action:
- device_id: 96a0196aa052b18e902568b640fbed8c
domain: vacuum
entity_id: edaec8e0a5656e916552e9a4343bbc8a
type: clean
mode: single
At the moment I found a workaround by reading the “cleaned_area” Entity, while I know, that the total cleaning amount will always be higher than 30 if completed. But it’s not as clever as I want it to be.
Any help is greatly appreciated as I like to dive deepter into templating and automations.