Hikvision frontgate doorbell enhancement

I completed something which took me a while.
Not because it was really hard, but because I couldn’t figure out how to complete it.
I want to share it with you because I think it’s cool. :slight_smile:

So I’ve wrote at a previous post about my Hikvision doorbell automation. Have a look here.

With the latest HA updates and a chromecast I managed to have a live stream at TV when someone presses the front gate doorbell! How cool is that! Here is the code for it

alias: Hikvision Doorbell notifier at TV (front gate)
description: show camera feed at TV is is ON
trigger:
  - entity_id: sensor.hikvision_doorbell_status_main_entrance
    platform: state
    to: ring
condition: []
action:
  - service: scene.create
    data:
      scene_id: save_source_before_doorbell_is_pressed
      snapshot_entities: media_player.sofita_tv
  - if:
      - condition: state
        entity_id: switch.attictv_tplink
        state: "on"
    then:
      - data:
          message: Someone is at the security gate!
        service: notify.sofita_tv
      - service: media_player.select_source
        data:
          source: HDMI3
        target:
          entity_id: media_player.sofita_tv
      - delay:
          hours: 0
          minutes: 0
          seconds: 5
          milliseconds: 0
      - service: media_player.play_media
        target:
          entity_id: media_player.chromecast
        data:
          media_content_id: media-source://camera/camera.front_gate_live_stream
          media_content_type: application/vnd.apple.mpegurl
        metadata:
          title: Front Gate live stream
          thumbnail: /api/camera_proxy/camera.front_gate_live_stream
          media_class: video
          children_media_class: null
          navigateIds:
            - {}
            - media_content_type: app
              media_content_id: media-source://camera
      - delay:
          hours: 0
          minutes: 0
          seconds: 20
          milliseconds: 0
      - service: scene.turn_on
        data: {}
        target:
          entity_id: scene.save_source_before_doorbell_is_pressed
mode: single
max_exceeded: silent

What I really love on the above automation is that using the scene create I actually save the channel I was watching and as soon as HA switches to chromecast source it knows on which channel to return!!! I just love it!!!

But still something was missing
To open the door, I had to stand up from my comfortable sofa, walk towards the Hikvision indoor station (or my tablet) to open the door.
(I still haven’t remove the hikvision indoor stations by the way).

It wasn’t practical and I was thinking that it is not possible to have so many automation and not to be able to open the door from the sofa (with TV’s remote control for example!).

Well this was not possible until today! :superhero:
Am using the simple LG remote control (not the magic or any other remote control devices like Harmony etc etc).

I had a good look at media_players state attributes

I noticed that when you press MUTE button the state changes almost instantly.
Which is something that I wanted.

So I came up with the following automation:

alias: Hikvision Doorbell unlock door (front gate)
description: >-
  Unlock door with remote control of TV by pressing MUTE button (works only on
  helper security_gate_button_is_pressed is ON)
trigger:
  - platform: state
    entity_id:
      - media_player.sofita_tv
    attribute: is_volume_muted
    to: true
    from: false
condition:
action:
  - service: script.open_front_door
    data: {}
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - service: webostv.button
    data:
      entity_id: media_player.sofita_tv
      button: MUTE
mode: single

Bingo!!
This opens the door each time I press the MUTE button of TV’s remote control!.
But then I thought that each time we press the MUTE button the door will open which is not something we wanted. :slight_smile:

So I added the following condition using a helper I made for this automation.

condition:
  - condition: state
    entity_id: input_boolean.security_gate_button_is_pressed
    state: "on"

It works so smoothly!! I love it and I am so excited!
Hope you like it too!! Tell me your thoughts and what you think!

PS: Because English is not my native language please feel free to correct any mistakes

2 Likes

great, will try to implement in the weekend. Thanks

any progress? Please feel free to share what you have done …so far

Postponed for next weekend