From 36a59f54c55e135f4a817d7c238ce36edfb1e16c Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Tue, 28 Mar 2023 19:10:33 -0400 Subject: [PATCH] Improved method for detecting last Alexa device --- node-red/projects/NerdFlows | 2 +- packages/alexa.yaml | 6 +++--- packages/audio.yaml | 21 +-------------------- packages/jarvis.yaml | 2 +- packages/notify.yaml | 2 +- scripts.yaml | 2 +- 6 files changed, 8 insertions(+), 27 deletions(-) diff --git a/node-red/projects/NerdFlows b/node-red/projects/NerdFlows index fce1603..52e6913 160000 --- a/node-red/projects/NerdFlows +++ b/node-red/projects/NerdFlows @@ -1 +1 @@ -Subproject commit fce1603353e16965d9c7f132daa71712ff00f973 +Subproject commit 52e6913c0e415768882814934c4e65ea2672d51e diff --git a/packages/alexa.yaml b/packages/alexa.yaml index 028f909..619e45c 100644 --- a/packages/alexa.yaml +++ b/packages/alexa.yaml @@ -126,7 +126,7 @@ automation: - service: script.kallen_desktop_wake - service: script.status_annc data: - who: "{{ states('sensor.last_alexa') }}" + who: "{{ states('sensor.last_alexa_entity_id') }}" call_confirmation: 1 - if: - condition: trigger @@ -134,7 +134,7 @@ automation: then: - service: script.status_annc data: - who: "{{ states('sensor.last_alexa') }}" + who: "{{ states('sensor.last_alexa_entity_id') }}" call_confirm_no: 1 - id: d1edfcf7-2712-49f4-b8f1-17f5b184b5ce @@ -168,7 +168,7 @@ automation: then: - service: script.status_annc data: - who: "{{ states('sensor.last_alexa') }}" + who: "{{ states('sensor.last_alexa_entity_id') }}" call_security_not_armed: 1 script: diff --git a/packages/audio.yaml b/packages/audio.yaml index 01d0133..e73d264 100644 --- a/packages/audio.yaml +++ b/packages/audio.yaml @@ -166,23 +166,4 @@ automation: mqtt: sensor: - name: "Room Presence" - state_topic: "house/presence/current_room" - -sensor: - - platform: template - sensors: - alexa_audio: - friendly_name: "Alexa Audio" - value_template: >- - {%- if is_state('sensor.last_alexa', 'media_player.living_room_echo_dot') %} - Living Room Echo Dot - {% elif is_state('sensor.last_alexa', 'media_player.basement_echo_dot') %} - Basement Echo Dot - {% elif is_state('sensor.last_alexa', 'media_player.master_bedroom_echo_dot') %} - Master Bedroom Echo Dot - {% else %} - Living Room Echo Dot - {%- endif %} - last_alexa: - value_template: > - {{ states.media_player | selectattr('attributes.last_called','eq',True) | map(attribute='entity_id') | first }} \ No newline at end of file + state_topic: "house/presence/current_room" \ No newline at end of file diff --git a/packages/jarvis.yaml b/packages/jarvis.yaml index 7e22322..6fc60cd 100644 --- a/packages/jarvis.yaml +++ b/packages/jarvis.yaml @@ -27,7 +27,7 @@ script: sequence: - service: script.status_annc data: - who: "{{ states('sensor.last_alexa')}}" + who: "{{ states('sensor.last_alexa_entity_id')}}" call_confirmation: 1 google_interjection: diff --git a/packages/notify.yaml b/packages/notify.yaml index 024c125..8228eb4 100644 --- a/packages/notify.yaml +++ b/packages/notify.yaml @@ -1731,7 +1731,7 @@ script: sequence: - service: script.speech_engine_simplified data: - who: '{{ states(''sensor.last_alexa'') }}' + who: '{{ states(''sensor.last_alexa_entity_id'') }}' message: > At {{ states('sensor.jarvis_last_msg_time') }} in the {{ states('sensor.jarvis_last_location') }} diff --git a/scripts.yaml b/scripts.yaml index ff622ae..8bf80b5 100644 --- a/scripts.yaml +++ b/scripts.yaml @@ -42,7 +42,7 @@ give_me_darkness: text: Would you like me to arm the security system? event_id: actionable_notification_night_security_arm - alexa_device: '{{ states(''sensor.last_alexa'') }}' + alexa_device: '{{ states(''sensor.last_alexa_entity_id'') }}' alias: Ask to arm security alias: Ask to arm security if both adults are home alias: If guest mode is off