All Projects → myhomeiot → DahuaVTO

myhomeiot / DahuaVTO

Licence: GPL-3.0 license
Control Dahua VTO/VTH devices from Home Assistant

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to DahuaVTO

ha-birthdays
Birthday integration for HomeAssistant
Stars: ✭ 14 (-85.71%)
Mutual labels:  integration, homeassistant
Pyscript
Pyscript adds rich Python scripting to HASS
Stars: ✭ 219 (+123.47%)
Mutual labels:  integration, homeassistant
home assistant omnik solar
Home Assistant Omnik Solar sensor component
Stars: ✭ 15 (-84.69%)
Mutual labels:  integration, homeassistant
panasonic smart app
Panasonic Smart App integration for Home Assistant.
Stars: ✭ 22 (-77.55%)
Mutual labels:  integration, homeassistant
Tuya-v2-Supported-Devices
A collection of all of the known working Tuya v2 Devices
Stars: ✭ 30 (-69.39%)
Mutual labels:  integration, homeassistant
ha-zoom-automation
Custom Home Assistant component for Zoom. Tracks when you are connected to a Zoom call by default but may allow you to track more.
Stars: ✭ 47 (-52.04%)
Mutual labels:  integration, homeassistant
ha-eskom-loadshedding
Fetches loadshedding data from Eskom
Stars: ✭ 48 (-51.02%)
Mutual labels:  integration, homeassistant
lennoxs30
Home Assistant Lennox S30 / E30 / M30 integration
Stars: ✭ 31 (-68.37%)
Mutual labels:  integration, homeassistant
visonic
Visonic Custom Component for integration with Home Assistant
Stars: ✭ 57 (-41.84%)
Mutual labels:  integration, homeassistant
container
Custom containers for various usecases
Stars: ✭ 12 (-87.76%)
Mutual labels:  integration, homeassistant
Audi connect ha
Adds an audi connect integration to home assistant
Stars: ✭ 63 (-35.71%)
Mutual labels:  integration, homeassistant
Onlyoffice Owncloud
The app which enables the users to edit office documents from ownCloud/Nextcloud using ONLYOFFICE Document Server, allows multiple users to collaborate in real time and to save back those changes to ownCloud/Nextcloud
Stars: ✭ 237 (+141.84%)
Mutual labels:  integration
Smudge
Control the Spotify app from within Emacs.
Stars: ✭ 186 (+89.8%)
Mutual labels:  integration
Metl
Metl is a simple, web-based integration platform that allows for several different styles of data integration including messaging, file based Extract/Transform/Load (ETL), and remote procedure invocation via Web Services. Read more at www.jumpmind.com/products/metl/overview
Stars: ✭ 185 (+88.78%)
Mutual labels:  integration
Val
VirtualDOM abstraction layer - give yourself better integration and full control over the DOM with any virtual DOM library that uses a Hyperscript-like API such as React and Preact.
Stars: ✭ 181 (+84.69%)
Mutual labels:  integration
nexus-platform-plugin
Nexus Platform Plugin for Jenkins
Stars: ✭ 25 (-74.49%)
Mutual labels:  integration
Camel Cookbook Examples
Example source code for Apache Camel Developer's Cookbook
Stars: ✭ 232 (+136.73%)
Mutual labels:  integration
Hooka
😎 A webhook server with zero coding
Stars: ✭ 180 (+83.67%)
Mutual labels:  integration
Nextcloud Drawio
Draw.io intergration app
Stars: ✭ 177 (+80.61%)
Mutual labels:  integration
trello-habitica
Keep in sync your Trello cards with Habitica
Stars: ✭ 32 (-67.35%)
Mutual labels:  integration

hacs_badge hacs_badge Validate

A Home Assistant custom integration for control Dahua VTO/VTH devices.

Please ⭐️ this repo if you find it useful.

If you have questions or problems with this integration you can check this thread. If your model working but it's not in the supported list please share this information with community in the thread above.

The following models are reported as working:

Folowing models should work:

Following models may work:

  • VTO12xx, VTO4202, VTO6xxx, VTO6221
  • VTH15xx, VTH16xx, VTH2201, VTH2421, VTH5222, VTH5341, VTH5421
  • VTS5240

Installation:

The easiest way to install the integration is with HACS. First install HACS if you don't have it yet. After installation you can find this integration in the HACS store under integrations.

Alternatively, you can install it manually. Just copy the dahua_vto folder and all of its contents into your Home Assistant's custom_components folder. This is often located inside of your /config folder. If you are running Hass.io, use SAMBA to copy the folder over. If you are running Home Assistant Supervised, the custom_components folder might be located at /usr/share/hassio/homeassistant. It is possible that your custom_components folder does not exist. If that is the case, create the folder in the proper location, and then copy the dahua_vto folder and all of its contents inside the newly created custom_components folder. The disadvantage of a manual installation is that you won't be notified about updates.

Configuration Examples

Add the following to your configuration.yaml file:

sensor:
  - platform: dahua_vto
    name: NAME_HERE
    host: HOST_HERE
    timeout: TIMEOUT_HERE optional, default 10
    port: PORT_HERE optional, default 5000
    username: USERNAME_HERE_OR_secrets.yaml
    password: PASSWORD_HERE_OR_secrets.yaml
    scan_interval: SCAN_INTERVAL_HERE optional, default 60

Example

  - platform: dahua_vto
    name: Dahua VTO
    host: 192.168.1.2
    username: admin
    password: password
    scan_interval: 5

Lock example with call to open door service

Note: If you change a name of integration name: Dahua VTO, you should change entity_id: sensor.dahua_vto in example to your sensor name which you can found in Home Assistant Developer Tools.

timer:
  door_lock:
    name: Door Lock
    icon: mdi:timer

lock:
  - platform: template
    name: Door Lock
    value_template: "{{ not is_state('timer.door_lock', 'active') }}"
    optimistic: false
    lock:
    unlock:
      - service: dahua_vto.open_door
        data_template:
          entity_id: sensor.dahua_vto
          channel: 1
          short_number: HA

Automation example with doorbell ring and unlock events

- alias: Dahua VTO All Events
  mode: queued
  trigger:
    - platform: event
      event_type: dahua_vto
  action:
    - service: persistent_notification.create
      data:
        title: "{{ trigger.event.data.Code if trigger.event.data.Code is defined else 'Unknown Code' }}"
        message: "{{ trigger.event.data }}"

- alias: Dahua VTO Command Result
  mode: queued
  trigger:
    - platform: event
      event_type: dahua_vto
  condition:
    - condition: template
      value_template: "{{ trigger.event.data.method is defined }}"
  action:
    - service: persistent_notification.create
      data:
        title: "{{ trigger.event.data.method }}"
        message: "{{ trigger.event.data }}"

- alias: Dahua VTO
  mode: queued
  trigger:
    - platform: event
      event_type: dahua_vto
      event_data:
        Code: BackKeyLight
  action:
    - choose:
        - conditions: >
            {{ trigger.event.data.Data.State | int in [0, 1, 2, 5, 6] }}
          sequence:
            - service: persistent_notification.create
              data:
                title: "{{ 'Doorbell Ring' if trigger.event.data.Data.State | int in [1, 2] else 'Doorbell No Ring' }}"
                message: "{{ trigger.event.data }}"
        - conditions: >
            {{ trigger.event.data.Data.State | int == 8 }}
          sequence:
            - service: timer.start
              data:
                entity_id: timer.door_lock
                duration: 00:00:02 # VTO Unlock Period
            - service: persistent_notification.create
              data:
                title: Unlock
                message: "{{ trigger.event.data }}"
        - conditions: >
            {{ trigger.event.data.Data.State | int == 9 }}
          sequence:
            - service: persistent_notification.create
              data:
                title: Unlock failed
                message: "{{ trigger.event.data }}"
        - conditions: >
            {{ trigger.event.data.Data.State | int == 11 }}
          sequence:
            - service: persistent_notification.create
              data:
                title: Device rebooted
                message: "{{ trigger.event.data }}"
      default:
        - service: persistent_notification.create
          data:
            title: "Unknown state {{ trigger.event.data.Data.State | int }}"
            message: "{{ trigger.event.data }}"

Door status sensor example

Thanks to @mate for this example. Here you can also find door open/close events examples received from Dahua VTO.

template:
  - trigger:
      - platform: event
        event_type: dahua_vto
        event_data:
          Code: DoorStatus
    binary_sensor:
      - name: VTO Door Status
        state: "{{ trigger.event.data.Data.Status | string == 'Open' }}"
        device_class: door

Commands and Events

You can send any command using the service dahua_vto.send_command or dahua_vto.send_instance_command and receive reply as event. dahua_vto.send_instance_command sequential call to service.factory.instance, service.method with object returned by factory.instance and service.destroy, where service it's a first part of the method before .. Result of service.method returned as event. I doesn't found documentation but you can grab some commands and their parameters from Dahua-JSON-Debug-Console-v2.py

All device client.notifyEventStream and client.notifyConfigChange messages you will receive as events, information about some of them you can find here.

For most of the cases you can use BackKeyLight event State, the list of some of them you can found in table below.

Possible that in your case the State will be different and this depends from the device model.

BackKeyLight States

State Description
0 OK, No Call/Ring
1, 2 Call/Ring
4 Voice message
5 Call answered from VTH
6 Call not answered
7 VTH calling VTO
8 Unlock
9 Unlock failed
11 Device rebooted

Some command examples

service: dahua_vto.send_command
data:
  entity_id: sensor.dahua_vto
  method: system.listService

service: dahua_vto.send_command
data:
  entity_id: sensor.dahua_vto
  method: magicBox.listMethod

service: dahua_vto.send_command
data:
  entity_id: sensor.dahua_vto
  method: magicBox.reboot
  params: {delay: 60}
  tag: alert

service: dahua_vto.send_command
data:
  entity_id: sensor.dahua_vto
  method: magicBox.getBootParameter
  params: {names: ['serverip', 'ver']}

# Cancel VTO Call
service: dahua_vto.send_command
data:
  entity_id: sensor.dahua_vto
  method: console.runCmd
  params: {'command': 'hc'}
  event: false

# Clear VTH Call Records
service: dahua_vto.send_instance_command
data:
  entity_id: sensor.dahua_vth
  method: RecordUpdater.clear
  instance_params: {'name': 'VideoTalkMissedLog'}
  event: false

# Arming the VTH alarm
service: dahua_vto.send_command
data:
  entity_id: sensor.dahua_vth
  method: configManager.setConfig
  params: {'table': {'AlarmEnable': true, 'CurrentProfile': 'Outdoor'}, 'name': 'CommGlobal'}
  event: false

# Disarming the VTH alarm
service: dahua_vto.send_command
data:
  entity_id: sensor.dahua_vth
  method: configManager.setConfig
  params: {'table': {'AlarmEnable': false, 'CurrentProfile': 'AtHome'}, 'name': 'CommGlobal'}
  event: false

# Getting the VTH alarm status
service: dahua_vto.send_command
data:
  entity_id: sensor.dahua_vth
  method: configManager.getConfig
  params: {'name': 'CommGlobal'}
  event: true

Debugging

Whenever you write a bug report, it helps tremendously if you include debug logs directly (otherwise we will just ask for them and it will take longer). So please enable debug logs like this and include them in your issue:

logger:
  default: warning
  logs:
    custom_components.dahua_vto: debug

Useful Links

Thanks to:

@elad-bar @mcw0 @riogrande75

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].