Smanar / Domoticz-deCONZ

deCONZ plugin for Domoticz (Zigbee application)
GNU General Public License v3.0
36 stars 26 forks source link

Add support for Heiman Siren HS2WD-E #97

Closed opechunka closed 3 years ago

opechunka commented 3 years ago

Deconz recognizes Heiman Siren HS2WD-E as a Warning device. Then Domoticz recognize two switches related to the Siren. 1. elif _Type == 'Warning device': kwarg['Type'] = 244 kwarg['Subtype'] = 73 kwarg['Switchtype'] = 0 kwarg['Image'] = 13

2. elif _Type == 'ZHAAlarm': kwarg['Type'] = 244 kwarg['Subtype'] = 73 kwarg['Switchtype'] = 2

And that's it. It's not possible to control the siren with those. Can you please add support for it?

Smanar commented 3 years ago

Oups sorry, haven't see this issue. There was a change recently for that, if you want to try the last version ? (Stable too, don't need the beta branch)

opechunka commented 3 years ago

Just checked. It works. Thank you. The only note, that it's just possible to turn it on and off. I would preffer to have a selector switch with commands, none, (off) select, (short siren) lselect, (long siren) blink (just strobe)

Smanar commented 3 years ago

Ha, strange, someone else have asked exaclty the same thing somes days ago.

The problem is this device is old, so if I change the widget, it will broke all existing automations, and you will loose the icon, the selector switch is less "customisable" You realy use the strobe or the short sound ?

opechunka commented 3 years ago

You realy use the strobe or the short sound ?

I'm not using it yet, as it didn't work. But I consider to use short sound and just strobe for some events. For example strobe would be usefull to indicate something during the night, when the event is not critical, so it will not wake up all my family in the house. Short sound would be usuful when I put the system to alarm mode as a confirmation.

opechunka commented 3 years ago

I suggest it can be done with a code like this, def onCommand(self, Unit, Command, Level, Hue): ..........

level

    if Command == 'Set Level':

..............

        #Special code to force devive update for group
        elif _type == 'groups':
            UpdateDeviceProc({'nValue': 1, 'sValue': str(Level)}, Unit)
            pass
        elif device_type == 'Warning device':
            #Heyman Siren
            _json.clear()
            if Level == 0:
                _json['alert'] = "none"
            UpdateDeviceProc({'nValue': Level, 'sValue': 'none'}, Unit)
            elif Level == 10:
                _json['alert'] = "select"
            UpdateDeviceProc({'nValue': Level, 'sValue': 'select'}, Unit)
            elif Level == 20:
                _json['alert'] = "lselect"
            UpdateDeviceProc({'nValue': Level, 'sValue': 'lselect'}, Unit)
            elif Level == 30:
                _json['alert'] = "blink"
            UpdateDeviceProc({'nValue': Level, 'sValue': 'blink'}, Unit)

I tested, it works, but maybe this code can be written in more "right" style.

opechunka commented 3 years ago

And of cause, I've redefined Warning device like

elif _Type == 'Warning device':
    kwarg['Type'] = 244
    kwarg['Subtype'] = 62
    kwarg['Switchtype'] = 18
    kwarg['Image'] = 13
    kwarg['Options'] = {"LevelActions": "|||", "LevelNames": "none|select|lselect|blink", "LevelOffHidden": "false", "SelectorStyle": "0"}

But it will brake the compatibility with other users' systems. So most probably the new device (switch) has to be defined, if to make the changes public available .

Smanar commented 3 years ago

But it will brake the compatibility with other users' systems.

Yeah it s exaclty my problem, but you was 2 in few days to ask that, It's perhaps something usefull. I have asked to the other user if he is sure to use all features.

Smanar commented 3 years ago

Ok, so I have used your code, can you try the beta branch, delete your device, it will be re-created.

For old version, the code will work too, but they will not have return state,

Smanar commented 3 years ago

@opechunka so it's better ?

opechunka commented 3 years ago

@opechunka so it's better ?

Hi, Sorry, still didn't have time to check. I'll check during the weekend.

opechunka commented 3 years ago

@Smanar , Hi, I have an issue with my Siren. It hanged and doesn't react to any command. I even cannot add it to ZigBee network, although LED is blinking. It happend already the second time. It has an internaly battery. There is no reset button on it. I didn't find a way, to open it. So the only way is to wait till battery is discharged. And then it will work properly again.

Smanar commented 3 years ago

It haven't a little hole like this one https://wattle.com/support/our-products/latest-generation/smart-siren/ ? I have an other use that have broked his device in less than 1 week. And another that have find a not compatible model, he have buy a second one, full compatible https://github.com/dresden-elektronik/deconz-rest-plugin/issues/4924

I don't think it's the more reliable model.

opechunka commented 3 years ago

It has a little hole. And it worked for adding / removing it to Zigbee network. But something happens with it (already second time), and Zigbee controller doesn't receive any messages from it. When I press in the hole, it start blinking, signaling that it has been removed from the network. When I press after this it starts quickly blinking as in Add mode. But Zigbee controller still does not receive any messages from it. The previous time I waited till the intenal battery fully got discharged. Then plugged in into the AC socket and it it started to work ! Looks like some piece of hardware hangs inside time to time. And the small hole button doesn't help to recover from this hang. I looked on the photo by the link you've provided. I have exactly the same model, what another guy had. It has the text "Zigbee" without 3.0. So it's a problematic one. I'll try to buy another model, with "Zigbee 3.0" print, which worked for the guy. But who know what they ship from Aliexpress. But the way, the battery is still not discharged.

opechunka commented 3 years ago

@Smanar , ok, so thanks to the link you provided and to the photos, I've managed to open the siren, disconnected and reconnected the batery and it works again. I've tested the code from the beta branch. It works. I can select any mode. The only thing to mention, that the siren icon on the switch is always dimmed.

Smanar commented 3 years ago

that the siren icon on the switch is always dimmed

You man alaways "on" even on "none" state (it s the "off" position)?

opechunka commented 3 years ago

You man alaways "on" even on "none" state (it s the "off" position)?

I mean always "off". It's always grey (no color)

Smanar commented 3 years ago

Have updated the code again (if you are still on beta branch)

cd Domoticz-deCONZ
git pull

Then restart the plugin, Hardware/deconz/update.

opechunka commented 3 years ago

Didn't help. Still the same issue.

Smanar commented 3 years ago

Ha ? all seem fine on my side. The icon is still grayed, but the activated button change ? Can you share domoticz logs ("debug info only") when pressing the switch button ? (can need to wait 4/5s for return state)

opechunka commented 3 years ago

The buttons are activated properly. The only thing is that the Siren icon is always grayed (not red). Not sure that this is important.

Smanar commented 3 years ago

For me yes ^^. It s a missing feature On my side the icon is greyed only on "none" state, but I m using simulation.

    if command == 'alert':
        #Can be none, lselect, select, strobe
        if val == 'select':
            kwarg['nValue'] = 10
            kwarg['sValue'] = '10'
        if val == 'lselect':
            kwarg['nValue'] = 20
            kwarg['sValue'] = '20'
        if val == 'blink':
            kwarg['nValue'] = 30
            kwarg['sValue'] = '30'
        else:
            kwarg['nValue'] = 0
            kwarg['sValue'] = 'Off'

Seriously, I don't see the problem, perhaps if you have 2 values in the returned JSON, and if one overwrite the second one ....

Edit: have found a problem, but not sure it will solve the issue, if you can re-update the code ? Now the code is

    if command == 'alert':
        #Can be none, lselect, select, strobe
        if val == 'select':
            kwarg['nValue'] = 10
            kwarg['sValue'] = '10'
        elif val == 'lselect':
            kwarg['nValue'] = 20
            kwarg['sValue'] = '20'
        elif val == 'blink':
            kwarg['nValue'] = 30
            kwarg['sValue'] = '30'
        else:
            kwarg['nValue'] = 0
            kwarg['sValue'] = 'Off'
opechunka commented 3 years ago

The latest changes didn't help.

Here is log:

2021-07-21 14:41:06.829 deConz: (deConz) Pushing 'onCommandCallback' on to queue 2021-07-21 14:41:06.862 (deConz) Processing 'onCommandCallback' message 2021-07-21 14:41:06.862 deConz: (deConz) Calling message handler 'onCommand'. 2021-07-21 14:41:06.862 deConz: (deConz) onCommand called for Unit 36: Parameter 'Set Level', Level: 30, Hue: 2021-07-21 14:41:06.862 deConz: (deConz) Send Command /api/42ED977A34/lights/9/state with {'alert': 'blink'} (0 in buffer) 2021-07-21 14:41:06.862 deConz: (deConz) Making Request: http://127.0.0.1:80/api/42ED977A34/lights/9/state with params {'alert': 'blink'} 2021-07-21 14:41:06.872 deConz: (deConz) Request Return: [{"success":{"/lights/9/state/alert":"blink"}}] 2021-07-21 14:41:06.872 deConz: (deConz) Classic Data : [{'success': {'/lights/9/state/alert': 'blink'}}]

I think that the problem is, that the siren doesn't return the state. I remember I did some exeriments with it some times ago, and I noticed that it never returns the state.

Maybe just that is the state: Request Return: [{"success":{"/lights/9/state/alert":"blink"}}] ?

Smanar commented 3 years ago

I think that the problem is, that the siren doesn't return the state. I remember I did some exeriments with it some times ago, and I noticed that it never returns the state.

Ha yes, it s that, it s patched for the on*off command but not the mutiple switch.

Have corrected the code again, I think it will be fine now.

opechunka commented 3 years ago

Have corrected the code again, I think it will be fine now.

Now it works. Thank you!

Smanar commented 3 years ago

Ha ^^ finally. Thx for your patience :)