Google Cast BlueIris Cameras with Home Assistant!

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

I’m not sure if you have the same Vizio cast as me (depends on the model I think), but I went down the same route in trying to cast to my Vizio TV (VIZIO 55 Inch LED Smart TV D55-D2 HDTV), but the implementation on my TV of Chromecast is not the same implementation as a Chromecast (either the stick or in a TV that runs Android TV. Therefore in my case you can’t cast as you would normally. The strange thing is I can cast from an Android device. YMMV, but I couldn’t get it working.

Hi, just got a lenovo smart display and looking to do similar setup where motion detected to display on the smartdisplay. How you tying the trigger of motion? Did you use similar setup as your OP? Thanks.

Create a script to project the video, then buy a door sensor or motion detector to trigger the camera script.

Sorry should of been more clear, using blue iris as well. Are you using mqtt to do that? Looking to setup when alerted on BI to cast to a display. Just haven’t been able to find a right setup or config.

If you are willing to share that config. Also with your code above I get everything but the “Execute button” what am I missing? not getting any config errors. Thanks.

Seems you’re pretty new to Home Assistant. I recommend you get the basics of understanding how to add devices to home assistant first, then learning about how scripts works and then to automations. The combination of these 3 things will get you what you need.

You’re essentially learning to code and its not as straight forward as your request assumes.

Hello Everyone out there reading this thread. After the release of Home Assistant v0.91, there’s a much better way to do this with native integration to the Google Assistant via Blue Iris.

Ingredient’s needed:

  1. Google Assistant Component: https://www.home-assistant.io/components/google_assistant/
  2. Home Assistant Stream: https://www.home-assistant.io/components/stream/
  3. Setup your Camera with Supported Streams: Stream Component: Confirmed Cameras and Configurations (note: it uses the “image” and “h264” streams vs the “mjpg” one)

If you do the above and expose your “camera.device” to the Google Assistant you’ll see it exposed in the Home App as a natively integrated camera. What this means if you have multiple smart displays in your home you can execute the following commands:

  1. OK Google, show me the baby camera” and it will know which device you’re interacting with and show it on that display.
  2. OK Google, show the baby camera on the TV Chromecast” and it should be smart enough to execute this action.
3 Likes

I tried the stream component but wasn’t happy with the delay. I think right now your method is still superior. :slight_smile:

2 Likes

To get motion triggers into HA you can do the following (replace text in ALL CAPS with your specific settings):

  1. You’ll need to have api_password: enabled since BI doesn’t support auth yet (AFAIK)…

configuration.yaml:

homeassistant:
  auth_providers:
    - type: legacy_api_password
      api_password: API_PASSWORD

(note: The remaining sections need to be duplicated for each camera.)

  1. You’ll need to create binary_sensor(s) for BI to manipulate:

binary_sensor:

- platform: template
  sensors:
    motion_CAMERA:
      value_template: >
        {% if states.binary_sensor.motion_CAMERA.state %}
          {% if is_state('binary_sensor.motion_CAMERA', 'on') %}
            on
          {% elif is_state('binary_sensor.motion_CAMERA', 'off') %}
            off
          {% else %}
            {{ states('binary_sensor.motion_CAMERA') }}
          {% endif %}
        {% else %}
          off
        {% endif %}
  1. For your camera(s) in BI:
  • Go to “Properties” > “Alerts” and in the “Actions” section place a check :ballot_box_with_check: in the box next to “Post to a web address or MQTT server”
  • Click “Configure”, choose http:// or https:// for both fields according to your HA configuration
  • Check :ballot_box_with_check: “Alert again when trigger is reset”
  • In both fields next to http:// (or https://) enter:

HA_IP_ADDRESS:8123/api/states/binary_sensor.motion_&CAM?api_password=API_PASSWORD
(note: BI will automatically replace “&CAM” with the camera’s “Short name”, which can be found in “Camera Properties…” under the “General” tab. This name must correspond to the “_CAMERA” name(s) configured in the binary_sensor: section [which are also referenced in the automation: section].)

  • In the first Post/payload: field enter {"state":"on"}.
  • In the second Post/payload: field enter {"state":"off"}.

eg:

  1. And lastly, create automations to start / stop Casting:

automation:

- alias: CAMERA Start Casting
  initial_state: true
  trigger:
    - platform: state
      entity_id: binary_sensor.motion_CAMERA
      to: "on"
  action:
    - service: media_player.play_media
      data_template:
        entity_id: media_player.CAST_DEVICE
        media_content_id: "http://BI_IP_ADDRESS:PORT/mjpg/CAMERA"
        media_content_type: "image/jpg"

- alias: CAMERA Stop Casting
  initial_state: true
  trigger:
    - platform: state
      entity_id: binary_sensor.motion_CAMERA
      to: "off"
  action:
    - service: media_player.media_stop
      entity_id: media_player.CAST_DEVICE
4 Likes

Thank you for the detailed write up helps a lot, just having one issue with the automation part that it’s not liking. Not sure if I missed something? This is the error given.

" Invalid config for [automation]: [media_content_id] is an invalid option for [automation]. Check: automation->action->0->media_content_id. (See /config/configuration.yaml, line 72)."

1 Like

Sorry, I omitted the data_template: line. :pensive:

Editing to correct…

1 Like

Working great, thanks for the assistance. :+1:t4:

1 Like

Great to hear!

I pieced this together by pruning some more complex configurations I had implemented (before moving them to Node-Red) so I haven’t tested these specific configurations. Did you implement every step that you can confirm as working?

yes used all the steps but did have to modify the automaton action part didn’t seem to work for me but the following change did. Thanks again.

action:
- service: media_player.play_media
data_template:
entity_id: media_player.CAST_DEVICE
media_content_id: “http://BI_IP_ADDRESS:PORT/mjpg/CAMERA”
media_content_type: “image/jpg”

1 Like

OK so service_template: didn’t work. I was using separate start / stop automations for an unrelated reason but I vaguely remember having trouble at some point with syntax variations between how play_media and media_stop are called. :thinking:

Thanks for reporting back. I’ll edit the post to include separate start / stop automations.

I wonder if you can do this directly with the dahua camera without using blue iris.