Google Cast BlueIris Cameras with Home Assistant!

You can’t just pass the credentials in the cgi-bin link? The amcrest docs suggest you can pass your credentials directly in the link as parameters.

I’ve tried passing the user and password values with various combinations and nothing seems to work.

It also looks like ppl have been trying to do this for years but every solutions seems to have a middleman such as blueiris, docker or some other server in between. This suggests to me that you’ll need to remove authentication for any solution to work.

Try enabling anonymous user but make sure to enable for LAN only

Do you mind sharing how you got it all working? Specifically the “hey google, show me the front door”? I can see my cameras, and I can also cast them with home assistant (Thanks to the OP). But getting google to see the individual cameras and setting up whatever routine is needed is what I’m missing

Follow the instructions on this page to have items in home assistant visible to the Google Assistant https://www.home-assistant.io/components/google_assistant/

I did, but they never seemed to appear. Once I followed this I was able to get it working. Needed to expose a script to tell it what to do I guess.

Ok Google: Who is at the front door!

Using a script is the easiest approach, but you could also use any of the other domains available to the Google Assistant https://www.home-assistant.io/components/google_assistant/#available-domains

I had tried exposing the domains listed, and it never seemed to pick the cameras up, or my scripts for that matter.

  exposed_domains:
      - switch
      - light
      - group
      - cover
      - vacuum
      - media_player
      - script

unless you are saying to also expose the actual camera as well.

entity_config:
switch.kitchen:
  name: CUSTOM_NAME_FOR_GOOGLE_ASSISTANT
  aliases:
    - BRIGHT_LIGHTS
    - ENTRY_LIGHTS
light.living_room:
  expose: false
  room: LIVING_ROOM

which I did not try

You mentioned that you got it working as a script to the Google Assistant. Have I misunderstood?

Correct it is working. Thank you for the assistance!!

I dont have the config files any longer as my SD Card died and I have not picked up a new one, however you if memory serves me correctly you need either have a Home assistant cloud account or the work around (Ill see if i can find it) so that you can link your HA to your Google Services. Once you have that linked and you have everything else working in HA, I went to IFTTT and created a web request that was duckdns address.

Example:
http://yoururl.duckdns.org:8123/api/services/script/SCRIPTNAME?api_password=YOURPASSWORD

Method: Post
Content Type: text/plain

hopefully that makes sense.

Many thanks for the excellent instructions @sebdoan, I was able to get this set up with hardly any issues. So, regarding using Google Assistant, I have my GA linked to HA, and working great. The switch that is exposed to HA is titled “Press to execute”, which really doesn’t seem like it would work anyway. I just can’t seem to figure out how to ask for a certain camera to be displayed on a certain home. Do I need a separate script for each camera feed? If so, do I also need to specify which device to display it on?

I have followed the example above and changed up the logic for the names of my cameras and ip address. I can take the media content and paste it into my browser and view my live camera feeds. I have no errors when i check configuration.

My issue is the input option does not come up on my
HA overview section.

Here is my code but i put them in their respective .yaml files

“Configuration.yaml” i put in the “input select:”

input_select:
  camera_dropdown:
    name: Cast camera
    options:
      - CAM01
      - CAM02
      - CAM03
      - Cycle Cameras
      - All Cameras
    initial: All Cameras
    icon: mdi:camera
  cast_to_screen_dropdown:
    name: To Screen
    options:
      - Google Smart Display
      - Chromecast
      - Android TV
    initial: Google Smart Display
    icon: mdi:cast

For the “Script.yaml” file i put the logic

  execute_cast_dropdown:
    alias: Press to execute
    sequence:
      - service: media_player.play_media
        data_template:
          entity_id: >
            {% if is_state("input_select.cast_to_screen_dropdown", "Google Smart Display") %}
              media_player.great_room_display
            {% elif is_state("input_select.cast_to_screen_dropdown", "Chromecast") %}
              media_player.great_room_display 
            {% elif is_state("input_select.cast_to_screen_dropdown", "Android TV") %}
              media_player.great_room_display
            {% endif %}
          media_content_id: >
            {% if is_state("input_select.camera_dropdown", "CAM01") %}
              http://192.168.1.133:8085/mjpg/CAM01/video.mjpg
            {% elif is_state("input_select.camera_dropdown", "CAM02") %}
              http://192.168.1.133:8085/mjpg/CAM02/video.mjpg
            {% elif is_state("input_select.camera_dropdown", "CAM03") %}
              http://192.168.1.133:8085/mjpg/CAM03/video.mjpg
            {% elif is_state("input_select.camera_dropdown", "Cycle Cameras") %}
              http://192.168.1.133:8085/mjpg/@index?/video.mjpg
            {% elif is_state("input_select.camera_dropdown", "All Cameras") %}
              http://192.168.1.133:8085/mjpg/index?/video.mjpg
            {% endif %}
          media_content_type: 'image/jpg'

For the “group.yaml” I put the following logic.

  Cast_Cameras_Group:
    name: Cast Camera to Screen
    view: no
    entities:
     - input_select.camera_dropdown
     - input_select.cast_to_screen_dropdown
     - script.execute_cast_dropdown

Can anyone tell me why i am not getting the group displayed on the overview of HA 0.86.4

NVM I tested just the script and confirmed that I can cast to the display

So I simplified the code and I am just running it from the dev tools as a service and

I put this in the JSON part

{ "entity_id" : "media_player.great_room_display", "media_content_id": "http://192.168.1.133:8085/mjpg/CAM02/video.mjpg", "media_content_type":"image/jpg"}

when i look at the TV it is a black screen with the “chromecast” symbol on it. It is a Vizio TV that has chromecast built in

I see this in the log. I am not sure where the IP address is stating “Cannot connect to host 192.168.1.208:8060” when no device has that IP address when i look at connected devices on my router. Does anyone have an idea what the issue is?

Log Details (ERROR)
Thu Feb 07 2019 08:39:22 GMT-0500 (Eastern Standard Time)

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/aiohttp/connector.py", line 924, in _wrap_create_connection
    await self._loop.create_connection(*args, **kwargs))
  File "uvloop/loop.pyx", line 1879, in create_connection
  File "uvloop/loop.pyx", line 1858, in uvloop.loop.Loop.create_connection
OSError: [Errno 113] Host is unreachable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/usr/local/lib/python3.6/site-packages/aiohttp/web_app.py", line 458, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.6/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/http/static.py", line 66, in staticresource_middleware
    return await handler(request)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/http/real_ip.py", line 34, in real_ip_middleware
    return await handler(request)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/http/ban.py", line 67, in ban_middleware
    return await handler(request)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/http/auth.py", line 99, in auth_middleware
    return await handler(request)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/http/view.py", line 118, in handle
    result = await result
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 857, in get
    data, content_type = await player.async_get_media_image()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 388, in async_get_media_image
    return await _async_fetch_image(self.hass, url)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 815, in _async_fetch_image
    response = await websession.get(url)
  File "/usr/local/lib/python3.6/site-packages/aiohttp/client.py", line 476, in _request
    timeout=real_timeout
  File "/usr/local/lib/python3.6/site-packages/aiohttp/connector.py", line 522, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/usr/local/lib/python3.6/site-packages/aiohttp/connector.py", line 854, in _create_connection
    req, traces, timeout)
  File "/usr/local/lib/python3.6/site-packages/aiohttp/connector.py", line 992, in _create_direct_connection
    raise last_exc
  File "/usr/local/lib/python3.6/site-packages/aiohttp/connector.py", line 974, in _create_direct_connection
    req=req, client_error=client_error)
  File "/usr/local/lib/python3.6/site-packages/aiohttp/connector.py", line 931, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 192.168.1.208:8060 ssl:None [Host is unreachable]

I am trying to get BlueIris on a monitoring TV using this code and a Chromecast.
I have it setup to automatically start when the chromecast is available, and this works well.

But after 20 minutes, the stream just stops. I have changed the automation to restart the stream, but it isn’t a great solution.

Is there just something wrong in my setup, or does the stream default stop after 20 minutes?

@notchy Can you control your chromecast from HA when casting something else? (for example youtube from your phone?)

I am not able to get the video to stream. I get the chromecast image attached in the pic on my tv.

Can you share your code with me?

@notchy I just used the code from the first post, and deleted the dropdown options from it.

Can you try calling the following service:
image

With the following code in the JSON part:

{ 
"entity_id" : "media_player.great_room_display", 
"media_content_id": "https://home-assistant.io/images/cast/splash.png", 
"media_content_type":"image/jpg"
}

@ Erwin_Nieuwenhuis so that code to cast the Home Assistant image worked on my TV. So what could be the problem why I can not stream my cameras?

1 Like

@notchy I have no idea… Now we now you can cast something to your TV. Next would be trying to cast a mjpeg file?

If you open http://192.168.1.133:8085/mjpg/CAM02/video.mjpg on your pc, do you get the mjpeg stream?

How is your network configured? Does the TV also have access to http://192.168.1.133:8085/mjpg/CAM02/video.mjpg ?