I’m new here, but was inspired by this and something I read about Trigger Ids and took it down a rabbit hole. I’ve got a bad habit of forgetting to give the dogs their meds, so this is a way to annoy me into submission.
Basically I set one of the leds on my Homeseer ZWave switch to red at 5AM. If it’s still red by 5PM that same day I get push notifications once per hour (in perpetuity) until it’s no longer red. Disabling the red led is in a different rule.
First stab at a rule this complex, let me know if there’s something I missed to make things easier!
alias: When it's the 11th of the month Then remind me to give the dogs their meds
description: ""
trigger:
- platform: time
at: "05:00:00"
id: morning_alarm
- platform: time_pattern
hours: "*"
id: annoy_me
condition:
- condition: or
conditions:
- alias: For morning alarm
condition: and
conditions:
- condition: trigger
id:
- morning_alarm
- alias: Check that it's the 11th
condition: template
value_template: "{{ now().day == 11 }}"
- alias: For annoy me
condition: and
conditions:
- condition: trigger
id:
- annoy_me
- alias: After 5 on the 11th or any time any other day
condition: or
conditions:
- alias: After 5:00 PM on the 11th
condition: and
conditions:
- alias: On the 11th
condition: template
value_template: "{{ now().day == 11 }}"
- condition: time
after: "16:59:59"
- alias: Not on the 11th
condition: template
value_template: "{{ now().day != 11 }}"
- condition: device
device_id: 4434b4609c62ab27f6a89fd296199cf5
domain: zwave_js
value_id: 40-112-0-13
type: config_parameter
subtype: 13 (Enable / Disable Custom LED Status Mode) on endpoint 0
value: 1
- condition: device
device_id: 4434b4609c62ab27f6a89fd296199cf5
domain: zwave_js
value_id: 40-112-0-27
type: config_parameter
subtype: 27 (Status LED 7 Color) on endpoint 0
value: 1
action:
- choose:
- conditions:
- condition: trigger
id:
- morning_alarm
sequence:
- service: notify.mobile_app_pixel_7_pro
data:
message: Give the dogs their meds!
- device_id: 4434b4609c62ab27f6a89fd296199cf5
domain: zwave_js
type: set_config_parameter
endpoint: 0
parameter: 13
bitmask: null
subtype: 13 (Enable / Disable Custom LED Status Mode) on endpoint 0
value: 1
- device_id: 4434b4609c62ab27f6a89fd296199cf5
domain: zwave_js
type: set_config_parameter
endpoint: 0
parameter: 27
bitmask: null
subtype: 27 (Status LED 7 Color) on endpoint 0
value: 1
alias: Set the status light
- conditions:
- condition: trigger
id:
- annoy_me
sequence:
- service: notify.mobile_app_pixel_7_pro
data:
message: Give the dogs their meds!
alias: Annoy Me
I believe timestamp_custom('%B') will return the English month name regardless of locale, so the sequence of replaces turns those into the Dutch month names.
Nothing: that should still work. It’s just the UI reformatting the template to an alternative layout.
If you manually run the automation, it should set the January input_number to the current value of that sensor. If not, post what happens here with any relevant log entries.
You really don’t: there are several errors in that code.
You mean Sunday? This holds prior state until it’s triggered on a Sunday. There are no condition blocks in trigger-based template sensors [EDIT: as of 2024.10, there are]. Did you dream that up, or is it a ChatGPT hallucination?
- trigger:
- platform: time
at: "23:59:59"
sensor:
- name: Updates at end of each Sunday
state: >
{% if now().weekday() == 6 %}
INSERT NEW STATE TEMPLATE HERE
{% else %}
{{ this.state }}
{% endif %}
Alternatively, and less efficiently, you could use a template trigger which will only trigger at 23:59, not at the very last second:
- trigger:
- platform: template
value_template: "{{ (now().weekday(), now().hour, now().minute) == (6,23,59) }}"
sensor:
- name: Updates at end of each Sunday
state: >
INSERT NEW STATE TEMPLATE HERE