Hello there, I´m trying to make an script triggered by a Hue Dimming Remote long press
switch off my TV by the Harmony Remote
switch of all unnecessary lights
switch on one dimed light for x minutes (to get out of the room)
set back the the lights brightness to 100%
turn of this light new brightness set
maybe play a playlist on a mediaplayer
But my script stuck after a successful Harmony Off Action, but only when I use the Hue Dimmer Remote, when I trigger the script via Home Assistant GUI everything works fine
alias: Good Night
sequence:
- device_id: e89b9fababaae214cc8b8f54bc5eb77e
domain: select
entity_id: select.harmony_hub_activities
type: select_option
option: power_off
- service: light.turn_on
data:
brightness_pct: 50
target:
area_id: esszimmer
- service: light.turn_off
data: {}
target:
area_id:
- wohnzimmer
- tv_licht
- delay:
hours: 0
minutes: 0
seconds: 10
milliseconds: 0
- service: light.turn_off
data: {}
target:
area_id: esszimmer
- service: media_player.play_media
target:
entity_id: media_player.bett
data:
media_content_id: media-source://radio_browser/8b0e5579-12b8-11e8-ae97-52543be04c81
media_content_type: audio/mpeg
metadata:
title: Klassikradio - Movie Channel
thumbnail: http://www.klassikradio.de/_nuxt/icons/icon_64.a00w80w0000.png
media_class: music
children_media_class: null
navigateIds:
- {}
- media_content_type: app
media_content_id: media-source://radio_browser
- media_content_type: music
media_content_id: media-source://radio_browser/country/DE
mode: single
icon: mdi:weather-night
tom_l
March 1, 2023, 10:57am
2
Scripts don’t have triggers, automations do.
Ok then I’ll rephrase it, I built an automation that triggers a script when a button on the remote is pressed.
tom_l
March 1, 2023, 1:16pm
4
You can look at the trace for your script, like for automations, that may reveal why it is not working.
tom_l
March 1, 2023, 5:47pm
6
Probably going to need to see the triggering automation(s). Particularly ones that can cancel the script, if any.
tom_l
March 2, 2023, 12:31am
8
The actual automation config, not the trace.
mode: restart
max_exceeded: silent
trigger:
- platform: event
event_type: zha_event
event_data:
device_id: a422e6ef5d0cc0ec530f206448b797d9
action:
- variables:
command: '{{ trigger.event.data.command }}'
- choose:
- conditions:
- '{{ command == ''on_short_release'' }}'
sequence:
- service: light.turn_on
data:
brightness_pct: 30
color_temp: 199
target:
area_id: tv_licht
- conditions:
- '{{ command == ''on_hold'' }}'
sequence:
- service: light.turn_on
data:
color_temp: 200
brightness_pct: 50
target:
area_id: tv_licht
- service: light.turn_off
data: {}
target:
entity_id:
- light.wohnzimmer
- light.esszimmer
- light.schlafzimmer_deckenlampe
area_id:
- flur_oben
- flur_unten
device_id: b321c878276a702234d0f94f14d56ace
- conditions:
- '{{ command == ''on_double_press'' }}'
sequence: []
- conditions:
- '{{ command == ''up_short_release'' }}'
sequence: []
- conditions:
- '{{ command == ''up_hold'' }}'
sequence:
- device_id: 6430b3b459ecde077c259fdc0b0cfbe9
domain: light
entity_id: light.hue_go_1
type: brightness_increase
- device_id: 897c91d666a5a48f7067e4d86d42e1e8
domain: light
entity_id: light.hue_go_1_2
type: brightness_increase
- device_id: ce0fc8e5127650c61887601421e664ec
domain: light
entity_id: light.hue_go_1_3
type: brightness_increase
- conditions:
- '{{ command == ''up_double_press'' }}'
sequence: []
- conditions:
- '{{ command == ''down_short_release'' }}'
sequence: []
- conditions:
- '{{ command == ''down_hold'' }}'
sequence:
- device_id: 6430b3b459ecde077c259fdc0b0cfbe9
domain: light
entity_id: light.hue_go_1
type: brightness_decrease
- device_id: 897c91d666a5a48f7067e4d86d42e1e8
domain: light
entity_id: light.hue_go_1_2
type: brightness_decrease
- device_id: ce0fc8e5127650c61887601421e664ec
domain: light
entity_id: light.hue_go_1_3
type: brightness_decrease
- conditions:
- '{{ command == ''down_double_press'' }}'
sequence: []
- conditions:
- '{{ command == ''off_short_release'' }}'
sequence:
- service: light.turn_off
data: {}
target:
area_id: tv_licht
- conditions:
- '{{ command == ''off_hold'' }}'
sequence:
- service: script.good_night
data: {}
- service: script.fernsehen_aus
data: {}
- conditions:
- '{{ command == ''off_double_press'' }}'
sequence: []
id: '1675091784312'
alias: Light - Wohnzimmer - TV Licht Steuerung
description: ''
tom_l
March 2, 2023, 7:15am
10
Ok, I think I see what is happening.
The way you are calling the script:
sequence:
- service: script.good_night
Waits for the script to complete, see: Scripts - Home Assistant . And as the automation has this mode:
mode: restart
max_exceeded: silent
If the automation is re-trigggerd while the script is running it will restart the automation and cancel the script call.
You can confirm this by changing the atomation mode to:
mode: restart
# max_exceeded: silent
And checking the logs to see if the automation is restarted.
If this is the case, you have a couple of options:
Call the script like this instead:
- service: script.turn_on
target:
entity_id: script.good_night
This will not wait for the script to complete before moving to the next action. So if the automation gets restarted the script keeps running. The script runs in single mode so if it gets called again when the automation is re-triggered it will be ignored.
The other option is to run the automation in parallel mode instead of restart mode. I have not looked closely enough at your automation to see if this will be an issue for you.
Thank you very much, I changed to script.turn_on now, solved my problem.
1 Like