Smanar / Domoticz-deCONZ

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

Ikea Remote "Styrbar" sends wrong values in Domoticz #115

Closed veitk closed 2 years ago

veitk commented 2 years ago

As mentioned in the Domoticz Forum - the Styrbar remote only sends values from 10-40 ...

2021-11-26 21:11:31.794 deCONZ plugin: ### WebSocket Data : {'attr': {'id': '8', 'lastannounced': None, 'lastseen': '2021-11-26T20:11Z', 'manufacturername': 'IKEA of Sweden', 'modelid': 'Remote Control N2', 'name': 'Styrbar die eine', 'swversion': '1.0.024', 'type': 'ZHASwitch', 'uniqueid': '84:fd:27:ff:fe:07:75:ff-01-1000'}, 'e': 'changed', 'id': '8', 'r': 'sensors', 't': 'event', 'uniqueid': '84:fd:27:ff:fe:07:75:ff-01-1000'}

So i guess the model-id you need to add to your code is 'Remote Control N2' Values should be the same as the old ikea remote but if you need them i can of course read them out.

thanks for your cool plugin!

Smanar commented 2 years ago

If you think the device use same value than for the old ikea remote this change can be enought https://github.com/Smanar/Domoticz-deCONZ/commit/71e5f75f0f847f9c6aa9571419e83fdceb81969f#diff-08655555cc53ca79554ba180d1ae7e6ebe5c9b0a25e1772ce248fdd8b83dab34

You can just edit the files (you will have an error message if you use 'git pull" later, but not a big problem)

And just need to restart the plugin, hardware/deconz/update.

veitk commented 2 years ago

ah sorry - i didn't check all states. i will try to modify the code for the styrbar.

Smanar commented 2 years ago

But you are right, it can work, both remote have same button number.

veitk commented 2 years ago

well i want to implement the longpress numbers which start with 1001 and stops with 1003, 1002 is the short click ... so i added a few lines of code and made a new type styrbar, the function for the convertion, added the fields for the level values and so on but the plugin crashes after i click update. running out of time for today, i forked your repo but i didn't push my changes yet

Smanar commented 2 years ago

Take care, on the old remote the long press on the on/off buton is forbidden, it s fir that it is not configured in deconz. This action change the device working mode.

Smanar commented 2 years ago

@veitk you need some help ?

veitk commented 2 years ago

too much to work at the moment :( but maybe next week i will try it again and i will probably have questions - thx for your offer!

Smanar commented 2 years ago

NP, or if you can't do it just give me the value you want. If you want to do it yourself mimic the device "RWL021" if your device is totaly different than the actual ikea one.

Smanar commented 2 years ago

Hello, some news ^^ ? It because somes other users have made some PR, and I want to update the stable soon, so if you want your device will be in the next version.

veitk commented 2 years ago

unfortunately i have too much work before the holidays. i made changes to your code but i can't push it to my github fork right now. it crashes ...

this is what i did:

fonctions.py:

def ButtonconvertionStyrbar(val): kwarg = {} val = str(val) if val == '1001': kwarg['nValue'] = 10 elif val == '1002': kwarg['nValue'] = 20 elif val == '1003': kwarg['nValue'] = 30 elif val == '2001': kwarg['nValue'] = 40 elif val == '2002': kwarg['nValue'] = 50 elif val == '2003': kwarg['nValue'] = 60 elif val == '4001': kwarg['nValue'] = 70 elif val == '4002': kwarg['nValue'] = 80 elif val == '4003': kwarg['nValue'] = 90 elif val == '5001': kwarg['nValue'] = 100 elif val == '5002': kwarg['nValue'] = 110 elif val == '5003': kwarg['nValue'] = 120 else: kwarg['nValue'] = 0

if kwarg['nValue'] == 0:
    kwarg['sValue'] = 'Off'
else:
    kwarg['sValue'] = str( kwarg['nValue'] )

return kwarg

i added the import in plugin.py: fonctions import ButtonconvertionXCUBE, ButtonconvertionXCUBE_R, ButtonconvertionTradfriRemote, ButtonconvertionStyrbar, ButtonconvertionTradfriS ......

and filtered the name (Remote Control N2 is the actual name): elif 'Remote Control N2' in Model: Type = 'Styrbar_remote'

called the conversion: elif model == 'Styrbar_remote': kwarg.update(ButtonconvertionStyrbar( state['buttonevent'] ) )

and the last step i gave them level names and stuff: elif _Type == 'Styrbar_remote': kwarg['Type'] = 244 kwarg['Subtype'] = 62 kwarg['Switchtype'] = 18 kwarg['Image'] = 9 kwarg['Options'] = {"LevelActions": "||||||||||||", "LevelNames": "V0|V1|V2|V3|V4|V5|V6|V7|V8|V9|V10|V11|V12", "LevelOffHidden": "true", "SelectorStyle": "0"}

veitk commented 2 years ago

so the plugin crashes on the import in the plugin.py - but i can't find an error. i should have time to look into this next week, but maybe you see an error right away...

veitk commented 2 years ago

so i was able to push it to git and i made a PR - this is NOT WORKING there is definitely an error in there. what be awesome if you can find it, it is my first time with python ;-)

Smanar commented 2 years ago

Have updated the beta using your code, if you can try it ?

I have no crash on my side, but if it s domotiz that crash you probably have a python issue, you are not using bulleyes ?

veitk commented 2 years ago

you didn't update the fonctions.py ? i think this is important to use long press and so on

Smanar commented 2 years ago

Yes it s updated too https://github.com/Smanar/Domoticz-deCONZ/commit/dca44381193f97eae49330c9a3b3b0fc6f296202 But I m using a more "compact" fonction

veitk commented 2 years ago

ah i didn't see this commit only the last. okay it is running, i will have to do some testing soon.

Smanar commented 2 years ago

Have added 3001,3002,3003, but you are sure for 5001>5003 ? was on your post above.

veitk commented 2 years ago

Oh okay i think the error was on my side probably. I will play around with it and fix it if needed.

Smanar commented 2 years ago

I have just updated the code We was still using the Tradfri_remote code instead of Stybar, have not deleted a previous check

https://github.com/Smanar/Domoticz-deCONZ/commit/653db8ffd064afad68ab77eab3c3a957a7955bef

veitk commented 2 years ago

interesting, thanks. i will test it tomorrow. finally holiday ;-)

veitk commented 2 years ago

this is brilliant, now even everything with longclick works !!! previously i couldn't read out if the longpress ended. great!!!

Smanar commented 2 years ago

finally holiday ;-)

Lol, yeah merry christmas ^^

I will update the stable in some days.