Shouldn’t the binary sensor be called “Vacuum not run in last 5 days”? If (now - last run) > 5 days, the template evaluates to true, meaning the last cleaning was more than 5 days ago.
True True
This has stopped working after latest update.
Any ideas?
The output right now seems to be what home assistant sets as a standard:
binary_sensor:
- platform: template
sensors:
vacuum_run_in_last_5_days:
friendly_name: "Vaccum run in last 5 days"
value_template: >-
{{ as_timestamp(states('sensor.date_time').replace(',','')) - as_timestamp(states('input_datetime.neato_last_run')) > 432000 }}
sensor:
- platform: template
sensors:
since_neato_last_run:
value_template: >-
{%- set slb = states.input_datetime.neato_last_run.state.split(' ') -%}
{%- set count = slb | length -%}
{%- set hms = slb[count - 1] -%}
{%- set hms_trimmed = hms.split('.')[0] -%}
{%- set hms_split = hms_trimmed.split(':') -%}
{%- set hours = hms_split[0] | int -%}
{%- set minutes = hms_split[1] | int -%}
{%- if count == 3 -%}
{{ slb[0] ~ ' ' ~ slb[1] ~ ' ' }}
{%- endif -%}
{%- if hours > 0 -%}
{%- if hours == 1 -%}
1 h
{%- else -%}
{{ hours }} h
{%- endif -%}
{%- endif -%}
{%- if minutes > 0 -%}
{%- if hours > 0 -%}
{{ ', ' }}
{%- endif -%}
{%- if minutes == 1 -%}
1 min
{%- else -%}
{{ minutes }} min
{%- endif -%}
{%- endif -%}
correct_hour:
value_template: >
{% set current_time = strptime(states.sensor.time.state, '%Y-%m-%d, %H:%M') %}
{{ ((as_timestamp(current_time) - as_timestamp(input_datetime.neato_last_run))/60)|round|int }}
- platform: template
sensors:
days_neato:
friendly_name: "Days Since Neato Last Cleaned"
unit_of_measurement: 'days'
value_template: "{{ as_timestamp(states('sensor.date_time').replace(',','')) - as_timestamp(states('input_datetime.neato_last_run'))}}"
- platform: template
sensors:
neato_last_run_rounded:
friendly_name: "Days Since Neato Last Cleaned"
value_template: >-
{%- set uptime = states.sensor.days_neato.state | round -%}
{%- set sep = ', ' -%}
{%- set TIME_MAP = {
'week': (uptime / 604800) % 604800,
'day': (uptime / 86400) % 7,
'hour': (uptime / 3600) % 24,
'minute': (uptime / 60) % 60,
'second': (uptime % 60)
}
-%}
{%- for unit, duration in TIME_MAP.items() if duration >= 1 -%}
{%- if not loop.first -%}
{{ sep }}
{%- endif -%}
{{ (duration | string).split('.')[0] }} {{ unit }}
{%- if duration >= 2 -%}
s
{%- endif -%}
{%- endfor -%}
{%- if uptime < 1 -%}
just now
{%- endif -%}
input_datetime:
neato_last_run:
name: Neato Last Run
has_date: true
has_time: true
Did you manage to get this working again?