I’m running an automation with a time pattern every 20 minutes between 14:59:59 and 22:00:01.
Every 20 minutes, the automation will trigger. The action will follow if the conditions are met. Because the conditions are relying on the cloud cover percentage and the time offset from sunset, the action will trigger another time every single day. Is it possible to stop the time pattern trigger once the scene state is true? Now, when the scene is activated, the automation will still trigger every 20 minutes. To avoid problems, I made and action that when the scene is true, the automation will stop. But then again after 20 minutes, the automation triggers again. Is there anyway to stop the triggering? My logs are full with unnecessary logfiles from the automation.
alias: "Woonkamer aan "
description: Livingroom on. Cloud coverage 80-100 sunset offset -02:00:00. CC 60-80 sunset offset -01:00:00. CC 30-60 sunset offset -00:30:00. CC 0-30 sunset
trigger:
- platform: time_pattern
minutes: /20
condition:
- condition: and
conditions:
- condition: time
after: "14:59:59"
before: "22:00:01"
- condition: or
conditions:
- condition: and
conditions:
- condition: sun
after: sunset
after_offset: "-02:00:00"
- type: is_value
condition: device
device_id:
entity_id: sensor.home_cloud_cover
domain: sensor
above: 80
below: 100
- condition: and
conditions:
- condition: sun
after: sunset
after_offset: "-01:00:00"
- type: is_value
condition: device
device_id:
entity_id: sensor.home_cloud_cover
domain: sensor
above: 60
below: 80
- condition: and
conditions:
- condition: sun
after: sunset
after_offset: "-00:30:00"
- type: is_value
condition: device
device_id:
entity_id: sensor.home_cloud_cover
domain: sensor
above: 30
below: 60
- condition: and
conditions:
- condition: sun
after: sunset
- type: is_value
condition: device
device_id:
entity_id: sensor.home_cloud_cover
domain: sensor
above: 0
below: 30
action:
- if:
- condition: device
type: is_on
device_id:
entity_id: light.plank_local
domain: light
then:
- stop: Scene running
else:
- service: scene.turn_on
target:
entity_id: scene.woonkamer_aan
metadata: {}
mode: single
Hope anybody can help. I couldn’t find anything about this online. I’m still pretty new to HASS. Been playing with it for 2 weeks now.
Re-design your automation to be event-based as opposed to polling-based. That will give you precise control over when it triggers and executes its actions.
BTW, once a Time Pattern Trigger is created, it triggers according to the period you specified. There’s no enable/disable for triggers. You can enable/disable an automation but if that’s needed as part of its normal operation then the overall design needs improvement.
It’s mostly the notification that the time pattern trigger has been triggered/the automation has been triggered. Not really a problem, more an annoyance
How would you design the automation based on my needs? Like the cloud cover value and the offset to sunset based on the cloud cover value? Like I said in the post, I’m still fairly new to HASS.
What are your requirements? Your first post explains the automation’s behavior but, rather than reverse-engineer the requirements from the automation, I would prefer if you explain what you want to achieve.
I would like to have the abillity that the lights turn on automatically depending on the cloud cover percentage on my home location. If the cloud cover percentage is 80 to 100%, the lights should turn on 2 hours before sunset. If the percentage is 60 to 80%, the lights should turn on 1,5 hours before sunset. If the percentage is 30 to 60 %, the lights should turn on 0,5 hour before sunset. If the percentage is 0 to 30%, the lights should turn on at sunset. When one of the requirements is met, the automation should activate the scene and after that go to, let’s call it sleepmode, so it won’t try to trigger again until the next day. The way I made the automation now, the automation will still trigger after it already has activated the scene.
Note that I provide a default value of 100 in states('sensor.home_cloud_cover')|float(100) — that way, if your cloud cover sensor is not working, the lights come on at the early time rather than leaving you in the dark.
Perhaps an ambient light sensor would work better in your situation? Trigger when dark rather than via some inferred value from a complex schedule of times and cloud thresholds.
Can’t resist fiddling, as I didn’t like the complexity, repetition and hard-coding of the original. This is almost the same, and turns on the light when the cloud cover % × 1.5 is greater than or equal to the number of minutes to sunset — from 150 minutes before sunset at 100% cloud cover to sunset itself when the sky is clear. Play with the multiplier to fine-tune it.
Thanks for providing the requirements. It’s clear that they can be met without the need for a Time Pattern Trigger.
I realize your requirements have already been met by Troon’s automation. However, if you’re interested, here’s another way to do the same thing.
It employs four Sun Triggers, one for each time you specified. At each specified time, it checks if the cloud coverage is within the desired range. If the coverage is within range and the light is off, it turns on the scene.
Anyway, the main point is that there’s no need for a method to “stop a Time Pattern Trigger” because your requirements can be fulfilled without the use of a Time Pattern Trigger.