From 5773d6527970d3757e97c47568e140711aa2e676 Mon Sep 17 00:00:00 2001 From: Jeffrey Stone Date: Sun, 15 Aug 2021 16:47:35 -0400 Subject: [PATCH] Updated config from video on trigger ids --- config/packages/halloween.yaml | 113 +++++++++++++++------- config/packages/security.yaml | 166 +++++++++++++++++++++------------ 2 files changed, 189 insertions(+), 90 deletions(-) diff --git a/config/packages/halloween.yaml b/config/packages/halloween.yaml index 21fd9e1..6a627aa 100755 --- a/config/packages/halloween.yaml +++ b/config/packages/halloween.yaml @@ -86,46 +86,95 @@ automation: # 1. You can test the haunted house piece without kicking having to be on Halloween # 2. It gives you the ability to kill the show if things go horribly wrong... # - - id: operation_haunted_house_on - alias: Operation Haunted House On - initial_state: true - # If this_is_halloween switch is turned on then we start the show. + # - id: operation_haunted_house_on + # alias: Operation Haunted House On + # initial_state: true + # # If this_is_halloween switch is turned on then we start the show. + # trigger: + # - platform: state + # entity_id: input_boolean.this_is_halloween + # to: 'on' + # action: + # # First up we play This is Halloween from Nightmare Before Christmas. Change this to what ever audio you want, or comment this one out. + # - service: script.local_audio + # data: + # media: "/media/disney/This_is_Halloween.mp3" + # volume: .5 + # # And turn on the haunted House script. + # - service: script.turn_on + # entity_id: script.haunted_house + + + # # Haunted House Kill Switch. If the this_is_halloween switch is turned off, the stop everything. + # - id: operation_haunted_house_off + # alias: Operation Haunted House Off + # initial_state: true + # trigger: + # - platform: state + # entity_id: input_boolean.this_is_halloween + # to: 'off' + # action: + # # This stops the media player. Besure to change it to match your music player + # - service: media_player.media_stop + # entity_id: media_player.ha_speaker + # # this kills the local_audio script if its running. + # - service: script.turn_off + # entity_id: script.local_audio + # # This kills the youtube audio script if it is running. + # - service: script.turn_off + # entity_id: script.youtube_audio + # # And finally we turn off the haunted house script so no more sounds play. + # - service: script.turn_off + # entity_id: script.haunted_house + + - id: operation haunted house + alias: Operation Haunted House trigger: + # If this_is_halloween switch is turned on then we start the show. - platform: state entity_id: input_boolean.this_is_halloween to: 'on' - action: - # First up we play This i sHalloween from Nightmare Before Christmas. Change this to what ever audio you want, or comment this one out. - - service: script.local_audio - data_template: - media: "/media/disney/This_is_Halloween.mp3" - volume: .5 - # And turn on the haunted House script. - - service: script.turn_on - entity_id: script.haunted_house - - - # Haunted House Kill Switch. If the this_is_halloween siwtch is turned off, the stop everything. - - id: operation_haunted_house_off - alias: Operation Haunted House Off - initial_state: true - trigger: + from: 'off' + id: start + # If this_is_halloween switch is turned off then we stop the show. - platform: state entity_id: input_boolean.this_is_halloween + id: stop + from: 'on' to: 'off' action: - # This stops the media player. Besure to change it to match your mecia player - - service: media_player.media_stop - entity_id: media_player.ha_speaker - # this kills the local_audio script if its running. - - service: script.turn_off - entity_id: script.local_audio - # This kills the youtube audio script if it is running. - - service: script.turn_off - entity_id: script.youtube_audio - # And finally we turn off the haunted house script so no more sounds play. - - service: script.turn_off - entity_id: script.haunted_house + # Choose provides decision logic + - choose: + # Start the show + - conditions: + - condition: trigger + id: start + sequence: + # First up we play This is Halloween from Nightmare Before Christmas. Change this to what ever audio you want, or comment this one out. + - service: script.local_audio + data: + media: "/media/disney/This_is_Halloween.mp3" + volume: .5 + # And turn on the haunted House script. + - service: script.turn_on + target: + entity_id: script.haunted_house + # Stop the show + - conditions: + - condition: trigger + id: stop + sequence: + # And finally we turn off the haunted house script so no more sounds play. + - service: script.turn_off + target: + entity_id: script.haunted_house + # This stops the media player. Besure to change it to match your music player + - service: media_player.media_stop + target: + entity_id: media_player.ha_speaker + default: [] + initial_state: true + mode: single script: diff --git a/config/packages/security.yaml b/config/packages/security.yaml index 0b259fb..03556d3 100755 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -393,8 +393,8 @@ automation: ############################################# # Normal Notifications # Door chime when doors are open to make sure we know when people are coming/going - - id: door_chime - alias: Door Chine + - id: door_notifications + alias: Door Notifications trigger: - platform: state entity_id: @@ -403,6 +403,17 @@ automation: - binary_sensor.attic_door - binary_sensor.back_door to: 'on' + id: chime + - platform: state + entity_id: + - binary_sensor.front_door + - binary_sensor.laundry_room_door + - binary_sensor.attic_door + - binary_sensor.back_door + from: 'off' + to: 'on' + for: '00:01:00' + id: door_still_open condition: condition: and conditions: @@ -421,48 +432,87 @@ automation: entity_id: media_player.ha_speaker state: 'off' action: - - service: script.door_chime + - choose: + - conditions: + - condition: trigger + id: chime + sequence: + - service: media_player.turn_on + entity_id: media_player.ha_speaker + - service: media_player.volume_set + data_template: + entity_id: media_player.ha_speaker + volume_level: .5 + - service: media_player.play_media + entity_id: media_player.ha_speaker + data: + media_content_id: /media/sounds/door_open.wav + media_content_type: "music" + - conditions: + - condition: trigger + id: door_still_open + sequence: + - service: script.speech_engine + data: + who: '{{ states.sensor.room_audio.state }}' + message: > + The {{ trigger.to_state.attributes.friendly_name }} + {{ [ + ' is standing open.', + ' is open.', + ' does not close on its own.', + ' was left standing open.' + ] | random }} + {{ [ + 'Can a human be so kind and close it?', + 'The air quality in this house has actually improved.', + 'Closing the door would improve the internal climate of the house.', + 'Hey. The door was just opened and this is crazy. But now you know. So close it maybe.', + 'If at first you do not succeed in closing the door, please try again. Like, Right now seems like a good time to try again.', + 'And the automatic door closer appears to be broken. So, you know what to do. Time to get physical.', + 'I would close it for you. But I lack legs. And Arms.' + ] | random }} initial_state: true - # If door is open too long play message and identify open door. - - id: door_opened_long - alias: Door Opened Too Long - trigger: - - platform: state - entity_id: - - binary_sensor.front_door - - binary_sensor.laundry_room_door - - binary_sensor.attic_door - - binary_sensor.back_door - from: 'off' - to: 'on' - for: '00:01:00' - condition: - - condition: state - entity_id: input_boolean.audible_notifications - state: 'on' - action: - - service: script.speech_engine - data_template: - who: '{{ states.sensor.room_audio.state }}' - message: > - The {{ trigger.to_state.attributes.friendly_name }} - {{ [ - ' is standing open.', - ' is open.', - ' does not close on its own.', - ' was left standing open.' - ] | random }} - {{ [ - 'Can a human be so kind and close it?', - 'The air quality in this house has actually improved.', - 'Closing the door would improve the internal climate of the house.', - 'Hey. The door was just opened and this is crazy. But now you know. So close it maybe.', - 'If at first you do not succeed in closing the door, please try again. Like, Right now seems like a good time to try again.', - 'And the automatic door closer appears to be broken. So, you know what to do. Time to get physical.', - 'I would close it for you. But I lack legs. And Arms.' - ] | random }} - initial_state: true + # # If door is open too long play message and identify open door. + # - id: door_opened_long + # alias: Door Opened Too Long + # trigger: + # - platform: state + # entity_id: + # - binary_sensor.front_door + # - binary_sensor.laundry_room_door + # - binary_sensor.attic_door + # - binary_sensor.back_door + # from: 'off' + # to: 'on' + # for: '00:01:00' + # condition: + # - condition: state + # entity_id: input_boolean.audible_notifications + # state: 'on' + # action: + # - service: script.speech_engine + # data_template: + # who: '{{ states.sensor.room_audio.state }}' + # message: > + # The {{ trigger.to_state.attributes.friendly_name }} + # {{ [ + # ' is standing open.', + # ' is open.', + # ' does not close on its own.', + # ' was left standing open.' + # ] | random }} + # {{ [ + # 'Can a human be so kind and close it?', + # 'The air quality in this house has actually improved.', + # 'Closing the door would improve the internal climate of the house.', + # 'Hey. The door was just opened and this is crazy. But now you know. So close it maybe.', + # 'If at first you do not succeed in closing the door, please try again. Like, Right now seems like a good time to try again.', + # 'And the automatic door closer appears to be broken. So, you know what to do. Time to get physical.', + # 'I would close it for you. But I lack legs. And Arms.' + # ] | random }} + # initial_state: true # If guest mode is enabled, notify the house - id: guest_mode_feedback @@ -872,22 +922,22 @@ script: # door chime script, just plays sound anytime called. - door_chime: - sequence: - - condition: state - entity_id: input_boolean.audible_notifications - state: 'on' - - service: media_player.turn_on - entity_id: media_player.ha_speaker - - service: media_player.volume_set - data_template: - entity_id: media_player.ha_speaker - volume_level: .5 - - service: media_player.play_media - entity_id: media_player.ha_speaker - data: - media_content_id: /media/sounds/door_open.wav - media_content_type: "music" + # door_chime: + # sequence: + # - condition: state + # entity_id: input_boolean.audible_notifications + # state: 'on' + # - service: media_player.turn_on + # entity_id: media_player.ha_speaker + # - service: media_player.volume_set + # data_template: + # entity_id: media_player.ha_speaker + # volume_level: .5 + # - service: media_player.play_media + # entity_id: media_player.ha_speaker + # data: + # media_content_id: /media/sounds/door_open.wav + # media_content_type: "music" # Play Fire alarm Siren # fire_alarm: