Skip to content

Instantly share code, notes, and snippets.

@bruxy70
Created March 6, 2024 16:52
Show Gist options
  • Save bruxy70/90734a82896102e67237706efbfcc7b8 to your computer and use it in GitHub Desktop.
Save bruxy70/90734a82896102e67237706efbfcc7b8 to your computer and use it in GitHub Desktop.
Local calendar sensors example
template:
- trigger:
- platform: time_pattern
hours: "0"
minutes: "1"
- platform: homeassistant
event: start
sensor:
- name: Směs days
unique_id: 33328b5a-ef3e-4811-bf59-2527165b168c
state: >-
{% set days = ((state_attr('calendar.smes','start_time') | as_timestamp -
today_at("00:00") | as_timestamp ) / 86400) | int %}
{{ min(days,2) }}
attributes:
days: >-
{{ ((state_attr('calendar.smes','start_time') | as_timestamp -
today_at("00:00") | as_timestamp ) / 86400) | int }}
- name: Bioodpad days
unique_id: eb3ed151-9986-4c9c-8038-8aeba78b7eb4
state: >-
{% set days = ((state_attr('calendar.bioodpad','start_time') | as_timestamp -
today_at("00:00") | as_timestamp ) / 86400) | int %}
{{ min(days,2) }}
attributes:
days: >-
{{ ((state_attr('calendar.bioodpad','start_time') | as_timestamp -
today_at("00:00") | as_timestamp ) / 86400) | int }}
- name: Papír days
unique_id: 859b5e3c-8a8d-40e8-89de-9a0576db7110
state: >-
{% set days = ((state_attr('calendar.papir','start_time') | as_timestamp -
today_at("00:00") | as_timestamp ) / 86400) | int %}
{{ min(days,2) }}
attributes:
days: >-
{{ ((state_attr('calendar.papir','start_time') | as_timestamp -
today_at("00:00") | as_timestamp ) / 86400) | int }}
- name: Plasty days
unique_id: 17276e40-94a4-4b7f-a816-22b07eebcaa9
state: >-
{% set days = ((state_attr('calendar.plasty','start_time') | as_timestamp -
today_at("00:00") | as_timestamp ) / 86400) | int %}
{{ min(days,2) }}
attributes:
days: >-
{{ ((state_attr('calendar.plasty','start_time') | as_timestamp -
today_at("00:00") | as_timestamp ) / 86400) | int }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment