Dahua VTO custom integration

Great! This integration work same way as DahuaVTO2MQTT just without MQTT and extra docker container. Many users which already has MQTT infrastructure prefer DahuaVTO2MQTT.

You are the best!!
It works now.
I had no clue I had the wrong port, I probably overridden the default from copy-paste of a random example somewhere.
Thank you

Hey guys, lately i have started noticing some wierd behaviour with my VTO2220
when i open the door, i hear the click sound but the strike does not unlock.
i thought maybe the vto or strike is faulty, but when i tried from the dmss app, it worked fine. then i switched back to home assistant and it worked fine once, only to go back to same issue.

DHI-ASI6213S-PW working with integration Dahua VTO

Having an issue since recent update.. completely broke the unlock functionality.. getting the following error:

template:
  - lock:
    - name: closing gate
      optimistic: false
      state: "{{ not is_state('timer.door_lock', 'active') }}"
      lock: #is optional but without it ha throw an error
      - data_template:
          entity_id: sensor.dahua_vto_gate
          channel: 1
          short_number: HA
        action: dahua_vto.open_door
      unlock: #unlock - opens gate lock
      - data_template:
          entity_id: sensor.dahua_vto_gate
          channel: 1
          short_number: HA
        action: dahua_vto.open_door

I have Dahua VTO and this warning hagns my HA completily:

04:55:47 WARNING - Updating dahua_vto sensor took longer than the scheduled update interval 0:00:05
04:55:47 WARNING - Update of sensor.dahua_vto is taking over 10 seconds

@cheusovalexandr I am running the same and have a couple of things working; the lock sensor and the unlock. Did you get anything else working for it?

Question, Has anyone ever tried using an RS-485 extension model? Curious to know if the extra ports gets exposed.

I’m planning to connect a DEE111R to my VTO2211G-P-S2.

I have a DEE1010B connected to my VTO3211D-P2-S4. I just send a command on channel 2 and it works fine (connected as clean contact to my driveway gate).

Yes, below I present the automation for person identification, the similarity percentage, and the call notification.

- alias: dahua_vto
  initial_state: true
  id: dahua_vto
  trace:
    stored_traces: 10
  mode: queued
  triggers:
    - trigger: event
      event_type: dahua_vto
      event_data:
        Code: "AccessControl"
    - trigger: event
      event_type: dahua_vto
      event_data:
        Code: "Invite"
    - trigger: event
      event_type:
        - telegram_callback
  actions:
    - variables:
        vars_dahua_vto_cardno: |
          {% set vars_dahua_vto_cardno = {
            'E465724A': 'some_user_1',
            'E4BA6D4A': 'some_user_2',
            '14346F4A': 'some_user_3'
            }
          %}
          {{ vars_dahua_vto_cardno }}
        vars_dahua_vto_camera: |
          {% set vars_dahua_vto_camera = {
            'camera_entity': 'camera.dahua_terminal_main',
            'photo_path': '/config/www/camera/dahua_terminal_main.png'
            }
          %}
          {{ vars_dahua_vto_camera }}
    - choose:
        - conditions:
            - "{{ trigger.event.data.entity_id == 'sensor.dahua_terminal' }}"
            - "{{ trigger.event.data.Code == 'AccessControl' }}"
            - "{{ trigger.event.data.Data.CardNo in vars_dahua_vto_cardno.keys()|list }}"
          sequence:
            - action: telegram_bot.send_message
              data:
                chat_id:
                  - !secret telegram_group_id
                message_thread_id: some_message_thread_id
                parse_mode: html
                message: |
                  {%- if 'FaceIndex' in trigger.event.data.Data -%}
                    {{"\U0001F464"}} Пользователь {{ vars_dahua_vto_cardno[trigger.event.data.Data.CardNo] }} открыл калитку по лицу, сходство {{ trigger.event.data.Data.Similarity }}%
                  {% elif 'FaceIndex' not in trigger.event.data.Data -%}
                    {{"\U0001FAAA"}} Пользователь {{ vars_dahua_vto_cardno[trigger.event.data.Data.CardNo] }} открыл калитку по ключу
                  {% endif %}
        - conditions:
            - "{{ trigger.event.data.entity_id == 'sensor.dahua_terminal' }}"
            - "{{ trigger.event.data.Code == 'Invite' }}"
            - condition: or
              conditions:
                - "{{ is_state('device_tracker.some_phone_1', 'home') }}"
                - "{{ is_state('device_tracker.some_phone_2', 'home') }}"
          sequence:
            - action: tts.yandex_station_say
              entity_id:
                - media_player.yandex_tv_t60yh6002t37mk
              data:
                message: '{{ ["voice_message_1", "voice_message_2", "voice_message_3", "voice_message_4"]|random }}'
                options:
                  volume_level: 0.4
            - action: camera.snapshot
              data:
                filename: |
                  {{ vars_dahua_vto_camera['photo_path'] }}
              target:
                entity_id: |
                  {{ vars_dahua_vto_camera['camera_entity'] }}

            - delay:
                milliseconds: 200
            - action: telegram_bot.send_photo
              data:
                chat_id:
                  - !secret telegram_group_id
                message_thread_id: some_message_thread_id
                parse_mode: markdown
                caption: "*Звонок в калитку*"
                file: |
                  {{ vars_dahua_vto_camera['photo_path'] }}
                inline_keyboard:
                  - '{{"\U0001F44B"}} Открыть:/send_open_door, {{"\U0001F595"}} Послать:/send_fuck_you'
        - conditions:
            - "{{ trigger.event.data.command == '/send_open_door' }}"
          sequence:
            - action: dahua.vto_open_door
              data:
                door_id: 1
              target:
                entity_id: |
                  {{ vars_dahua_vto_camera['camera_entity'] }}

        - conditions:
            - "{{ trigger.event.data.command == '/send_fuck_you' }}"
          sequence:
            - action: telegram_bot.delete_message
              data_template:
                message_id: "last"
                chat_id: "{{ trigger.event.data.chat_id }}"