Control Electric Gates through HA (Dahua VTO)

Hi,

I am new to the HA community and would like some help.

I have recently installed HA and my first project is to control some electric gates.

Currently the gates are controlled by a Dahua VTO (VTO6221E-P) that I manage from the DMSS app.

I have integrated the Dahua VTO events into DahuaVTO2MQTT

I followed this video to do this. https://www.youtube.com/watch?v=1U6SQDU6f24&feature=emb_logo

And

I can see the events in the log and can (kind of) understand them with help from this post.

I would like to now control the gates from Home Assistant, both manually (a button press) and automatically (I also have Dahua cameras with motion control that I can see on HA using ONVIF).

I am using Visual Studio as my editor.

I have also installed Node-Red but have no experience.

Thank you.

Please run this curl command to see if you can control the gate. If it works we can build the automation.

curl -s --globoff --digest --user admin:PASSWORD "http://192.168.1.XXX/cgi-bin/accessControl.cgi?action=openDoor&channel=1&UserID=101&Type=Remote"

please change admin, password , ip address to your values. you can run it from any terminal window having network access.

Thanks for the quick response.
Should i paste this into the config.yaml?
I receive an error “can not read a block mapping entry a multiline key may not be an implicit key”

not like that. copy the following to config.yaml

shell_command:
  gate_open: curl -s --globoff --digest --user admin:PASSWORD "http://192.168.1.XXX/cgi-bin/accessControl.cgi?action=openDoor&channel=1&UserID=101&Type=Remote"

Please dont forget to change the admin, password and ip address in the url.

After this go to config and check config and restart server.
after restarting go to developer console and then services. Call the service shell_command.gate_open .
If any doubt, please ask

I can see an error in the logs.
admin = my admin user name?
password = my password?
ip address is the IP address of my VTO?

yes username, password and IP of VTO

it worked!
that is amazing. Thank you.

ok. I hope now you can build the automation and also a momentary button to operate the gate. If you want any help, let me know.

I am going to work on that now.
Thank you, again.

Hi. the service opens the gate, waits x seconds and the closes the gate.

Is it possible to create a service that just opens and a seperate second service that closes the gate.

Thanks

For the time being I am not able to find any other api calls for opening a the door. Can you try a work around i,e to send this command again before the time ends to close the door. Which could restart the door close timer and keep the door open. Please try it and let me know.

repeating the call does keep the gate open. thanks.
could i create a toggle to keep calling the serivce every x seconds unitl i call switch off?

what would it look like?

I think you can create an input_boolean and then create an automation which will trigger when the this boolean changes from off to on. Then in actions select repeat until and put condition as off state of this input boolean.

Hi. I created the below automation.

However, it doens’t seem to work.

if i execute the automation manually the gate opens, but then closes.
if i change the boolean from off to on from the UI, nothing happens.

Could you help?
thanks

- id: '1611764001296'

  alias: Open Gate

  description: ''

  trigger:

  - platform: state

    entity_id: input_boolean.open_gate

    from: 'Off'

    to: 'On'

  condition: []

  action:

  - service: switch.turn_on

    data: {}

    entity_id: switch.dahua_gate_open

  - repeat:

      until:

      - condition: state

        entity_id: input_boolean.open_gate

        state: 'Off'

      sequence: []

  mode: single

Try with full lower case on/off instead On/Off

Thanks - it now opens the gate form the input boolea
however the gate still closes automatically.
Can i put a time on the repeat action e.g. repeat every x seconds?

This will repeat the sequence until the input boolean is turned off. Maybe this will be better

action:
  - repeat:
      until:
        - condition: state
          entity_id: input_boolean.open_gate
          state: 'off'

This is what i have. isn’t that the same?

>   action:
>   - service: switch.turn_on
>     data: {}
>     entity_id: switch.dahua_gate_open
>   - repeat:
>       until:
>       - condition: state
>         entity_id: input_boolean.open_gate
>         state: 'off'
>       sequence: []
>   mode: single

yes, isnt that working?

No, the gate still closes after a few seconds.