Hi,
I got an automation which switches on my WLAN and a certain wall socket when I come home. To this wall socket a Sonos Box is connected. As soon as the Sonos Box (i.e. the media_player) becomes available within Home Assistant a tts script is started (my home is saying welcome to me ).
The problem is that it takes about almost two minutes until the Sonos box becomes available within HA so the welcoming text is played far too late.
According to the Sonos box status light the box is connected to the WLAN after appr. 50 seconds after wall socket and WLAN was turned on. So, if Home Assistant would scan after 50 seconds for the availability of the Sonos Box the tts script would start earlier.
Is there any way to tell HA to scan manually for the availability of a media_player entity?
My automation which does not address the aforementioned problem is as follows:
- id: Generell1
alias: Geräte an/aus beim Ankommen und Verlassen
trigger:
- platform: state
entity_id: input_boolean.zu_hause
to: 'on'
- platform: state
entity_id: input_boolean.zu_hause
to: 'off'
for: '00:01:00'
action:
choose:
- conditions: "{{ trigger.to_state.state == 'on' }}"
sequence:
- service: switch.turn_on
entity_id: switch.eg_whz_radio
- service: switch.turn_on
entity_id: group.wifi_fritzbox
- service: script.notify_telegram_ios
data:
title: "Devices turned on"
message: "message"
- delay: '00:00:05'
- wait_template: "{{ is_state('media_player.wohnzimmer', 'idle') }}"
- service: script.sonos_say
data:
sonos_entity: media_player.wohnzimmer
volume: 0.5
message: "Welcome Back"
delay: '00:00:05'
- conditions: "{{ trigger.to_state.state == 'off' }}"
sequence:
- service: switch.turn_off
entity_id: all
- service: switch.turn_off
entity_id:
- group.wifi_fritzbox
- group.guest_wifi
- service: light.turn_off
entity_id: all
- service: script.notify_telegram_ios
data:
title: "Message"
message: "Message"