sasu-drooz / Domoticz-Rfplayer

Domoticz python Plugin for Ziblue RfPlayer Rfp1000
GNU General Public License v3.0
12 stars 16 forks source link

Door Contact Visonic MCT-302 - infotype 2 #22

Closed Quentin-domo closed 7 years ago

Quentin-domo commented 7 years ago

Hi,

I'm testing the Door Contact MCT-302. (433 Mhz) with your plugin. The following frame is not decoded (Error Decoding/Reading )

best regards,

Quentin

2017-07-12 14:00:12.224 (rfp) Received 496 bytes of data:.
2017-07-12 14:00:12.224 (rfp) 5a 49 41 33 33 7b 20 22 66 72 61 6d 65 22 20 3a 7b 22 68 65 ZIA33{."frame".:{"he
2017-07-12 14:00:12.224 (rfp) 61 64 65 72 22 3a 20 7b 22 66 72 61 6d 65 54 79 70 65 22 3a ader":.{"frameType":
2017-07-12 14:00:12.224 (rfp) 20 22 30 22 2c 20 22 63 6c 75 73 74 65 72 22 3a 20 22 30 22 ."0",."cluster":."0"
2017-07-12 14:00:12.224 (rfp) 2c 20 22 64 61 74 61 46 6c 61 67 22 3a 20 22 30 22 2c 20 22 ,."dataFlag":."0",."
2017-07-12 14:00:12.224 (rfp) 72 66 4c 65 76 65 6c 22 3a 20 22 2d 35 31 22 2c 20 22 66 6c rfLevel":."-51",."fl
2017-07-12 14:00:12.224 (rfp) 6f 6f 72 4e 6f 69 73 65 22 3a 20 22 2d 31 30 33 22 2c 20 22 oorNoise":."-103",."
2017-07-12 14:00:12.225 (rfp) 72 66 51 75 61 6c 69 74 79 22 3a 20 22 31 30 22 2c 20 22 70 rfQuality":."10",."p
2017-07-12 14:00:12.225 (rfp) 72 6f 74 6f 63 6f 6c 22 3a 20 22 32 22 2c 20 22 70 72 6f 74 rotocol":."2",."prot
2017-07-12 14:00:12.225 (rfp) 6f 63 6f 6c 4d 65 61 6e 69 6e 67 22 3a 20 22 56 49 53 4f 4e ocolMeaning":."VISON
2017-07-12 14:00:12.225 (rfp) 49 43 22 2c 20 22 69 6e 66 6f 54 79 70 65 22 3a 20 22 32 22 IC",."infoType":."2"
2017-07-12 14:00:12.225 (rfp) 2c 20 22 66 72 65 71 75 65 6e 63 79 22 3a 20 22 34 33 33 39 ,."frequency":."4339
2017-07-12 14:00:12.225 (rfp) 32 30 22 7d 2c 22 69 6e 66 6f 73 22 3a 20 7b 22 73 75 62 54 20"},"infos":.{"subT
2017-07-12 14:00:12.225 (rfp) 79 70 65 22 3a 20 22 30 22 2c 20 22 73 75 62 54 79 70 65 4d ype":."0",."subTypeM
2017-07-12 14:00:12.225 (rfp) 65 61 6e 69 6e 67 22 3a 20 22 44 65 74 65 63 74 6f 72 2f 53 eaning":."Detector/S
2017-07-12 14:00:12.225 (rfp) 65 6e 73 6f 72 22 2c 20 22 69 64 22 3a 20 22 33 33 35 35 34 ensor",."id":."33554
2017-07-12 14:00:12.225 (rfp) 37 31 38 34 22 2c 20 22 71 75 61 6c 69 66 69 65 72 22 3a 20 7184",."qualifier":.
2017-07-12 14:00:12.225 (rfp) 22 33 22 2c 20 22 71 75 61 6c 69 66 69 65 72 4d 65 61 6e 69 "3",."qualifierMeani
2017-07-12 14:00:12.225 (rfp) 6e 67 22 3a 20 7b 20 22 66 6c 61 67 73 22 3a 20 5b 22 54 61 ng":.{."flags":.["Ta
2017-07-12 14:00:12.225 (rfp) 6d 70 65 72 22 2c 22 41 6c 61 72 6d 22 5d 7d 7d 7d 7d 0a 0d mper","Alarm"]}}}}..
2017-07-12 14:00:12.225 (rfp) 5a 49 41 33 33 7b 20 22 66 72 61 6d 65 22 20 3a 7b 22 68 65 ZIA33{."frame".:{"he
2017-07-12 14:00:12.225 (rfp) 61 64 65 72 22 3a 20 7b 22 66 72 61 6d 65 54 79 70 65 22 3a ader":.{"frameType":
2017-07-12 14:00:12.225 (rfp) 20 22 30 22 2c 20 22 63 6c 75 73 74 65 72 22 3a 20 22 30 22 ."0",."cluster":."0"
2017-07-12 14:00:12.225 (rfp) 2c 20 22 64 61 74 61 46 6c 61 67 22 3a 20 22 30 22 2c 20 22 ,."dataFlag":."0",."
2017-07-12 14:00:12.225 (rfp) 72 66 4c 65 76 65 6c 22 3a 20 22 2d 35 31 22 2c 20 22 66 6c rfLevel":."-51",."fl
2017-07-12 14:00:12.225 (rfp) 6f 6f 72 4e 6f 69 73 65 22 3a 20 22 2d 31 30 33 .. .. .. .. oorNoise":."-103
2017-07-12 14:00:12.225 (rfp) Calling message handler 'onMessage'.
2017-07-12 14:00:12.226 (rfp) Last Message was 2.809194 seconds ago, Message clear
2017-07-12 14:00:13.078 (rfp) Received 53 bytes of data:.
2017-07-12 14:00:13.078 (rfp) 20 22 30 22 2c 20 22 73 75 62 54 79 70 65 4d 65 61 6e 69 6e ."0",."subTypeMeanin
2017-07-12 14:00:13.078 (rfp) 67 22 3a 20 22 4f 46 46 22 2c 20 22 69 64 4d 65 61 6e 69 6e g":."OFF",."idMeanin
2017-07-12 14:00:13.078 (rfp) 67 22 3a 20 22 41 31 22 7d 7d 7d 0a 0d .. .. .. .. .. .. .. g":."A1"}}}..
2017-07-12 14:00:13.078 (rfp) Calling message handler 'onMessage'.
2017-07-12 14:00:13.079 (rfp) ZIA33{ "frame" :{"header": {"frameType": "0", "cluster": "0", "dataFlag": "0", "rfLevel": "-51", "floorNoise": "-103", "rfQuality": "10", "protocol": "2", "protocolMeaning": "VISONIC", "infoType": "2", "frequency": "433920"},"infos": {"subType": "0", "subTypeMeaning": "Detector/Sensor", "id": "335547184", "qualifier": "3", "qualifierMeaning": { "flags": ["Tamper","Alarm"]}}}}
ZIA33{ "frame" :{"header": {"frameType": "0", "cluster": "0", "dataFlag": "0", "rfLevel": "-51", "floorNoise": "-103 "0", "subTypeMeaning": "OFF", "idMeaning": "A1"}}}
2017-07-12 14:00:13.079 (rfp) Error while decoding or reading JSON
2017-07-12 14:00:13.079 (rfp) Debug : Error Decoding/Reading { "frame" :{"header": {"frameType": "0", "cluster": "0", "dataFlag": "0", "rfLevel": "-51", "floorNoise": "-103", "rfQuality": "10", "protocol": "2", "protocolMeaning": "VISONIC", "infoType": "2", "frequency": "433920"},"infos": {"subType": "0", "subTypeMeaning": "Detector/Sensor", "id": "335547184", "qualifier": "3", "qualifierMeaning": { "flags": ["Tamper","Alarm"]}}}}
{ "frame" :{"header": {"frameType": "0", "cluster": "0", "dataFlag": "0", "rfLevel": "-51", "floorNoise": "-103 "0", "subTypeMeaning": "OFF", "idMeaning": "A1"}}}
zaraki673 commented 7 years ago

Hi, can you try my last update đź‘Ť https://github.com/sasu-drooz/Domoticz-Rfplayer/commit/2f657dd369071a546ad44c6f0a362861032d3bd5

thks ;)

Quentin-domo commented 7 years ago

Plugin updated, same error

 2017-07-13 01:44:23.583 (rfplayer) Received 372 bytes of data:.
2017-07-13 01:44:23.583 (rfplayer) 5a 49 41 33 33 7b 20 22 66 72 61 6d 65 22 20 3a 7b 22 68 65 ZIA33{."frame".:{"he
2017-07-13 01:44:23.583 (rfplayer) 61 64 65 72 22 3a 20 7b 22 66 72 61 6d 65 54 79 70 65 22 3a ader":.{"frameType":
2017-07-13 01:44:23.583 (rfplayer) 20 22 30 22 2c 20 22 63 6c 75 73 74 65 72 22 3a 20 22 30 22 ."0",."cluster":."0"
2017-07-13 01:44:23.583 (rfplayer) 2c 20 22 64 61 74 61 46 6c 61 67 22 3a 20 22 30 22 2c 20 22 ,."dataFlag":."0",."
2017-07-13 01:44:23.583 (rfplayer) 72 66 4c 65 76 65 6c 22 3a 20 22 2d 35 35 22 2c 20 22 66 6c rfLevel":."-55",."fl
2017-07-13 01:44:23.583 (rfplayer) 6f 6f 72 4e 6f 69 73 65 22 3a 20 22 2d 31 30 32 22 2c 20 22 oorNoise":."-102",."
2017-07-13 01:44:23.583 (rfplayer) 72 66 51 75 61 6c 69 74 79 22 3a 20 22 31 30 22 2c 20 22 70 rfQuality":."10",."p
2017-07-13 01:44:23.583 (rfplayer) 72 6f 74 6f 63 6f 6c 22 3a 20 22 32 22 2c 20 22 70 72 6f 74 rotocol":."2",."prot
2017-07-13 01:44:23.583 (rfplayer) 6f 63 6f 6c 4d 65 61 6e 69 6e 67 22 3a 20 22 56 49 53 4f 4e ocolMeaning":."VISON
2017-07-13 01:44:23.584 (rfplayer) 49 43 22 2c 20 22 69 6e 66 6f 54 79 70 65 22 3a 20 22 32 22 IC",."infoType":."2"
2017-07-13 01:44:23.584 (rfplayer) 2c 20 22 66 72 65 71 75 65 6e 63 79 22 3a 20 22 34 33 33 39 ,."frequency":."4339
2017-07-13 01:44:23.584 (rfplayer) 32 30 22 7d 2c 22 69 6e 66 6f 73 22 3a 20 7b 22 73 75 62 54 20"},"infos":.{"subT
2017-07-13 01:44:23.584 (rfplayer) 79 70 65 22 3a 20 22 30 22 2c 20 22 73 75 62 54 79 70 65 4d ype":."0",."subTypeM
2017-07-13 01:44:23.584 (rfplayer) 65 61 6e 69 6e 67 22 3a 20 22 44 65 74 65 63 74 6f 72 2f 53 eaning":."Detector/S
2017-07-13 01:44:23.584 (rfplayer) 65 6e 73 6f 72 22 2c 20 22 69 64 22 3a 20 22 33 33 35 35 34 ensor",."id":."33554
2017-07-13 01:44:23.584 (rfplayer) 37 31 38 34 22 2c 20 22 71 75 61 6c 69 66 69 65 72 22 3a 20 7184",."qualifier":.
2017-07-13 01:44:23.584 (rfplayer) 22 31 22 2c 20 22 71 75 61 6c 69 66 69 65 72 4d 65 61 6e 69 "1",."qualifierMeani
2017-07-13 01:44:23.584 (rfplayer) 6e 67 22 3a 20 7b 20 22 66 6c 61 67 73 22 3a 20 5b 22 54 61 ng":.{."flags":.["Ta
2017-07-13 01:44:23.584 (rfplayer) 6d 70 65 72 22 5d 7d 7d 7d 7d 0a 0d .. .. .. .. .. .. .. .. mper"]}}}}..
2017-07-13 01:44:23.585 (rfplayer) Calling message handler 'onMessage'.
2017-07-13 01:44:23.585 (rfplayer) Last Message was 17.499574 seconds ago, Message clear
2017-07-13 01:44:23.585 (rfplayer) ZIA33{ "frame" :{"header": {"frameType": "0", "cluster": "0", "dataFlag": "0", "rfLevel": "-55", "floorNoise": "-102", "rfQuality": "10", "protocol": "2", "protocolMeaning": "VISONIC", "infoType": "2", "frequency": "433920"},"infos": {"subType": "0", "subTypeMeaning": "Detector/Sensor", "id": "335547184", "qualifier": "1", "qualifierMeaning": { "flags": ["Tamper"]}}}}
2017-07-13 01:44:23.586 (rfplayer) infoType : 2
2017-07-13 01:44:23.586 (rfplayer) Error while decoding or reading JSON
2017-07-13 01:44:23.586 (rfplayer) Debug : Error Decoding/Reading { "frame" :{"header": {"frameType": "0", "cluster": "0", "dataFlag": "0", "rfLevel": "-55", "floorNoise": "-102", "rfQuality": "10", "protocol": "2", "protocolMeaning": "VISONIC", "infoType": "2", "frequency": "433920"},"infos": {"subType": "0", "subTypeMeaning": "Detector/Sensor", "id": "335547184", "qualifier": "1", "qualifierMeaning": { "flags": ["Tamper"]}}}}
Quentin-domo commented 7 years ago

avec le code ci-dessous, plus d'erreur de décodage, et le device est ajouté .. et tous les autres de la maison :)
Mais la gestion des états semble très mal gérée coté domoticz.. et mon extraction du deviceid n'est surement pas correct vu le nombre de devices trouvés.

                ##############################################################################################################
                #####################################Frame infoType 2                                   Visonic###############################
                #############http://www.el-sys.com.ua/wp-content/uploads/MCR-300_UART_DE3140U0.pdf ###########################
                ###########http://cpansearch.perl.org/src/BEANZ/Device-RFXCOM-1.142010/lib/Device/RFXCOM/Decoder/Visonic.pm ##
                #############https://forum.arduino.cc/index.php?topic=289554.0 ###############################################
                ##############################################################################################################
                if infoType == "2":
                        protocol = DecData['frame']['header']['protocol']
                        frequency = DecData['frame']['header']['frequency']
                        SubType = DecData['frame']['infos']['subType']
                        if protocol == "2":
                                id_= DecData['frame']['infos']['id']
                                try:
                                        qualifier = list(bin(DecData['frame']['infos']['qualifier'])[2:])
                                except:
                                        Domoticz.Debug("Alternative Decoding requiered")
                                        #extract device id (experimental - no source)
                                        _idcode = DecData['frame']['infos']['id']
                                        _idb= bin(int(_idcode))
                                        id = int(_idb[:-26],2)
                                        Domoticz.Debug("device id = " + str(id))
                                        #Extract Values
                                        _qualifiercode = DecData['frame']['infos']['qualifier']
                                        _qualifiermeaning = ", ".join(list(DecData['frame']['infos']['qualifierMeaning']['flags']))
                                        Domoticz.Debug("qualifierCode = " + _qualifiercode + ", qualifierMeaning = " + _qualifiermeaning)
                                        #Convert
                                        qualifier = ["0","0","0"]
                                        if "Tamper" in _qualifiermeaning : qualifier[0] = "1"
                                        if "Alarm" in _qualifiermeaning : qualifier[1] = "1"
                                        if "Battery" in _qualifiermeaning : qualifier[2] = "1"
                                        Domoticz.Debug("converted to : " + str(qualifier)[1:-1])
                                Domoticz.Debug("id : " + str(id) + " subType :" + str(SubType))
                        elif protocol == "3" :
                                id = DecData['frame']['infos']['id']
                                Domoticz.Debug("id : " + id + " subType :" + SubType)
                        ##############################################################################################################
                        if SubType == "0" and protocol == "2": # Detector/sensor visonic
                                Tamper=qualifier[0]
                                Alarm=qualifier[1]
                                Battery=qualifier[2]
                                if Tamper=="0" and Alarm=="0" :
                                        status=0
                                if Tamper=="1" and Alarm=="0" :
                                        status=10
                                if Tamper=="0" and Alarm=="1" :
                                        status=20
                                if Tamper=="1" and Alarm=="1" :
                                        status=30
                                if Battery=="0" :
                                        Battery=100
                                else :
                                        Battery=5
                                Options = {"infoType":infoType, "id": str(id), "protocol": str(protocol), "subType": str(SubType), "LevelActions": "||||", "LevelNames": "Off|Tamper|Alarm|Tamper+Alarm", "LevelOffHidden": "False", "SelectorStyle": "0"}
                                Domoticz.Debug("Options to find or set : " + str(Options))
                                for x in Devices:
                                        if Devices[x].Options == Options :
                                                IsCreated = True
                                                Domoticz.Log("Devices already exist. Unit=" + str(x))
                                                Domoticz.Debug("Options find in DB: " + str(Devices[x].Options) + " for devices unit " + str(x))
                                                nbrdevices=x
                                        if IsCreated == False :
                                                nbrdevices=x
                                if IsCreated == False and Parameters["Mode4"] == "True":
                                        Domoticz.Debug("Adding..")
                                        nbrdevices=nbrdevices+1
                                        Domoticz.Debug("device should be added, total device : " + str(nbrdevices))
                                        #Options = {"LevelActions": "||||", "LevelNames": "Off|Tamper|Alarm|Tamper+Alarm", "LevelOffHidden": "False", "SelectorStyle": "0"}
                                        Domoticz.Device(Name=protocol + " - " + str(id),  Unit=nbrdevices, Type=16, Switchtype=0, Options=Options).Create()
                                        Domoticz.Debug("Device created")
                                        Devices[nbrdevices].Update(nValue =0, sValue = "on", Options = Options)
                                elif IsCreated == True :
                                        Devices[nbrdevices].Update(nValue =0,sValue = str(status), BatteryLevel = Battery)
 2017-07-14 18:23:33.140 (rfplayerdev12) Calling message handler 'onMessage'.
2017-07-14 18:23:33.141 (rfplayerdev12) ZIA33{ "frame" :{"header": {"frameType": "0", "cluster": "0", "dataFlag": "0", "rfLevel": "-41", "floorNoise": "-102", "rfQuality": "10", "protocol": "2", "protocolMeaning": "VISONIC", "infoType": "2", "frequency": "433920"},"infos": {"subType": "0", "subTypeMeaning": "Detector/Sensor", "id": "335547184", "qualifier": "3", "qualifierMeaning": { "flags": ["Tamper","Alarm"]}}}}
2017-07-14 18:23:33.141 (rfplayerdev12) infoType : 2
2017-07-14 18:23:33.141 (rfplayerdev12) Alternative Decoding requiered
2017-07-14 18:23:33.141 (rfplayerdev12) device id = 5
2017-07-14 18:23:33.141 (rfplayerdev12) qualifierCode = 3, qualifierMeaning = Tamper, Alarm
2017-07-14 18:23:33.141 (rfplayerdev12) converted to : '1', '1', '0'
2017-07-14 18:23:33.141 (rfplayerdev12) id : 5 subType :0
2017-07-14 18:23:33.142 (rfplayerdev12) Options to find or set : {'LevelActions': '||||', 'subType': '0', 'infoType': '2', 'SelectorStyle': '0', 'LevelNames': 'Off|Tamper|Alarm|Tamper+Alarm', 'protocol': '2', 'id': '5', 'LevelOffHidden': 'False'}
2017-07-14 18:23:33.142 (rfplayerdev12) Devices already exist. Unit=3
2017-07-14 18:23:33.142 (rfplayerdev12) Options find in DB: {'LevelActions': '||||', 'subType': '0', 'infoType': '2', 'LevelNames': 'Off|Tamper|Alarm|Tamper+Alarm', 'SelectorStyle': '0', 'protocol': '2', 'id': '5', 'LevelOffHidden': 'False'} for devices unit 3
2017-07-14 18:23:33.142 (rfplayerdev12 - 2 - 5) Updating device from 0:'20' to have values 0:'30'. 

visonic-test1

zaraki673 commented 7 years ago

correction apporté : 9dba132

;)

zaraki673 commented 7 years ago

je clos, si encore un problème on réouvre