Trying to turn on switch from IFTTT

I’ve created an IFTTT webhooks applet to turn on a switch, but HA doesn’t seem to be responding. Details of the IFTTT webhook are:

HTTP POST URL: https://mydns.ddns.net:8123/api/services/switch/turn_on?api_password=myHApasswordWithoutQuotes

Content Type: application/json

Body: {"entity_id":"switch.onkyo_game" }

My HA config…in configuration.yaml:

switch:
  - platform: broadlink
    host: 192.168.1.87
    mac: '34:EA:34:C7:87:FA'
    switches:
      tv_samsung:
        friendly_name: "Samsung TV"
        command_on: 'JgDSAJaSFjUWNRc1FhETExYRFREWERU2FTYUNxQTFhETExYRExMWNRcQExMWNRc1FhAWERY1FhAXNBc1FhEVERY1FjUXEBUABjeTlRY1FTcTNxQTFhETExYRExMWNRc1FjUWEBYRFhAUExYREzgWEBcQFDcWNRYRFhAWNRcQFjYVNhMTFhETOBQ3FBMWAAY0lpMWNRY1FzQXEBQSFxETExYQFDgTNxc1FhAXEBYRFhAWERY1FhAWERY1FjUVEhYRFTYVERY1FzQXERMTFjUWNRcPFwANBQAAAAAAAA=='
        command_off: 'JgBGAJaSFjUXNRY1FhETExYRExMWERU2FDcUNxQTFhETExYRExMWERMTFhEUNxQ3FBMVEhM3FTcXNRY1FhETExY1FzUWERMADQUAAA=='
      receiver_onkyo:
        friendly_name: "Onkyo Receiver"
        command_on: 'JgBgAAABHJETExM2FRMTExM3ExMTNxM2FDUTFRM2EzYTFRM2EzYVExMTExQSNxMUExQTExMUFBMTNhM3ExQTNxM2EzYTNxM2EwAEywABHkgVAAvXAAEeSRQAC9gAAR5IEwANBQAAAAAAAAAA=='
        command_off: 'JgBgAAABHJEUEhQ1FRITExU1FBIVNRM2ExMUExM2FTUTExU0EzcVERU1EzYUNhQSFBIUExU0FRITExMUExMTNhM3FDUVEhM2EwAE7gABHUkTAAvZAAEdSRUAC9gAARxKEgANBQAAAAAAAAAA=='
      onkyo_pc:
        friendly_name: "Onkyo Computer"
        command_on: 'JgBgAAABJZMTEhI3ExISEhM3EhITNxI3EjcTEhM2EzcSEhM2EzcSEhMSEhMSNxM2EzcTERMSEjcUNRQ2EhITEhMSEjcSNxMSEgAE8gABJUsSAAw+AAElShMADD4AASVKEwANBQAAAAAAAAAA=='
      onkyo_game:
        friendly_name: "Onkyo Chromecast"
        command_on: 'JgBgAAABJpITEhM2ExITERQ1FBEUNRQ2EzYUERM2EzYUERM2FDYTERQ1FBEUNRQ2ExEUERMSExEUERM2FBETEhM2EzYUNRQ2EwAE8QABJkkUAAw9AAEmSRQADDwAASZKEwANBQAAAAAAAAAA'

customize.yaml:

script.watch_humax:
  google_assistant: true
switch.tv_samsung:
  google_assistant: true
switch.receiver_onkyo:
  google_assistant: true
switch.onkyo_pc:
  google_assistant: true
  google_assistant_name: "Onkyo PC"
switch.onkyo_game:
  google_assistant: true
  google_assistant_name: "Onkyo Chromecast"
switch.onkyo_dvd:
  google_assistant: true
  google_assistant_name: "Onkyo DVD"
switch.onkyo_cblsat:
  google_assistant: true
  google_assistant_name: "Onkyo Humax"
switch.onkyo_fm:
  google_assistant: true
  google_assistant_name: "Onkyo FM"
switch.onkyo_am:
  google_assistant: true
  google_assistant_name: "Onkyo AM"
switch.onkyo_net:
  google_assistant: true
  google_assistant_name: "Onkyo Net"
'''

The IFTTT applet gives verbal confirmation that it's run, but HA does not respond, and nothing gets added to the HA log.

Any idea what I've done wrong?

I think this is related to your other script problem with GA and I just had the thought that you should check the “States” page (in the left hand menu, at the bottom, icon that looks like < >). Scroll down until you alphabetically come to “switch” and see what entity_id’s HA is giving your Broadlink switches. I suspect the reason that both your script and IFTTT aren’t working is that you are calling the wrong entity_id.

Hmm…that’s strange…the entity names on the States page don’t reflect those in configuration.yaml, even though I stopped and started the HA server. Does HA somehow remember previous entity names? This particular problem has been resolved by changing the entity_id to the one of the States page (thanks!).

…But inevitably I now have another problem with a parallel IFTTT applet which is casting a Blue Iris camera stream to my Chromecast. This was working fine earlier, but is now casting a blank feed (even though the camera stream URL works fine from a web browser). I notice these errors in the HA log from when I last tried to execute it. Is there an issue with HA maintaining a connection to Chromecasts?

AttributeError: 'NoneType' object has no attribute 'get_extra_info'
2018-01-09 19:30:01 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/tasks.py", line 241, in _step
    result = coro.throw(exc)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1031, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/media_player/__init__.py", line 408, in async_service_handler
    yield from getattr(player, method['method'])(**params)
  File "/usr/lib/python3.5/asyncio/futures.py", line 379, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 297, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 292, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/media_player/cast.py", line 317, in play_media
    self.cast.media_controller.play_media(media_id, media_type)
  File "/srv/homeassistant/lib/python3.5/site-packages/pychromecast/controllers/media.py", line 466, in play_media
    callback_function=app_launched_callback)
  File "/srv/homeassistant/lib/python3.5/site-packages/pychromecast/socket_client.py", line 806, in launch_app
    self.update_status(lambda response:
  File "/srv/homeassistant/lib/python3.5/site-packages/pychromecast/socket_client.py", line 797, in update_status
    callback_function=callback_function_param)
  File "/srv/homeassistant/lib/python3.5/site-packages/pychromecast/controllers/__init__.py", line 84, in send_message
    self.namespace, data, inc_session_id, callback_function)
  File "/srv/homeassistant/lib/python3.5/site-packages/pychromecast/socket_client.py", line 603, in send_platform_message
    inc_session_id, callback_function_param)
  File "/srv/homeassistant/lib/python3.5/site-packages/pychromecast/socket_client.py", line 597, in send_message
    raise NotConnected("Chromecast is connecting...")
pychromecast.error.NotConnected: Chromecast is connecting...

So I decided to take IFTTT out of the equation, and use a HA script to cast the video stream to my Chromecast instead. The 2nd action in the script executes fine - i.e. switching the receiver to the Chromecast input, but the first action doesn’t start the camera stream playing on the Chromecast. The Chromecast displays a big blue Chromecast logo (common behaviour for when a device is trying to connect to it), but the video stream does not start. If I copy the same stream URL into a Firefox browser it starts streaming video immediately.

The video stream is hosted on a Blue Iris server. My first thought was that it was an authentication issue, but authentication is disable for LAN access in Blue Iris (and I don’t need to login to view the stream on Firefox).

Nothing shows up in the HA log when I try to run the script. I’ve cross-checked the entity_id for the Chromecast with the States page of the HA console (media_player.lounge) and it’s correct.

The script is here:

watch_camera:
    alias: Watch Camera
    sequence:
      - service: media_player.play_media
        data:
          entity_id: media_player.lounge
          media_content_id: media_player.http://192.168.1.4:81/mjpg/dining
          media_content_type: image/jpg
      - service: switch.turn_on
        data:
          entity_id: switch.onkyo_chromecast

Any idea why the video stream isn’t starting on the Chromecast?