Google Cast BlueIris Cameras with Home Assistant!

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.

jparthum, I wanted to thank you for your awesome instructions. Everything worked!

1 Like

Great to hear, Flamez!

And thanks for the kind words. I’m glad to be able to give a little back to such a great community. :slight_smile:

10% of the time:

google: ok showing the X camera on X tv

90% of the time:

google: your nearest kitchen store is blah
google: ok streaming street videos on youtube
google: the closest living room store is blah

Before I am going to join this journey what solution is best for Google casting generic (hacked Xiaomi Xiaofang) IP cameras?

This solution or this?

No offence is meant to the author of course. :sweat_smile:

I’m trying to use the Node-red Cast node to send a BI stream to my Google Home Hub.

Media Url: http://192.168.1.7:8029/h264/naturecam/temp.h264 (works fine in VLC)
Media Type: video/H264

I get, “Not able to load media:Load failed Not able to load the media.”

Sending TTS this way works, so I am reaching it.
What am I doin’ wrong?

EDIT: This works (from HA):

http://192.168.1.9:8029/h264/naturecam/temp.m3u8
video/mp4