Can HA process external web commands when an event is triggered?

Thanks, I’ll give it a go when I get home. :+1:

I played around with indention and dashes and placing it directly under the - service but it tells me my configuration is invalid.
Configuration invalid

Error loading /config/configuration.yaml: while parsing a block collection in “/config/automations.yaml”, line 2, column 1 expected <block end>, but found ‘?’ in “/config/automations.yaml”, line 31, column 1
line 2 is the - id: and 31 is the start of the rest_command:

automations.yaml file

#automations.yaml TEST file
- id: Kitchen_light_test_on
  alias: Turn on Kitchen light when door opened
  trigger:
    - platform: state
      entity_id: binary_sensor.dome_dw_sensor1_112
      to: 'on'
      from: 'off'
  condition:
    condition: or
    conditions:
      - condition: sun
        after: sunset
        after_offset: "-01:00:00"
      - condition: sun
        before: sunrise
        before_offset: "+01:00:00"
  action:
    - service: homeassistant.turn_on
      entity_id: 
      - light.kit_eat_light_dim_14
      - light.kitchen_light_104
    - service: rest_command.play_fdo_sound
    - delay: '00:00:10'
    - service: homeassistant.turn_off
      entity_id:
      - light.kit_eat_light_dim_14
      - light.kitchen_light_104
    - service: rest_command.play_fdo_sound

rest_command:
  play_fdo_sound:
    url: 'http://192.168.0.201/sound.php?file=fdo&volume=100'
    
#automations.yaml TEST file end

I cleared my automatons.yaml and moved the code to my configuration.yaml
it works when in the configuration.yaml … I guess I need to learn these spaces and dashes rules when in a file.

can I have two automatons on 1 trigger? One in configuration.yaml and another in automatons.yaml?

automation:
- id: Kitchen_light_test_on
  alias: Turn on Kitchen light when door opened
  trigger:
    - platform: state
      entity_id: binary_sensor.dome_dw_sensor1_112
      to: 'on'
      from: 'off'
  condition:
    condition: or
    conditions:
      - condition: sun
        after: sunset
        after_offset: "-01:00:00"
      - condition: sun
        before: sunrise
        before_offset: "+01:00:00"
  action:
    - service: homeassistant.turn_on
      entity_id: 
      - light.kit_eat_light_dim_14
      - light.kitchen_light_104
    - service: rest_command.play_fdo_sound

    - delay: '00:00:10'
    - service: homeassistant.turn_off
      entity_id:
      - light.kit_eat_light_dim_14
      - light.kitchen_light_104

rest_command:
  play_fdo_sound:
    url: "http://192.168.0.201/sound.php?file=fdo&volume=100"

Hmm that would be messy, if it could…

If you have a sequence of tasks, write them into scripts and call them by an automation.

P.S. Yes, this space and tab thing in YAML was quite new for me and irritating. I use Visual Studio Code with Jinja and YAML plugins, this make things easier :wink:

I may try Visual Studio. Yes, it seems (to me) that the syntax is different between the configuration.yaml and automations.yaml and other yaml files

I was thinking of two separate task driven by a single sensor but two different files. Like, one for the sound and one for the lights on/off

I’ve have two automation: scripts that work perfectly in the configuration.yaml but only one in the configuration.yaml file at a time

with both automations in the configuration.yaml file, they both turn_on and off the lights but only the last one listed will run play the sound.

################################################################# automation:TEST
automation test:
- id: Kitchen_light_test_on
  alias: Both Kitchen light on then off when door opened
  trigger:
    - platform: state
      entity_id: binary_sensor.dome_dw_sensor1_112
      to: 'on'
      from: 'off'
  action:
    - service: homeassistant.turn_on
      entity_id: 
      - light.kit_eat_light_dim_14
      - light.kitchen_light_104
    - service: rest_command.play_fdo_sound

    - delay: '00:00:10'
    - service: homeassistant.turn_off
      entity_id:
      - light.kit_eat_light_dim_14
      - light.kitchen_light_104

rest_command:
  play_fdo_sound:
    url: "http://192.168.0.201/sound.php?file=fdo&volume=100"
################################################################# automation: TEST end

################################################################
## Play Kitchen Door Open
##
automation KDO:
- id: kitchenDoor_open
  alias: Breakfast light only when Kitchen Door Open
  trigger:
    - platform: state
      entity_id: binary_sensor.kitchen_door_1_65
      from: 'off'
      to: 'on'
  action:
    - service: homeassistant.turn_on
      entity_id: 
      - light.kit_eat_light_dim_14
    - service: rest_command.play_kdo_sound
    - delay: '00:00:10'
    - service: homeassistant.turn_off
      entity_id:
      - light.kit_eat_light_dim_14
rest_command:
  play_kdo_sound:
    url: "http://192.168.0.201/sound.php?file=kdo&volume=100"
##
## Play Kitchen Door Open end
################################################################
 

i will endeavor to persevere… and I have no idea why the code above looks grayed out

this is the error message in the log each time the automation is run.

WARNING (MainThread) [homeassistant.core] Unable to find service rest_command/play_fdo_sound

splitting it up is the plan. I’d just like to get 2 working in the configuration.yaml

download/installing Visual Studio Code now. I don’t see Jinja and YAML as an option. Are the plugins installed after the install? Are there dependencies?

nevermind, “the google” is my friend. :rofl:

1 Like

[rant]The Automation Editor documentation is seriously lacking.

To add the lights it took me a good bit of googling to figure out what it wanted between the “Service Data” {} section of the automation.
in my case it’s
“entity_id”: “binary_sensor.kitchen_door_1_65”
or
“entity_id”: “light.kitchen_light_104”
for the two lights I’m testing with.

I think the documentation examples in the official documentation should include examples that are actually useful.
[/rant]

Well, got it to work with two automaintions
I stripped the automation:s out of the configuration,yaml
started with an empty automations.yaml
used the Automation Editor under configuration\Automation
created two new automations with lights turning on /then off.
in the “actions” under “service call” I noticed that rest_command.play_kdo_sound was a choice but not rest_command.play_fdo_sound. (now I could consistently get one of them to play but not both and it depended which one came first in the configuration.yaml file.)
I hadn’t rebooted yet. I used the rest_command.play_kdo_sound option to see what it placed in the automations file.
it added this…

  - alias: ''
    data:
      url: http://192.168.0.201/sound.php?file=kdo&volume=100
    service: rest_command.play_kdo_sound

so I modified the configuration.yaml file and added this to the end

rest_command:
  play_dsa_mp3:
    url: "http://192.168.0.201/sound.php?file=dsa&volume=100"
  play_kdo_mp3:
    url: "http://192.168.0.201/sound.php?file=kdo&volume=100"

and rebooted the Hass.io
At that point both rest_command: choices showed up under “actions” under “service call”
so I modified the automations.yaml to renaming the play sound options to read as follows.

- id: '1535144973178'
  alias: DomeTest
  trigger:
  - entity_id: binary_sensor.dome_dw_sensor1_112
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - data:
      entity_id: light.kit_eat_light_dim_14
    service: light.turn_on
  - delay: 00:00:10
  - data:
      entity_id: light.kit_eat_light_dim_14
    service: light.turn_off
  - alias: ''
    service: rest_command.play_dsa_mp3
    data:
      url: http://192.168.0.201/sound.php?file=dsa&volume=100
- id: '1535146352770'
  alias: KD Automation
  trigger:
  - entity_id: binary_sensor.kitchen_door_1_65
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - service: light.turn_on
    entity_id: light.kitchen_light_104
  - delay: 00:00:10
  - service: light.turn_off
    entity_id: light.kitchen_light_104
  - alias: ''
    service: rest_command.play_kdo_mp3
    data:
      url: http://192.168.0.201/sound.php?file=kdo&volume=100

so now I wonder if there’s a way to call a url in an automation without having to define rest commands in the configuration.yaml?

The documentation, like all of home-assistant, is open source. Please submit your suggested changes.

Rebooting hass sucks, I know… I have a huge configuration and it takes lots of time for that.
So, for some use cases, I create bash scripts, when I know I want test and/or change the call several times.

shell_command:
  parse_phrase: "sudo /usr/sbin/parse_snips.sh '{{states('sensor.mqqt_tasker_phrase')}}'"
  parse_input_text: "sudo /usr/sbin/parse_snips.sh '{{states('input_text.tasker_phrase')}}'"

If you want, I give you detailed information.

tl;tr
You only have to change the bash script without rebooting hass everytime… :wink:

I am interested. I intend to explore scripts but hadn’t gotten there yet. I’ve only had HA for a week and have only used the “Automation Editor” for a day. :slight_smile:

I have found that rearranging the order from the "Automation Editor"s order has sped things up a bit.

- id: '1535144973178'
  alias: DomeTest
  trigger:
  - entity_id: binary_sensor.dome_dw_sensor1_112
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - alias: 'play_dsa_mp3'
    service: rest_command.play_dsa_mp3
    data:
      url: http://192.168.0.201/sound.php?file=dsa&volume=100
  - service: light.turn_on
    entity_id: light.kit_eat_light_dim_14
  - delay: 00:00:10
  - data:
      entity_id: light.kit_eat_light_dim_14
    service: light.turn_off
- id: '1535146352770'
  alias: KD Automation
  trigger:
  - entity_id: binary_sensor.kitchen_door_1_65
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - alias: 'play_kdo_mp3'
    service: rest_command.play_kdo_mp3
    data:
      url: http://192.168.0.201/sound.php?file=kdo&volume=100
  - service: light.turn_on
    entity_id: light.kitchen_light_104
  - delay: 00:00:10
  - service: light.turn_off
    entity_id: light.kitchen_light_104

Where would I submit my suggested changes to the documentation, I think some real world examples that included actual lights and sensors would have sped my success up a little bit and reduced my questions on here.

Just go to the doc page and look for “edit this page on github”, open an issue with your suggestion.

Okay, I will try to make a general example easy to understand… d’oh

thanks…

I have set up automation to tell me a door, gate, or window is open @ 23:00.
I have two gates I’d like to get repeat notification that they are open until closed.
With the previous code, I get a notification that the gate is open.
With the below code, it waits 5 minutes and then notifies continuously.
I’ve tried placing - delay: '00:01:00' , repeat: 10 and initial_state: 'off and on'
in various places but it always goes into non stop execution of the url: http://192.168.0.201/sound.php?file=test&volume=100

- id: '1535307883175'
  alias: A dome test if sensor is triggered and left open
  trigger:
  - minutes: "/5"
    platform: time
  condition:
  - condition: state
    entity_id: binary_sensor.dome_dw_sensor1_112
    state: 'on'
  action:
  - data:
      url: http://192.168.0.201/sound.php?file=test&volume=100 
    service: rest_command.play_test_mp3

I looked at Alert also… any suggestions?

so I have it working well enough that I think I’m done fiddling with it but here’s something funny.
I have my dome test sensor and two gate sensors using time trigger

  trigger:
    seconds: 15
    platform: time

and here’s what’s funny, some how seconds: 15 translates into 1 minute. I think it’s supposed to trigger @ 15 seconds past the top of each minute.

The dome test will trigger @ 30 seconds past the top of the minute, and the gate triggers @ 45 seconds from the top of the minute. regardless of when it was opened.

very odd

right now I have two automatons for them, one when it opens, and one if it’s left open. I’d like to combine them but this works for now.

- id: '1535308795832'
  alias: a dome test if sensor triggered
  trigger:
  - entity_id: binary_sensor.dome_dw_sensor1_112
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
    service: rest_command.play_test_mp3

- id: '1535653515479'
  alias: a dome test if sensor triggered left open
  trigger:
    seconds: 15
    platform: time
  condition:
  - condition: state
    entity_id: binary_sensor.dome_dw_sensor1_112
    state: 'on'
  action:
  - service: rest_command.play_test_mp3

I also learned that the -data and url: code in unnecessary in the automation.yaml.

So for all the newbies like me here’s what I’ve ended up using to tell me around 11pm if a door or window is open and if a gate was left open anytime (can’t let the dogs get out).
I haven’t removed the -data and url: code from the top of the file yet but have from the end of the file.

so here’s what’s in the configuration.yaml to make the rest commands work.

configuration.yaml

rest_command:
  play_ldo_mp3:
    url: "http://192.168.0.201/sound.php?file=ldo&volume=100"
  play_kdo_mp3:
    url: "http://192.168.0.201/sound.php?file=kdo&volume=100"
  play_ugo_mp3:
    url: "http://192.168.0.201/sound.php?file=ugo&volume=100"
  play_lgo_mp3:
    url: "http://192.168.0.201/sound.php?file=lgo&volume=100"
  play_gbdo_mp3:
    url: "http://192.168.0.201/sound.php?file=gbdo&volume=100"
  play_sgd_mp3:
    url: "http://192.168.0.201/sound.php?file=sgd&volume=100"
  play_fdo_mp3:
    url: "http://192.168.0.201/sound.php?file=fdo&volume=100"
  play_jwoje_mp3:
    url: "http://192.168.0.201/sound.php?file=jwoje&volume=100"
  play_egdo_mp3:
    url: "http://192.168.0.201/sound.php?file=egdo&volume=100"
  play_wgdo_mp3:
    url: "http://192.168.0.201/sound.php?file=wgdo&volume=100"
  play_basementdo_mp3:
    url: "http://192.168.0.201/sound.php?file=basementdo&volume=100"
  play_wugro_mp3:
    url: "http://192.168.0.201/sound.php?file=wugro&volume=100"
  play_wlgro_mp3:
    url: "http://192.168.0.201/sound.php?file=wlgro&volume=100"
  play_test_mp3:
    url: "http://192.168.0.201/sound.php?file=test&volume=100"

and the automatons.yaml

- id: '1535144973178'
  alias: Laundyroom Door Open
  trigger:
  - entity_id: binary_sensor.laundyroomdoor_113
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - alias: play_ldo_mp3
    data:
      url: http://192.168.0.201/sound.php?file=ldo&volume=100
    service: rest_command.play_ldo_mp3
- id: '1535146352770'
  alias: Kitchen Door Open
  trigger:
  - entity_id: binary_sensor.kitchen_door_1_65
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - alias: play_kdo_mp3
    data:
      url: http://192.168.0.201/sound.php?file=kdo&volume=100
    service: rest_command.play_kdo_mp3
- id: '1535247958715'
  alias: Upper Gate Open
  trigger:
  - entity_id: binary_sensor.upper_gate_119
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - data:
      url: http://192.168.0.201/sound.php?file=ugo&volume=100
    service: rest_command.play_ugo_mp3
- id: '1535248438903'
  alias: Lower Gate open
  trigger:
  - entity_id: binary_sensor.lower_gate_121
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - data:
      url: http://192.168.0.201/sound.php?file=lgo&volume=100
    service: rest_command.play_lgo_mp3
- id: '1535248542354'
  alias: Garage Back Door Open
  trigger:
  - entity_id: binary_sensor.back_door_1_69
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - data:
      url: http://192.168.0.201/sound.php?file=gbdo&volume=100
    service: rest_command.play_gbdo_mp3
- id: '1535248625309'
  alias: Sliding Glass Door Open
  trigger:
  - entity_id: binary_sensor.sliding_glass_door_109
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - data:
      url: http://192.168.0.201/sound.php?file=sgd&volume=100
    service: rest_command.play_sgd_mp3
- id: '1535248693332'
  alias: Front Door Open
  trigger:
  - entity_id: binary_sensor.front_door_1_67
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - data:
      url: http://192.168.0.201/sound.php?file=fdo&volume=100
    service: rest_command.play_fdo_mp3
- id: '1535248913198'
  alias: Jackies Window Open
  trigger:
  - entity_id: binary_sensor.jnorthwindow_59
    from: 'off'
    platform: state
    to: 'on'
  - entity_id: binary_sensor.jsouthwindow_75
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - data:
      url: http://192.168.0.201/sound.php?file=jwoje&volume=100
    service: rest_command.play_jwoje_mp3
- id: '1535249068830'
  alias: Garage Door East
  trigger:
  - entity_id: binary_sensor.garage_door_e_1_68
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - data:
      url: http://192.168.0.201/sound.php?file=egdo&volume=100
    service: rest_command.play_egdo_mp3
- id: '1535249173346'
  alias: Garage Door West
  trigger:
  - entity_id: binary_sensor.garage_door_w_111
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - data:
      url: http://192.168.0.201/sound.php?file=wgdo&volume=100
    service: rest_command.play_wgdo_mp3
- id: '1535249320393'
  alias: Basement Door Open
  trigger:
  - entity_id: binary_sensor.basement_door_1_71
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - data:
      url: http://192.168.0.201/sound.php?file=basementdo&volume=100
    service: rest_command.play_basementdo_mp3
- id: '1535298612412'
  alias: zCheck Garage Back Door Open
  trigger:
  - at: '23:00:00'
    platform: time
  condition:
  - condition: state
    entity_id: binary_sensor.back_door_1_69
    state: 'on'
  action:
  - data:
      url: http://192.168.0.201/sound.php?file=gbdo&volume=100
    service: rest_command.play_gbdo_mp3
- id: '1535298954391'
  alias: zCheck for Basement Door Open
  trigger:
  - at: '23:00:10'
    platform: time
  condition:
  - condition: state
    entity_id: binary_sensor.basement_door_1_71
    state: 'on'
  action:
  - data:
      url: http://192.168.0.201/sound.php?file=basementdo&volume=100
    service: rest_command.play_basementdo_mp3
- id: '1535299146090'
  alias: zCheck for Front Door Open
  trigger:
  - at: '23:00:20'
    platform: time
  condition:
  - condition: state
    entity_id: binary_sensor.front_door_1_67
    state: 'on'
  action:
  - data:
      url: http://192.168.0.201/sound.php?file=fdo&volume=100
    service: rest_command.play_fdo_mp3
- id: '1535299366780'
  alias: zCheck for Garage Door (East) Open
  trigger:
  - at: '23:00:30'
    platform: time
  condition:
  - condition: state
    entity_id: binary_sensor.garage_door_e_1_68
    state: 'on'
  action:
  - data:
      url: http://192.168.0.201/sound.php?file=egdo&volume=100
    service: rest_command.play_egdo_mp3
- id: '1535299540894'
  alias: zCheck for Garage Door (west) Open
  trigger:
  - at: '23:00:40'
    platform: time
  condition:
  - condition: state
    entity_id: binary_sensor.garage_door_w_111
    state: 'on'
  action:
  - data:
      url: http://192.168.0.201/sound.php?file=wgdo&volume=100
    service: rest_command.play_wgdo_mp3
- id: '1535299677281'
  alias: zCheck for Jackies North Window Open
  trigger:
  - at: '23:00:50'
    platform: time
  condition:
  - condition: state
    entity_id: binary_sensor.jnorthwindow_59
    state: 'on'
  action:
  - data:
      url: http://192.168.0.201/sound.php?file=jwoje&volume=100
    service: rest_command.play_jwoje_mp3
- id: '1535299794185'
  alias: zCheck for Jackies South Window Open
  trigger:
  - at: '23:01:00'
    platform: time
  condition:
  - condition: state
    entity_id: binary_sensor.jsouthwindow_75
    state: 'on'
  action:
  - data:
      url: http://192.168.0.201/sound.php?file=jwoje&volume=100
    service: rest_command.play_jwoje_mp3
- id: '1535299926498'
  alias: zCheck for Kitchen Door Open
  trigger:
  - at: '23:01:10'
    platform: time
  condition:
  - condition: state
    entity_id: binary_sensor.kitchen_door_1_65
    state: 'on'
  action:
  - data:
      url: http://192.168.0.201/sound.php?file=kdo&volume=100
    service: rest_command.play_kdo_mp3
- id: '1535300084373'
  alias: zCheck for Laundyroom Door Open
  trigger:
  - at: '23:01:20'
    platform: time
  condition:
  - condition: state
    entity_id: binary_sensor.laundyroomdoor_113
    state: 'on'
  action:
  - data:
      url: http://192.168.0.201/sound.php?file=ldo&volume=100
    service: rest_command.play_ldo_mp3
- id: '1535300388286'
  alias: zCheck for Sliding Glass Door Open
  trigger:
  - at: '23:01:30'
    platform: time
  condition:
  - condition: state
    entity_id: binary_sensor.sliding_glass_door_109
    state: 'on'
  action:
  - data:
      url: http://192.168.0.201/sound.php?file=sgd&volume=100
    service: rest_command.play_sgd_mp3
- id: '1535300520317'
  alias: zCheck for Upper Gate Open
  trigger:
    seconds: 30
    platform: time
  condition:
  - condition: state
    entity_id: binary_sensor.upper_gate_119
    state: 'on'
  action:
    service: rest_command.play_wugro_mp3
- id: '1535300242557'
  alias: zCheck for Lower Gate Open
  trigger:
    seconds: 30
    platform: time
  condition:
  - condition: state
    entity_id: binary_sensor.lower_gate_121
    state: 'on'
  action:
    service: rest_command.play_wlgro_mp3
- id: '1535308795832'
  alias: a dome test if sensor triggered
  trigger:
  - entity_id: binary_sensor.dome_dw_sensor1_112
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
    service: rest_command.play_test_mp3
- id: '1535653515479'
  alias: a dome test if sensor triggered left open
  trigger:
    seconds: 15
    platform: time
  condition:
  - condition: state
    entity_id: binary_sensor.dome_dw_sensor1_112
    state: 'on'
  action:
  - service: rest_command.play_test_mp3

Could I have used the - platform: command_line
as seen in this thread?

  - platform: command_line
    command: curl -i http://192.168.0.1

as it turns out, this not unreliable enough to be “production”. I can open and close a door repeatedly and it will work. but if there’s an interval of a few hours it may or may not work.
I see the below error in the log

   2018-09-30 12:09:29 ERROR (MainThread) [homeassistant.core] Error executing service <ServiceCall rest_command.play_ugo_mp3 (c:b061d8b773764a35b8871a44b282734b): url=http://192.168.0.201/sound.php?file=ugo&volume=100>
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/rest_command.py", line 105, in async_service_handler
    headers=headers
  File "/usr/local/lib/python3.6/site-packages/aiohttp/client.py", line 370, in _request
    timeout=timeout
  File "/usr/local/lib/python3.6/site-packages/aiohttp/connector.py", line 445, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/usr/local/lib/python3.6/site-packages/aiohttp/connector.py", line 757, in _create_connection
    req, traces, timeout)
  File "/usr/local/lib/python3.6/site-packages/aiohttp/connector.py", line 862, in _create_direct_connection
    req=req, client_error=client_error)
  File "/usr/local/lib/python3.6/site-packages/aiohttp/connector.py", line 822, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)
  File "uvloop/loop.pyx", line 1871, in create_connection
  File "uvloop/loop.pyx", line 1860, in uvloop.loop.Loop.create_connection
concurrent.futures._base.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/rest_command.py", line 105, in async_service_handler
    headers=headers
  File "/usr/local/lib/python3.6/site-packages/async_timeout/__init__.py", line 45, in __exit__
    self._do_exit(exc_type)
  File "/usr/local/lib/python3.6/site-packages/async_timeout/__init__.py", line 92, in _do_exit
    raise asyncio.TimeoutError
concurrent.futures._base.TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/core.py", line 1177, in _event_to_service_call
    await service_handler.func(service_call)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/rest_command.py", line 115, in async_service_handler
    _LOGGER.warning("Timeout call %s.", request.url)
UnboundLocalError: local variable 'request' referenced before assignment