I am wondering if there is a way to load certain components even if the corresponding device is off during boot time.
The AppleTV and Broadlink component seem to require the correpsonding device. Since I switch of everything via Sonoff, I need to switch it on before restarting Home Assistant. It would be nice if this would not be required anymore, which would greatly simplify my restart script.
I am trying to switch off components which are only switched on due to a home assistant restart.
Before restarting home assistant, various components are switched on:
prepare_restart:
alias: Prepare for restart
sequence:
- service: switch.turn_on
entity_id: switch.tv
- service: switch.turn_on
entity_id: switch.tv_2
- service: homeassistant.turn_on
entity_id: group.all_speaker
I do not want to have those components always on, therefore I am trying to switch them off after home assistant restarted. But since some of them could be potentially be in use (e.g. the TV), they should only be switched off, if not in use. I wonder how you guys approach this or have solved this.
Since components such as an AppleTV are sometimes not available after reboot, I have a automation to call an init script after a delay:
- alias: 'Startup: Init components'
initial_state: 'on'
trigger:
platform: homeassistant
event: start
action:
- service: script.init_hass
- delay:
minutes: 1
- service: script.init_tv
- service: script.init_tv_2
- service: script.init_sonos
The init scripts then look like this:
init_tv_2:
alias: 'Init TV2'
sequence:
- condition: or
conditions:
- condition: state
entity_id: media_player.tv_2
state: 'paused'
- condition: state
entity_id: media_player.tv_2
state: 'idle'
- service: switch.turn_off
entity_id: switch.tv_2
I still have the issue, that the Apple TV is not properly loaded by home assistant and therefore my TV will stay on, since I can’t access the playing status.
Any ideas if there is a simpler way to achieve this?