Google Cast BlueIris Cameras with Home Assistant!

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 ?

The url with the ip address i can copy and paste it into chrome browser and it brings up the video stream with no issue.
The TV is on the same network as the test with the image file cast to the TV.

What are your Blue Iris authentication settings?

Blue Iris options > webserver > advanced

image

@ Erwin_Nieuwenhuis sorry i was away for a few days.

I have these settings in my Blue Iris.

Capture

@notchy that looks different from my settings, what blue Iris version do you have?

Did you try opening the stream in your browser?

Your settings say ‘secure only’, maybe this means only ssl (https) is allowed?

it is Blue Iris 3.66
I can use the url and paste it into a browser and view the video.

@notchy Sorry but I am almost out of things to try…

I am running Blue Iris 4.8.5.0, don’t know if there are any big changes about the mjpeg stream in this version.

Maybe you can try changing the authentication settings? (No connections and disable the secure only)
I think you need to restart Blue Iris for these changes (not sure).

For anyone wondering about the 20 minutes timeout, this seems to be a default chromecast setting. Because the state of the Chromecast is ‘paused’ during the mjpeg stream, it times out after 20 minutes. (to prevent screen burn in)
I have no idea yet how to change this… Or how to workaround…

Thanks for this guide sebdoan. I now have your script incorporated with an automation. Has anyone got a script that will disconnect the casting screen from the Blue Iris feed after a set time?

I’ve got it working!!!

When my doorbell (MQTT) is triggered the CCTV feed from Blue Iris is cast to my TV using this script

cctv_sony_bravia:
alias: CCTV to TV
sequence:

I then have a delay of 20 seconds in the automation and then this script runs

stop_casting_tv:
alias: Stop casting TV
sequence:

  • service: media_player.turn_off
    data_template:
    entity_id: media_player.kd_49x8309c
1 Like

Thanks for all the input in this tread, particularly from OP! Thanks!

I would suggest using static IP-adresses for your chromecasts and whitelist these in BlueIris like shown here: https://community-assets.home-assistant.io/original/3X/4/d/4df72c1232fc714f29a0f511aa7159e300ae4a1d.jpeg. More addresses are separated with a comma like ^10.0.0.2, ^10.0.0.3. This way you do not have to open up to all adresses on your network.

Hey everyone, glad to see my original post is helping everyone out there. Even though the walkthrough here uses BlueIris I want everyone to know you can also do the same using the Hassio MotionEye addon. This is fully open source.

If you want to go down this route do not use a Raspberry Pi and instead run Hassio on a Virtual Machine which is far, far more powerful. If you’re interested in migrating to a Hassio Virtual Machine look here: My migration to improve Hassio performance and increase security

Can anyone confirm if they have this working with a Vizio cast TV.

Did you have to install the Vizio component manually with Hassio?

If so can you share the steps.

@sebdoan

Thank you for this, I’ve adapted your original post to work with direct RTSP streams.

Hopefully others find this useful too

input_select:
  camera_dropdown:
    name: Cast camera
    options:
      - "Driveway"
      - "Side Passage"
      - "Garden"
      - "Living Room"
    initial: "Driveway"
    icon: mdi:camera
  cast_to_screen_dropdown:
    name: To Screen
    options:
      - "Living Room Display"
      - "Shield TV"
      - "Bedroom TV"
    initial: "Living Room Display"
    icon: mdi:cast

script:
  execute_cast_dropdown:
    alias: Cast
    sequence:
      - service: camera.play_stream
        data_template:
          entity_id: >
            {% if is_state("input_select.camera_dropdown", "Driveway") %}
              camera.driveway
            {% elif is_state("input_select.camera_dropdown", "Side Passage") %}
              camera.side_passage
            {% elif is_state("input_select.camera_dropdown", "Garden") %}
              camera.garden
            {% elif is_state("input_select.camera_dropdown", "Living Room") %}
              camera.living_room

            {% endif %}
          media_player: >
            {% if is_state("input_select.cast_to_screen_dropdown", "Living Room Display") %}
              media_player.living_room_display
            {% elif is_state("input_select.cast_to_screen_dropdown", "Shield TV") %}
              media_player.shield
            {% elif is_state("input_select.cast_to_screen_dropdown", "Bedroom TV") %}
              media_player.bedroom_tv
            {% endif %}
group:
  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
3 Likes