I just tried that with an automation like this:
- id: startup
alias: Startup Routine
initial_state: 'on'
trigger:
platform: homeassistant
event: start
action:
- service: cloud.remote_connect
However, when I restarted the server it gave the following in the log:
2019-03-21 13:54:08 ERROR (MainThread) [homeassistant.components.automation] Error while executing automation automation.startup_routine. Unknown error for call_service at pos 1:
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/automation/__init__.py", line 381, in action
await script_obj.async_run(variables, context)
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/script.py", line 131, in async_run
await self._handle_action(action, variables, context)
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/script.py", line 210, in _handle_action
action, variables, context)
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/script.py", line 299, in _async_call_service
context=context
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/service.py", line 88, in async_call_from_config
domain, service_name, service_data, blocking=blocking, context=context)
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1138, in async_call
self._execute_service(handler, service_call))
File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
yield self # This tells Task to wait for completion.
File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
future.result()
File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
raise self._exception
File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
result = coro.send(None)
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1160, in _execute_service
await handler.func(service_call)
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/cloud/__init__.py", line 184, in _service_handler
await cloud.remote.connect()
File "/srv/homeassistant/lib/python3.5/site-packages/hass_nabucasa/remote.py", line 246, in connect
raise RemoteNotConnected()
hass_nabucasa.remote.RemoteNotConnected
Edit:
It appears to work if I add this before the service call:
- delay: '00:00:30'
So, it looks like at the time the start event is received it is not quite ready to connect to the remote endpoint.