rroller / dahua

Dahua Camera and Doorbell Home Assistant Integration
MIT License
396 stars 80 forks source link

Reboot Service Call #136

Closed bagobones closed 2 years ago

bagobones commented 2 years ago

Is your feature request related to a problem? Please describe.

My AD110 camera seems to slow down over time (stream losing frames, errors in connecting) and this is corrected by rebooting.. Both the Amcrest mobile app and Synology Surveillance station appear to support sending a reboot to the device so it is likely a standard feature on other devices as well.

Describe the solution you'd like A home assistant service call I can call with an automation to reboot the device when I want.

Describe alternatives you've considered Surveillance Station supports scheduled restarts or restarts when IT loses contact with the device.

Additional context Just want to be able to reboot the device from Home Assistant.

rroller commented 2 years ago

Should be easy to add. I'll get to this asap.

jaytea33 commented 2 years ago

+1 for this feature but for anyone who needs a workaround for the time-being, I was able to add a reboot button with a curl command in a bash script, adding this to /config/shell (where "doorbell" is your IP/hostname and obviously your* is where your credentials go)

!/bin/bash

curl --anyauth --user yourusername:yourpassword http://doorbell/cgi-bin/magicBox.cgi?action=reboot

save as something like "rebootdoorbell.sh" to /config/shell and make sure it has execution rights (chmod +x rebootdoorbell.sh). Putty or WinSCP should work just fine.

add something like this to your config.yaml, replacing description and script name as necessary and reboot HA after (mind the YAML spacing):

shell_command: reboot_doorbellcam: bash /config/shell/rebootdoorbell.sh

Use the Helper section in HA to create a Button. Add it to your Lovelace dashboard.

Create an automation to trigger the shell service when the button is pressed - should be pretty simple but here's my yaml for it (keep in mind the formatting will likely be jacked up but just use the UI it's a simple automation):

alias: Reboot Doorbell Camera description: '' trigger:

Optionally, you can use the Restriction card (https://github.com/iantrich/restriction-card) to lock the card so that you need to confirm before being able to access the button. Very useful for avoiding accidental button presses on things like this or opening the garage door.

rroller commented 2 years ago

I added this in 0.9.36

With the UI:

image

With YAML

service: dahua.reboot
data: {}
target:
  entity_id: camera.doorbell_d1a1_main
jaytea33 commented 2 years ago

Awesome, thanks! Works like a charm.

jgverweij commented 2 years ago

Top! Could you also provide this service as a button entity with device class restart in the Configuration section of the device?

e.g. button.{{ cam name }}_reboot

See https://www.home-assistant.io/integrations/button/ for the general idea. Makes it easier to add to Lovelace 😀

bagobones commented 2 years ago

Nice, just updated. I will have to check it out.

bagobones commented 2 years ago

Tested out the service call today, worked perfectly.. Not sure if I will use it on a schedule or try to detect poor performance.

Would be nice to have a button however.