pergolafabio / Hikvision-Addons

Home Assistant: Hikvision Doorbell
187 stars 41 forks source link

Toggle/command to change the doorbell schedule #231

Closed sesardelaisla closed 2 weeks ago

sesardelaisla commented 3 weeks ago

Is there an existing feature request for this?

Add-on

Doorbell

Your feature request

Hi,

I have a DS-KV6113-WPE1(C) doorbell which has been working fine with your addon for sometime. I am wondering whether it would be possible to add a button/switch for changing from one schedule profile to another. Such doorbell allows to set two profiles/templates: one for the doorbell to be working all the time (which can't be customized) and another one to customize "disabled" time slots. With this second template, the doorbell will reject calls and will play a busy tone to the caller. My scenario would be to set such a template to disable it all the time:

doorbell02

Then, what I would like such button to do is to switch between profiles:

doorbell01

If so, I will be able to automate disable time slots without having to use the doorbell interface, but Home Assistant's.

Looking forward for feedback. Thanks!

pergolafabio commented 3 weeks ago

Ok , interesting... I will have a look next week if there is an command to trigger it with isapi, if there is, I can add it easily indeed...

pergolafabio commented 3 weeks ago

Btw , there are also mute/unmute buttons on my addon, , you can then mute the incoming call on your indoor, maybe that's also enough instead of rejecting the call?

sesardelaisla commented 3 weeks ago

Btw , there are also mute/unmute buttons on my addon, , you can then mute the incoming call on your indoor, maybe that's also enough instead of rejecting the call?

Buttons must be pushed manually to mute, so indoor will ring until done, and such action won’t mute phone calls. I’d rather not to receive calls at all: indoor and mobile phones without any action. I think it is useful for setting a kind of “no disturb” or “night” mode.

pergolafabio commented 3 weeks ago

https://open.hikvision.com/hardware/definitions/NET_DVR_SetDVRConfig_ACS.html

NET_DVR_SET_DOOR_STATUS_PLAN_TEMPLATE => NET_DVR_PLAN_TEMPLATE

not sure if thats the correct one ..

pergolafabio commented 3 weeks ago

hmm, that one i posted before is incorrect, i think i have found the isapi command:

can you try also?

curl -i --digest -u admin:XXX http://192.168.0.70/ISAPI/VideoIntercom/keyCfg/1

gives back:

<?xml version="1.0" encoding="UTF-8"?>
<KeyCfg version="2.0" xmlns="http://www.isapi.org/ver20/XMLSchema">
<id>1</id>
<module>main</module>
<callNumber>1</callNumber>
<enableCallCenter>false</enableCallCenter>
<templateNo>0</templateNo>
</KeyCfg>

you can also do a PUT to change it ... this is the request you need to send with it, tough i dont see how to change the enableCallCenter, but maybe its enough to activate the enableCallCenter instead?

curl -i --digest -u admin:XXX-X PUT -d 'XML HERE' http://192.168.0.70/ISAPI/VideoIntercom/keyCfg/1

<KeyCfg version="2.0" xmlns="http://www.isapi.org/ver20/XMLSchema"> 
  <id><!--required, xs:integer, button No. which corresponds to the <ID> in the request URI /ISAPI/VideoIntercom/keyCfg/<ID>--></id>
  <module><!--optional, xs:string, module to be configured: "main"-main module (default), "sub"-sub module-->   </module>
  <moduleId><!--dependent, xs:integer, sub module ID, this node is valid when <module> is "sub" and is used to specify that the button information of which module will be configured--></moduleId>
  <callNumber><!--dependent, xs:string, called number, this field is valid when <callMethod> is "callNumber"--></callNumber>
  <enableCallCenter><!--optional, xs:boolean, whether to call the management center--></enableCallCenter>
  <callMethod><!--optional, xs:string, calling method: "callNumber"-call by number, "manageCenter"-call the management center, "app"-call APP. The empty string is invalid, and if this node is configured, the node <enableCallCenter> is not required--></callMethod>
</KeyCfg>
pergolafabio commented 3 weeks ago

the xml i posted from the manual is probably not up to date; i think you can just include the templateNo , like below for example

to enable/disable plan:

curl -i --digest -u admin:xxx -X PUT -d '<KeyCfg><id>1</id><module>main</module><callNumber>1</callNumber><enableCallCenter>false</enableCallCenter><templateNo>0</templateNo></KeyCfg>' http://192.168.0.70/ISAPI/VideoIntercom/keyCfg/1

curl -i --digest -u admin:xxx -X PUT -d '<KeyCfg><id>1</id><module>main</module><callNumber>1</callNumber><enableCallCenter>false</enableCallCenter><templateNo>1</templateNo></KeyCfg>' http://192.168.0.70/ISAPI/VideoIntercom/keyCfg/1
sesardelaisla commented 3 weeks ago

the xml i posted from the manual is probably not up to date; i think you can just include the templateNo , like below for example

to enable/disable plan:

curl -i --digest -u admin:xxx -X PUT -d '<KeyCfg><id>1</id><module>main</module><callNumber>1</callNumber><enableCallCenter>false</enableCallCenter><templateNo>0</templateNo></KeyCfg>' http://192.168.0.70/ISAPI/VideoIntercom/keyCfg/1

curl -i --digest -u admin:xxx -X PUT -d '<KeyCfg><id>1</id><module>main</module><callNumber>1</callNumber><enableCallCenter>false</enableCallCenter><templateNo>1</templateNo></KeyCfg>' http://192.168.0.70/ISAPI/VideoIntercom/keyCfg/1

If I execute such commands as they are, I get a "non authorized" response. However, if I reformat them a bit, they work fine. Perhaps it happens due to my own setup. Anyway, the key part of the commands works, so you found what I really needed. Thanks!

Enable default template curl --digest -u admin:***** 'http://192.168.0.72/ISAPI/VideoIntercom/keyCfg/1' -X 'PUT' --data-raw '<KeyCfg><id>1</id><module>main</module><callNumber>1</callNumber><enableCallCenter>false</enableCallCenter><templateNo>0</templateNo></KeyCfg>' --insecure

Enable custom template curl --digest -u admin:***** 'http://192.168.0.72/ISAPI/VideoIntercom/keyCfg/1' -X 'PUT' --data-raw '<KeyCfg><id>1</id><module>main</module><callNumber>1</callNumber><enableCallCenter>false</enableCallCenter><templateNo>1</templateNo></KeyCfg>' --insecure

Will you implement this in your addon? :)

pergolafabio commented 3 weeks ago

Yeah I can do that, will try to add it next week , gonna add 2 new buttons

sesardelaisla commented 3 weeks ago

Please, add something which makes getting current template status possible, so it can be displayed in the dashboard which template is selected. Thanks!

pergolafabio commented 3 weeks ago

Yeah, but then I need to implement a polling every xx time, it's possible, but I want to avoid it as much as possible, this addon is for getting events..

What I can do, a button, like the other buttons , when you press on it, it will get the state... So you can do it manually or with an automatio to poll it...

And another button to toggle between the templates

pergolafabio commented 3 weeks ago

Is there also such a setting on indoor panels? Do maybe deny a call?

sesardelaisla commented 3 weeks ago

Is there also such a setting on indoor panels? Do maybe deny a call?

I don’t think so. If a template is set to disable, the doorbell basically plays a busy tone to the visitor, and neither indoor nor phones ring.

As for getting the status, I understand your point. Perhaps you can get the status when template is changed only, although I can do that with an automation… For me, being able to change the templates from the addon for not having to create commands manually (as well as a button to get the status) is more than enough. 👌

pergolafabio commented 3 weeks ago

I have an DND setting on my indoor? Don't you have that?

Maybe that's a better approach, so users can decide if they still want to ring on device A , and DND on device B.. Instead of disable it all...

sesardelaisla commented 3 weeks ago

The DND setting in my doorbell silents de indoor only. You still receive calls on the phones. I’d like to have the option to disable everything without having to set DND on every device. Furthermore, I don’t want to set DND om the phones, as the only thing I want to disable is the doorbell and its devices/calls.

EDIT: By the way… having the option to disable the indoor option only in addition to what I am asking for would be great as well. Is it already possible?

pergolafabio commented 3 weeks ago

Ah ok, makes sense!! :+)

Will add it in coming weeks, maybe also together with DND mode if I can find that setting

pergolafabio commented 3 weeks ago

Ah ok, makes sense!! :+)

Will add it in coming weeks, maybe also together with DND mode if I can find that setting

pergolafabio commented 2 weeks ago

i was thinking about this additional feature , the "problem" is, it needs to work for everyone, proobably there are also users with 2 main buttons, or maybe with sub modules, if i create 2 entities for each "callnumber", it wil create a lot of unnessesary enties for most people...

Instead i could make it as a service, like ...

service: hassio.addon_stdin
data:
  addon: aff2db71_hikvision_doorbell
  input: id main/sub callnumber template on/off

ex:

service: hassio.addon_stdin
data:
  addon: aff2db71_hikvision_doorbell
  input: 1 main 1 1

or maybe a config option the addon like:

- name: DS-KD8003
  ip: 192.168.0.70
  username: admin
  password: XXX
  template_numbers: 2

if template numbers is not present in addon config, it doesnt create entities, if present, it creates the amount of entities for the callnumbers you need, in example above, it will create 4 ... 2 buttons to poll the state of template if enabled/disabled 2 buttons to change the template for id/callnumber 1 and 2

pergolafabio commented 2 weeks ago

i think the first option is the better one, especially for users with submodules, and where the callnumber is different

pergolafabio commented 2 weeks ago

or maybe a third option is to create an text entity with some prefilled text, like the diagnostic one (disabled by default)

so you can type in the GET url or PUT url, like below i can add those ISAPI commands in some kind of documentaion, can be usefull in future for other isapi commands too

image

action: text.set_value
target:
  entity_id: text.ds_kd8003_isapi_request
data:
  value: GET /ISAPI/VideoIntercom/keyCfg/1

will give as result:

image

sesardelaisla commented 2 weeks ago

I think any service call option is the way to go. Having at least the option to call the services should be enough for everyone. I understand it is not something many people require, so having at least a "hidden" but documented option is fine. Actually, taking into account that I already know the cURL command to post, I can just build a shell_command for my own setup. However, it would be great if you can add it to the addon for an easier use. Thanks!

sesardelaisla commented 2 weeks ago

i can add those ISAPI commands in some kind of documentaion, can be usefull in future for other isapi commands too

I missed this. It is a great idea indeed!

pergolafabio commented 2 weeks ago

yes, gonna make the isapi input field a non-diagnostic one, so its visible by default... so its a small change i need todo on the addon, then i add it to the docs, with some other usefull ISAPI commands...

that way, its flexible for everyone

pergolafabio commented 2 weeks ago

i added release 18 , with isapi field default enabled

sesardelaisla commented 2 weeks ago

I am trying to change the template with the commands as indicated but they don't work. The text entity attribute does not change in HASS. Neither does in doorbell setting:

Captura de pantalla 2024-11-06 a las 15 50 31

Captura de pantalla 2024-11-06 a las 15 49 46

However, if I enable the template in the doorbell web back-en:

Captura de pantalla 2024-11-06 a las 15 55 01

And then I issue a GET command:

Captura de pantalla 2024-11-06 a las 15 55 56

TemplateNo is updated:

Captura de pantalla 2024-11-06 a las 15 53 19

cURL commands still work.

Any advice, please?

pergolafabio commented 2 weeks ago

show me your service you are doing, your PUT request is wrong, it should be the complete: <KeyCfg><id>1</id><module>main</module><callNumber>1</callNumber><enableCallCenter>false</enableCallCenter><templateNo>1</templateNo></KeyCfg>

sesardelaisla commented 2 weeks ago

Ok. The format as per de cURL commands work. Now I understand how to handle this. Thanks!

I think the docs are confusing. As an example, you state this:

PUT /ISAPI/VideoIntercom/keyCfg/1 1main1false1

I thought I had to discard the html tags and include the values only. I guessed there was some sort of regex rule being applied to expand those 1, main, 1, false and 1 values. I tried to break them out with spaces but didn't try to use the actual raw tags-based string. Thanks for pointing this out.

pergolafabio commented 2 weeks ago

indeed, the formatting messes up, it was correct :-)

i edited it now