Cast Camera when Doorbell Pressed

I’ve got a Ubiquiti G4 Doorbell and wanted to cast its video to a display every time it gets pressed. Below is the automation but it doesn’t seem to trigger. I figured it was a simple automation and just cannot wrap my head around what could possibly be wrong.

While in the UI, editing the automation, when I click “Run Action”, it will cast the camera stream correctly. After the doorbell is pressed (there are no errors in the log), and when I check the entity history it shows correctly each time it is activated (see screenshot). After pressing the doorbell, there are no errors in the log.

What am I missing?

doorbell

- id: '1615989694017'
  alias: Someone's at the Door
  description: Cast Doorbell Video to Smart Display
  trigger:
  - platform: state
    entity_id: binary_sensor.g4doorbell_porch
    to: 'on'
  condition: []
  action:
  - service: camera.play_stream
    data:
      media_player: media_player.lenovo_smart_display
    target:
      entity_id: camera.g4doorbell_porch
  mode: single

What does the state become when the doorbell is pressed? It may not be ‘on’, it may be ‘occupied’. Watch the states tab in dev-tools, or the bit you screenshotted as someone presses the bell.

My motion sensors come up as “Detected” when they see something.

So in the screenshot above, in between the “clear” states is a tiny sliver which is identified as the “detected” state, just as you mentioned. However, I didn’t think you need to indicate the state to be “detected” or “clear” in the code. Per ‘binary sensor’ page, on and off have specific meanings for different device types.

You are probably right (I thought about it more after posting!).

Take a look in states in dev tools, just to humour me.

This is the first time I’ve ever gone into this part of the app … lol

I’m assuming this is what you are asking?

doorbellState

Since it is currently in the ‘off’ state, that means on/off should work?

Yes it is, well done :slight_smile: To go the whole hog, press the doorbell while looking at that panel.

Also, try taking the quotes out of ‘on’ in the automation trigger.

Alright, I’ll give that a go in the morning and report back.
The family will not appreciate the doorbell ringing at this hour :smiley:

It seems awfully strange, but putting in the quotations seemed to have fixed it … thanks for that suggestion. It’s with using on/off as opposed to clear/detected.

Still on this topic of casting the camera stream to a media player, what occurs right now is that it streams continuously until told otherwise. How would I go about “disconnecting” the cast after a certain amount of time? Would it have to be done via another automation? or is there something that can be done within this one i’m fiddling around with?

I think you can put a delay in the action, and after the delay turn it off.