pergolafabio / Hikvision-Addons

Home Assistant: Hikvision Doorbell
187 stars 41 forks source link

DS-KH6320-WTDE1 doorbell volume restore issue #226

Closed 6PATyCb closed 1 month ago

6PATyCb commented 1 month ago

What happened?

Hi. I am trying to control DS-KH6320-WTDE1doorbell from HA. When I click to "Mute audio output" my volume level cannot be parsed correctly from the response and as a result after unmuting the volume is restored to default. All details in debug log.

Add-on

Hikvision Doorbell

What version of the add-on are you running?

3.0.16

Installation type

Home Assistant add-on

Relevant log output

2024-10-03 02:05:42.682 | INFO     | mqtt_input:_mute_audio_output_callback:489 - Received mute audio output command for doorbell: Indoor_extention
2024-10-03 02:05:42.682 | DEBUG    | sdk.utils:call_ISAPI:125 - Call ISAPI request method url body: GET /ISAPI/System/Audio/AudioOut/channels/1  
[2024-10-03 02:05:42.689][INF] Private connect 192.168.133.170:8000 sock=203 this=0x52c528dc cmd=0x117000 port=39710

2024-10-03 02:05:42.692 | DEBUG    | sdk.utils:call_ISAPI:165 - Response output: <AudioOut version="2.0" xmlns="http://www.isapi.org/ver20/XMLSchema">
<id>1</id>
<AudioOutVolumelist>
<AudioOutVlome>
<volume>1</volume>
<talkVolume>1</talkVolume>
</AudioOutVlome>
</AudioOutVolumelist>
</AudioOut>

2024-10-03 02:05:42.693 | DEBUG    | doorbell:mute_audio_output:384 - Current talk volume found: 1
2024-10-03 02:05:42.693 | DEBUG    | doorbell:mute_audio_output:389 - Current volume not found, using 7 as default
2024-10-03 02:05:42.694 | DEBUG    | sdk.utils:call_ISAPI:125 - Call ISAPI request method url body: PUT /ISAPI/System/Audio/AudioOut/channels/1 <AudioOut><id>1</id><AudioOutVolumelist><AudioOutVlome><type>audioOutput</type>
                         <volume>0</volume><talkVolume>1</talkVolume>
                         </AudioOutVlome></AudioOutVolumelist></AudioOut> 
[2024-10-03 02:05:42.692][DBG] SimpleSTDCommandToDvr with out cmd[GET /ISAPI/System/Audio/AudioOut/channels/1], input size[0], max segment length[262144]

[2024-10-03 02:05:42.699][INF] Private connect 192.168.133.170:8000 sock=203 this=0x52c528dc cmd=0x117001 port=39724

[2024-10-03 02:05:42.735][DBG] SimpleSTDCommandToDvr with out cmd[PUT /ISAPI/System/Audio/AudioOut/channels/1], input size[223], max segment length[262144]

Relevant configuration

doorbells:
  - name: Indoor_korridor
    ip: 192.168.133.169
    username: admin
    password: 
  - name: Indoor_extention
    ip: 192.168.133.170
    username: admin
    password: 
system:
  log_level: DEBUG
  sdk_log_level: DEBUG
mqtt:
  host: 192.168.144.112
  port: 1883
  ssl: false

Anything else?

No response

pergolafabio commented 1 month ago

Yes, that could be normal, older models don't support all Isapi commands, it doesn't work on my extension either :-(

6PATyCb commented 1 month ago

Doesn't look like a problem with Isapi. Please look at the xml response of my device at log: изображение It contains the necessary meaning for memorization. For some reason xpath is missing this value (dorbell.py): изображение

pergolafabio commented 1 month ago

hm, its indeed strange, the value is there? is if failing on both indoor stations?

pergolafabio commented 1 month ago

the idea is tochange this behaviour anyway , instead of having 2 buttons in the addon , its better to have 1 number entity, so you can make a service to define the volume to a number you choose yourself

6PATyCb commented 1 month ago

hm, its indeed strange, the value is there? is if failing on both indoor stations?

Yes, the behavior is completely the same.

Python is not a language close to me, I already wanted to change the xpath myself, but this is the wrong approach, because it is better for other users to fix this problem. So far I have not managed to figure out how to get to the source inside the docker container to try to fix it at least for myself.

6PATyCb commented 1 month ago

the idea is tochange this behaviour anyway , instead of having 2 buttons in the addon , its better to have 1 number entity, so you can make a service to define the volume to a number you choose yourself

It will look better, but under the hood the logic probably won't change much. You'll still have to read and remember the previous volume state.

pergolafabio commented 1 month ago

no, not need to remember the last setting, i just create one service like number.set "xx"" you deice then if its 0 or 7 or whatever

6PATyCb commented 1 month ago

no, not need to remember the last setting, i just create one service like number.set "xx"" you deice then if its 0 or 7 or whatever

Maybe I didn't explain the original error well. Turning the volume off and on generally works, but the original volume before turning it off is 1, and after turning it back on it becomes 7, and I would like it to be 1 again. I can't figure out how to solve this issue without remembering the original volume level.

6PATyCb commented 1 month ago

I was found how to fix it: at doorbell.py need replace 387 row old text is: if currentVolume is None or currentVolume.text is None or "0": new text is: if currentVolume is None or currentVolume.text is None or currentVolume.text is "0":

6PATyCb commented 1 month ago

no, not need to remember the last setting, i just create one service like number.set "xx"" you deice then if its 0 or 7 or whatever

Oh, I'm very stupid, but now I get your idea. My fix now is not required.

pergolafabio commented 1 month ago

can you try the beta addo version : 69 ? i just pushed it, i changed lien to :

if currentVolume is None or currentVolume.text is None or currentVolume.text == "0":

6PATyCb commented 1 month ago

Checked in beta. Works as it should. It was a tested piece of code. I figured out how to edit the source in docker and checked it.

mute: изображение

unmute: изображение