sasu-drooz / Domoticz-Rfplayer

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

Pb création manuelle "X2D 433 Operating_Mode" et "X2D 868 Operating_Mode" #33

Closed ogulf closed 7 years ago

ogulf commented 7 years ago

Le plugin différencie les matériels X2D avec une notion de "fonction" (=2 ou différent de 2) : en création automatique c'est parfait.

Mais en création manuelle il n'y a pas cette différence, du coup les Operating_Mode des deux fréquences sont mal créés et ne sont pas utilisables.

Ne sachant pas comment générer un Pull Requests, je propose ici les modifications que j'ai testées chez moi et qui fonctionnent sur la version V1.0.6 du plugin. Elles sont identifiées par # Modif ogulf

Est-il possible de les reporter dans une prochaine version du plugin ?

class BasePlugin:
...
    def onStart(self):
    ...
        if Parameters["Mode5"] != "False":
        ...
             if infoType == "10" and Parameters["Mode5"] =="6":
                     Options = {"infoType":infoType, "id": str(id), "area": str(Area), "function": "2", "protocol": str(protocol), "subType": "62", "frequency":"433920", "LevelActions": "|||||||||", "LevelNames": "Off|Eco|Moderat|Medio|Comfort|Stop|Out of frost|Special|Auto|Centralised", "LevelOffHidden": "True", "SelectorStyle": "0"}
                     stype=62    # Modif ogulf
                     function=2  # Modif ogulf
             if infoType == "10" and Parameters["Mode5"] =="61":
                     Options = {"infoType":infoType, "id": str(id), "area": str(Area), "function": "1", "protocol": str(protocol), "subType": "0", "frequency":"433920"}
                     stype=0
                     function=1  # Modif ogulf
             if infoType == "10" and Parameters["Mode5"] =="62":
                     Options = {"infoType":infoType, "id": str(id), "area": str(Area), "function": "12", "protocol": str(protocol), "subType": "0", "frequency":"433920"}
                     stype=0
                     function=12  # Modif ogulf
             if infoType == "10" and Parameters["Mode5"] =="63":
                     Options = {"infoType":infoType, "id": str(id), "area": str(Area), "function": "26", "protocol": str(protocol), "subType": "0", "frequency":"433920"}
                     stype=0
                     function=26  # Modif ogulf
             if infoType == "10" and Parameters["Mode5"] =="7":
                     Options = {"infoType":infoType, "id": str(id), "area": str(Area), "function": "2", "protocol": str(protocol), "subType": "62", "frequency":"868950", "LevelActions": "|||||||||", "LevelNames": "Off|Eco|Moderat|Medio|Comfort|Stop|Out of frost|Special|Auto|Centralised", "LevelOffHidden": "True", "SelectorStyle": "0"}
                     stype=62    # Modif ogulf
                     function=2  # Modif ogulf
             if infoType == "10" and Parameters["Mode5"] =="71":
                     Options = {"infoType":infoType, "id": str(id), "area": str(Area), "function": "1", "protocol": str(protocol), "subType": "0", "frequency":"868950"}
                     stype=0
                     function=1  # Modif ogulf
             if infoType == "10" and Parameters["Mode5"] =="72":
                     Options = {"infoType":infoType, "id": str(id), "area": str(Area), "function": "12", "protocol": str(protocol), "subType": "0", "frequency":"868950"}
                     stype=0
                     function=12  # Modif ogulf
             if infoType == "10" and Parameters["Mode5"] =="73":
                     Options = {"infoType":infoType, "id": str(id), "area": str(Area), "function": "26", "protocol": str(protocol), "subType": "0", "frequency":"868950"}
                     stype=0
                     function=26  # Modif ogulf
             if infoType == "11" :
                     Options = {"infoType":infoType, "id": str(id), "protocol": str(protocol), "subType": "1", "LevelActions": "|||", "LevelNames": "Off|On|Stop", "LevelOffHidden": "False", "SelectorStyle": "0"}
                     stype=18
             IsCreated=False
             x=0
             nbrdevices=1
             Domoticz.Debug("Options to find or set : " + str(Options))
             #########check if devices exist ####################
             #########check if devices exist ####################
             for x in Devices:
                     #JJE - start
                     DOptions = Devices[x].Options
            #                       if Devices[x].Options == Options :  # see https://stackoverflow.com/questions/5352546/extract-subset-of-key-value-pairs-from-python-dictionary-object
                     if {k: DOptions.get(k, None) for k in ('id', 'protocol', 'infoType')} == {k: Options.get(k, None) for k in ('id', 'protocol', 'infoType')}:
                     #JJE - end
                             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
             ########### create device if not find ###############
             if IsCreated == False :
                     nbrdevices=nbrdevices+1
                     if infoType =="3" :
                             Domoticz.Device(Name="RTS - " + Parameters["Mode2"],  Unit=nbrdevices, TypeName="Selector Switch", Switchtype=18, Image=12, Options=Options).Create()
                     # Modif ogulf - start
                     elif infoType=="10" and function==2 :
                             Domoticz.Device(Name="Manual Swith - " + Parameters["Mode2"],  Unit=nbrdevices, TypeName="Selector Switch", Switchtype=18, Image=12, Options=Options).Create()
                     # Modif ogulf - end
                     else :
                             Domoticz.Device(Name="Manual Switch - " + Parameters["Mode2"], Unit=nbrdevices, Type=16, Switchtype=stype).Create()
                     Devices[nbrdevices].Update(nValue =0,sValue = "0",Options = Options)
             Domoticz.Log("Plugin has " + str(len(Devices)) + " devices associated with it.")
            DumpConfigToLog()
            #Domoticz.Transport("Serial", Parameters["SerialPort"], Baud=115200)
            #Domoticz.Protocol("None")  # None,XML,JSON,HTTP
            #Domoticz.Connect()
            SerialConn = Domoticz.Connection(Name="RfP1000", Transport="Serial", Protocol="None", Address=Parameters["SerialPort"], Baud=115200)
            SerialConn.Connect()
            ReqRcv=''
            return
ogulf commented 7 years ago

Corrigé avec le PullRequests #34