elad-bar / DahuaVTO2MQTT

Listens to events from Dahua VTO unit and publishes them via MQTT Message
103 stars 38 forks source link

Button (Entity) to open the door #31

Closed nunokaneco closed 3 years ago

nunokaneco commented 3 years ago

Hello all

I just need some help in order to get a button (Entity) to open the door over the home assistant I Try to use this information

TOPIC: [MQTT_BROKER_TOPIC_PREFIX]/Command/Open

But I cant understand how to use ...

Can anyone please help me in order to create this ??

Thank you for your support/help in advance

nunokaneco commented 3 years ago

I'm trying to add this to configuration.yaml like this but without success for now

type: button tap_action: action: call-service service: mqtt.publish
topic: [MQTT_BROKER_TOPIC_PREFIX]/Command/Open payload: "0" show_icon: false name: Door

elad-bar commented 3 years ago

You need to replace the [MQTT_BROKER_TOPIC_PREFIX] with the topic prefix you have set for the docker, by default it's DahuaVTO

nunokaneco commented 3 years ago

You need to replace the [MQTT_BROKER_TOPIC_PREFIX] with the topic prefix you have set for the docker, by default it's DahuaVTO

Great thank you for your reply !!

I Still have a issue when I press the button I receive this message on the footer page of the HA

Failed to call service mqtt/publish. required key not provided @ data['topic']

Can you please help me in order to solve this ?

Thank you and best regards

NimlothPL commented 3 years ago

@elad-bar there is issue when HTTPS is enabled - cert is not trusted and command execution fails

2021-03-17 19:30:59,029 DEBUG main MQTT Message DahuaVTO/Command/Open: b'0', 2021-03-17 19:30:59,029 DEBUG main Access Control - Open door, 2021-03-17 19:30:59,036 DEBUG urllib3.connectionpool Starting new HTTP connection (1): 192.168.1.201:80, 2021-03-17 19:30:59,047 DEBUG urllib3.connectionpool http://192.168.1.201:80 "GET /cgi-bin/accessControl.cgi?action=openDoor&channel=1&UserID=101&Type=Remote HTTP/1.1" 302 114, 2021-03-17 19:30:59,054 DEBUG urllib3.connectionpool Starting new HTTPS connection (1): 192.168.1.201:443, 2021-03-17 19:30:59,102 ERROR main Failed to open door, error: HTTPSConnectionPool(host='192.168.1.201', port=443): Max retries exceeded with url: /cgi-bin/accessControl.cgi?action=openDoor&channel=1&UserID=101&Type=Remote (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)'))), Line: 47,

elad-bar commented 3 years ago

it seems that the parameter of the hostname is configured with http url

NimlothPL commented 3 years ago

It's fine for it to be http, just when SSL is enabled Dahua is doing redirection from http to https - it's common behaviour. Just current implementation will fail as it's looking for certificate. Fix is easy - just add "verify=False": response = requests.get(url, verify=False, auth=HTTPDigestAuth(username, password))