Changes in / [1:3]


Ignore:
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • /D_EnoceanRPS.json

    r1 r3  
    77    "imgIconMax": "", 
    88    "halloIconsDir": "pics\/hallo", 
     9    "inScene": "0", 
    910    "DisplayStatus": { 
    1011        "Service": "urn:upnp-esweb-nl:serviceId:EnoceanRPS1", 
     
    1617        "doc_version": 1, 
    1718        "doc_platform": 0, 
    18         "doc_page": "sensors"  
    19     },   
     19        "doc_page": "sensors" 
     20    }, 
    2021    "Tabs": [ 
    2122        { 
    2223            "Label": { 
    2324                "lang_tag": "tabname_control", 
    24                 "text": "Control"  
     25                "text": "Control" 
    2526            }, 
    2627            "Position": "0", 
    2728            "TabType": "flash", 
    28                 "ControlGroup":[ 
    29                     { 
    30                         "id":"1", 
    31                         "type":"info" 
    32                     } 
    33                 ], 
     29            "SceneGroup": [ 
     30                { 
     31                    "id": "1", 
     32                    "top": "1", 
     33                    "left": "0", 
     34                    "x": "2", 
     35                    "y": "1" 
     36                } 
     37            ], 
     38            "ControlGroup":[ 
     39                { 
     40                    "id":"1", 
     41                    "scenegroup": "1" 
     42                } 
     43            ], 
    3444            "Control": [ 
    3545                { 
    36                             "ControlGroup":"1",  
    37                             "ControlPair":"1", 
    38                             "ControlHeader":"1", 
     46                  "ControlGroup":"1", 
    3947                  "ControlType": "label", 
    4048                  "Label": { 
    4149                      "lang_tag": "lblButton", 
    42                       "text": "Last button:"  
     50                      "text": "Last button:" 
    4351                  }, 
    4452                  "Display": { 
     
    4654                      "Left": 50, 
    4755                      "Width": 75, 
    48                       "Height": 20  
    49                   }  
     56                      "Height": 20 
     57                  } 
    5058                }, 
    5159                { 
    52                         "ControlGroup":"1", 
    53                             "ControlPair":"1", 
    54                             "ControlHeader":"1", 
     60                  "ControlGroup":"1", 
    5561                  "ControlType": "variable", 
     62                  "left": "1", 
    5663                  "Display": { 
    5764                      "Service": "urn:upnp-esweb-nl:serviceId:EnoceanRPS1", 
     
    6067                      "Left": 145, 
    6168                      "Width": 40, 
    62                       "Height": 20  
    63                   }  
    64                 } 
    65             ]  
     69                      "Height": 20 
     70                  } 
     71                } 
     72            ] 
    6673        }, 
    6774        { 
    6875            "Label": { 
    6976                "lang_tag": "advanced", 
    70                 "text": "Advanced"  
     77                "text": "Advanced" 
    7178            }, 
    7279            "Position": "2", 
    7380            "TabType": "javascript", 
    7481            "ScriptName": "shared.js", 
    75             "Function": "advanced_device"  
    76         }, 
    77         { 
    78                     "Label": { 
    79                         "lang_tag": "logs", 
    80                         "text": "Logs"  
    81                     }, 
    82                     "Position": "4", 
    83                     "TabType": "javascript", 
    84                     "ScriptName": "shared.js", 
    85                     "Function": "device_logs"  
    86         }, 
    87         { 
    88                     "Label": { 
    89                         "lang_tag": "notifications", 
    90                         "text": "Notifications"  
    91                     }, 
    92                     "Position": "5", 
    93                     "TabType": "javascript", 
    94                     "ScriptName": "shared.js", 
    95                     "Function": "device_notifications"  
    96         }  
     82            "Function": "advanced_device" 
     83        }, 
     84        { 
     85            "Label": { 
     86                "lang_tag": "logs", 
     87                "text": "Logs" 
     88            }, 
     89            "Position": "4", 
     90            "TabType": "javascript", 
     91            "ScriptName": "shared.js", 
     92            "Function": "device_logs" 
     93        }, 
     94        { 
     95            "Label": { 
     96                "lang_tag": "notifications", 
     97                "text": "Notifications" 
     98            }, 
     99            "Position": "5", 
     100            "TabType": "javascript", 
     101            "ScriptName": "shared.js", 
     102            "Function": "device_notifications" 
     103        } 
    97104    ], 
    98105    "sceneList": { 
     
    103110                "action": "SetButton", 
    104111                "arguments": { 
    105                     "newButtonValue": "A0"  
     112                    "newButtonValue": "A0" 
    106113                }, 
    107114                "display": { 
     
    109116                    "variable": "Button", 
    110117                    "value": "A0" 
    111                 }  
     118                } 
    112119            } 
    113         }  
     120        } 
    114121    }, 
    115     "eventList": { 
    116         "event_1": { 
    117             "label": "A button is pressed", 
     122    "eventList2": [ 
     123        { 
     124            "id": 1, 
     125            "label": { 
     126                "lang_tag": "button_is_pressed", 
     127                "text": "A button is pressed" 
     128            }, 
    118129            "serviceId": "urn:upnp-esweb-nl:serviceId:EnoceanRPS1", 
    119             "argumentList": { 
    120                 "argument_1": { 
     130            "argumentList": [ 
     131                { 
     132                    "id": 1, 
    121133                    "dataType": "string", 
    122134                    "defaultValue": "", 
    123                             "allowedValueList" :  
    124                             { 
    125                                 "A1":"A1", "A0":"A0", 
    126                                 "B1":"B1", "B0":"B0", 
    127                                 "C1":"C1", "C0":"C0", 
    128                                 "D1":"D1", "D0":"D0" 
    129                             }, 
     135                    "allowedValueList": [ 
     136                        { 
     137                            "A1": "A1", 
     138                            "HumanFriendlyText": { 
     139                                "lang_tag": "hft_is_pressed", 
     140                                "text": "_DEVICE_NAME_: A1 is pressed" 
     141                            } 
     142                        }, 
     143                        { 
     144                            "A0": "A0", 
     145                            "HumanFriendlyText": { 
     146                                "lang_tag": "hft_is_pressed", 
     147                                "text": "_DEVICE_NAME_: A0 is pressed" 
     148                            } 
     149                        }, 
     150                        { 
     151                            "B1": "B1", 
     152                            "HumanFriendlyText": { 
     153                                "lang_tag": "hft_is_pressed", 
     154                                "text": "_DEVICE_NAME_: B1 is pressed" 
     155                            } 
     156                        }, 
     157                        { 
     158                            "B0": "B0", 
     159                            "HumanFriendlyText": { 
     160                                "lang_tag": "hft_is_pressed", 
     161                                "text": "_DEVICE_NAME_: B0 is pressed" 
     162                            } 
     163                        }, 
     164                        { 
     165                            "C1": "C1", 
     166                            "HumanFriendlyText": { 
     167                                "lang_tag": "hft_is_pressed", 
     168                                "text": "_DEVICE_NAME_: C1 is pressed" 
     169                            } 
     170                        }, 
     171                        { 
     172                            "C0": "C0", 
     173                            "HumanFriendlyText": { 
     174                                "lang_tag": "hft_is_pressed", 
     175                                "text": "_DEVICE_NAME_: C0 is pressed" 
     176                            } 
     177                        }, 
     178                        { 
     179                            "D1": "D1", 
     180                            "HumanFriendlyText": { 
     181                                "lang_tag": "hft_is_pressed", 
     182                                "text": "_DEVICE_NAME_: D1 is pressed" 
     183                            } 
     184                        }, 
     185                        { 
     186                            "D0": "D0", 
     187                            "HumanFriendlyText": { 
     188                                "lang_tag": "hft_is_pressed", 
     189                                "text": "_DEVICE_NAME_: D0 is pressed" 
     190                            } 
     191                        } 
     192                    ], 
    130193                    "name": "Button", 
    131194                    "comparisson": "=", 
    132                     "prefix": "Button", 
    133                     "suffix": ""  
    134                 }  
    135             }  
    136         }, 
    137         "event_2": { 
    138             "label": "A button is released", 
     195                    "prefix": { 
     196                        "lang_tag": "button", 
     197                        "text": "What button?" 
     198                    }, 
     199                    "suffix": {} 
     200                } 
     201            ] 
     202        }, 
     203        { 
     204            "id": 2, 
     205            "label": { 
     206                "lang_tag": "button_is_released", 
     207                "text": "A button is released" 
     208            }, 
    139209            "serviceId": "urn:upnp-esweb-nl:serviceId:EnoceanRPS1", 
    140210            "serviceStateTable": { 
    141211                "Released": { 
    142212                    "value": "1", 
    143                     "comparisson": "="  
    144                 }  
    145             }, 
    146             "argumentList": { 
    147                 "argument_1": { 
     213                    "comparisson": "=" 
     214                } 
     215            }, 
     216            "argumentList": [ 
     217                { 
     218                    "id": 1, 
    148219                    "dataType": "boolean", 
    149                     "allowedValueList": { 
    150                         "Yes": "1", 
    151                         "No": "0"  
    152                     }, 
     220                    "allowedValueList": [ 
     221                        { 
     222                            "Yes": "1", 
     223                            "HumanFriendlyText": { 
     224                                "lang_tag": "hft_is_released", 
     225                                "text": "_DEVICE_NAME_: Button is released" 
     226                            } 
     227                        }, 
     228                        { 
     229                            "No": "0", 
     230                            "HumanFriendlyText": { 
     231                                "lang_tag": "hft_is_not_released", 
     232                                "text": "_DEVICE_NAME_: Button is not released" 
     233                            } 
     234                        } 
     235                    ], 
    153236                    "name": "Released", 
    154237                    "comparisson": "=", 
    155                     "prefix": "Released", 
    156                     "suffix": " "  
    157                 }  
    158             }  
    159         }  
    160     }, 
     238                    "prefix": {}, 
     239                    "suffix": {} 
     240                } 
     241            ] 
     242        } 
     243    ], 
    161244    "DeviceType": "urn:schemas-esweb-nl:device:EnoceanRPS:1", 
    162     "device_type": "urn:schemas-esweb-nl:device:EnoceanRPS:1"  
     245    "device_type": "urn:schemas-esweb-nl:device:EnoceanRPS:1" 
    163246} 
  • /I_Enocean.xml

    r1 r3  
    55  </settings> 
    66  <functions> 
    7      
    8       -- EnOcean Message Structure Constants 
     7   
     8    -- EnOcean Message Structure Constants 
    99    EO_HSEQ = 3 
    1010    EO_ORG = 4 
     
    1818    EO_ID0 = 12 
    1919    EO_Status = 13 
    20      
    21       local ipAddress 
     20   
     21    local ipAddress 
    2222    local ipPort 
    2323    local buffer = "" 
    2424     
    2525    bitw = require("bit") 
    26        
     26     
    2727    -- 
    2828    -- Used for performance timing hooks in the callouts 
     
    3232     
    3333    -- Thanks to guessed for this snippet. 
    34       function findChild(parentDevice, label) 
    35         for k, v in pairs(luup.devices) do 
    36           if (v.device_num_parent == parentDevice and v.id == label) then 
    37             return k 
    38           end 
    39         end 
    40      
    41           -- Dump a copy of the Global Module list for debugging purposes. 
    42             luup.log("findChild cannot find parentDevice: " .. tostring(parentDevice) .. " label: " .. label) 
    43             for k, v in pairs(luup.devices) do 
     34    function findChild(parentDevice, label) 
     35      for k, v in pairs(luup.devices) do 
     36        if (v.device_num_parent == parentDevice and v.id == label) then 
     37          return k 
     38        end 
     39      end 
     40   
     41      -- Dump a copy of the Global Module list for debugging purposes. 
     42      luup.log("findChild cannot find parentDevice: " .. tostring(parentDevice) .. " label: " .. label) 
     43      for k, v in pairs(luup.devices) do 
    4444        luup.log("Device Number: " .. k .. 
    45                        " v.device_type: " .. tostring(v.device_type) .. 
    46                        " v.device_num_parent: " .. tostring(v.device_num_parent) .. 
    47                        " v.id: " .. tostring(v.id) 
    48               ) 
    49             end  
    50       end 
     45                 " v.device_type: " .. tostring(v.device_type) .. 
     46                 " v.device_num_parent: " .. tostring(v.device_num_parent) .. 
     47                 " v.id: " .. tostring(v.id) 
     48        ) 
     49      end  
     50    end 
    5151 
    5252    function mainStartup(lul_device) 
    53         PARENT_DEVICE = lul_device 
    54         Enocean_Devices_1BS = {} 
    55         Enocean_Devices_RPS = {} 
    56         Enocean_Count_1BS = 0 
    57         Enocean_Count_RPS = 0 
     53      PARENT_DEVICE = lul_device 
     54      Enocean_Devices_1BS = {} 
     55      Enocean_Devices_RPS = {} 
     56      Enocean_Count_1BS = 0 
     57      Enocean_Count_RPS = 0 
    5858 
    5959      luup.log("Starting Enocean device: " .. tostring(lul_device)) 
     
    6565      end 
    6666 
    67         for k, v in pairs(luup.devices) do 
    68           if (v.device_num_parent == lul_device) then 
    69             luup.log( "Found child device, lets save! id " .. tostring(v.id) .. " device " .. tostring(v.device_type)) 
    70                    
    71             if (tostring(v.device_type) == "urn:schemas-micasaverde-com:device:DoorSensor:1") then 
    72               Enocean_Count_1BS = Enocean_Count_1BS + 1 
    73               Enocean_Devices_1BS[Enocean_Count_1BS] = v.id 
    74             end 
    75             if (tostring(v.device_type) == "urn:schemas-esweb-nl:device:EnoceanRPS:1") then 
     67      for k, v in pairs(luup.devices) do 
     68        if (v.device_num_parent == lul_device) then 
     69          luup.log( "Found child device, lets save! id " .. tostring(v.id) .. " device " .. tostring(v.device_type)) 
     70           
     71          if (tostring(v.device_type) == "urn:schemas-micasaverde-com:device:DoorSensor:1") then 
     72            Enocean_Count_1BS = Enocean_Count_1BS + 1 
     73            Enocean_Devices_1BS[Enocean_Count_1BS] = v.id 
     74          end 
     75          if (tostring(v.device_type) == "urn:schemas-esweb-nl:device:EnoceanRPS:1") then 
    7676            Enocean_Count_RPS = Enocean_Count_RPS + 1 
    7777            Enocean_Devices_RPS[Enocean_Count_RPS] = v.id 
    78             end 
    79           end 
    80         end 
    81          
    82         ipAddress = device.ip 
    83          
     78          end 
     79        end 
     80      end 
     81       
     82      ipAddress = device.ip 
     83       
    8484      local portList = luup.variable_get("urn:upnp-esweb-nl:serviceId:Enocean1", "portList", lul_device) 
    8585      if ((portList or "") == "") then 
     
    8888      elseif (portList:find("%d") == nil) then 
    8989          return false, "The Port parameter must be of the form nnnn.  eg. 1470" 
    90       end        
    91          
    92         ipPort = portList 
     90      end      
     91       
     92      ipPort = portList 
    9393 
    9494      luup.log("open socket for read " .. ipAddress .. " port " .. ipPort ) 
    9595      luup.io.open(lul_device, ipAddress, ipPort) 
    9696 
    97         return true, "ok", "enocean" 
    98     end 
    99  
    100  
    101       function sendData( dataBuf ) 
    102           luup.log("Sending data " .. dataBuf ) 
    103          
    104           luup.io.write(dataBuf) 
    105       end 
    106  
    107       function processData( dataBuf ) 
    108      
    109           local EO_ID = getEnoceanID( dataBuf ) 
     97      return true, "ok", "enocean" 
     98    end 
     99 
     100 
     101    function sendData( dataBuf ) 
     102      luup.log("Sending data " .. dataBuf ) 
     103     
     104      luup.io.write(dataBuf) 
     105    end 
     106 
     107    function processData( dataBuf ) 
     108   
     109      local EO_ID = getEnoceanID( dataBuf ) 
    110110 
    111111      luup.log("Received data " .. EO_ID .. " " .. getEnoceanMsg( dataBuf ) ) 
    112          
    113           local lsMsgT = getMsgType( dataBuf) 
    114  
    115         local EO_DEV = findChild(PARENT_DEVICE, EO_ID ) 
    116          
    117         if EO_DEV == nil then 
    118         luup.log( "device not found..." )    
     112     
     113      local lsMsgT = getMsgType( dataBuf) 
     114 
     115      local EO_DEV = findChild(PARENT_DEVICE, EO_ID ) 
     116       
     117      if EO_DEV == nil then 
     118        luup.log( "device not found..." )  
    119119         
    120           local child_devices = luup.chdev.start(PARENT_DEVICE);     
    121  
    122             for teller = 1, Enocean_Count_1BS do 
     120        local child_devices = luup.chdev.start(PARENT_DEVICE);   
     121 
     122        for teller = 1, Enocean_Count_1BS do 
    123123          luup.chdev.append(PARENT_DEVICE, child_devices, Enocean_Devices_1BS[teller], "Enocean 1BS Sensor #" .. Enocean_Devices_1BS[teller] ,  
    124124            "urn:schemas-micasaverde-com:device:DoorSensor:1","D_DoorSensor1.xml","","",false) 
    125             end 
    126             for teller = 1, Enocean_Count_RPS do 
     125        end 
     126        for teller = 1, Enocean_Count_RPS do 
    127127          luup.chdev.append(PARENT_DEVICE, child_devices, Enocean_Devices_RPS[teller], "Enocean RPS Remote #" .. Enocean_Devices_RPS[teller] ,  
    128128            "urn:schemas-esweb-nl:device:EnoceanRPS:1","D_EnoceanRPS.xml","","",false) 
    129             end 
    130              
    131         if lsMsgT == "1BS" then 
    132                 luup.log("EO 1BS ID " .. EO_ID .. " not found. Creating child device.") 
     129        end 
     130         
     131        if lsMsgT == "1BS" then 
     132            luup.log("EO 1BS ID " .. EO_ID .. " not found. Creating child device.") 
    133133            luup.chdev.append(PARENT_DEVICE, child_devices, EO_ID, "Enocean 1BS Sensor #" .. EO_ID ,  
    134134              "urn:schemas-micasaverde-com:device:DoorSensor:1","D_DoorSensor1.xml","","",false) 
    135             Enocean_Count_1BS = Enocean_Count_1BS + 1 
    136             Enocean_Devices_1BS[Enocean_Count_1BS] = EO_ID 
    137         end 
    138  
    139         if lsMsgT == "RPS" then 
    140                 luup.log("EO RPS ID " .. EO_ID .. " not found. Creating child device.") 
     135            Enocean_Count_1BS = Enocean_Count_1BS + 1 
     136            Enocean_Devices_1BS[Enocean_Count_1BS] = EO_ID 
     137        end 
     138 
     139        if lsMsgT == "RPS" then 
     140            luup.log("EO RPS ID " .. EO_ID .. " not found. Creating child device.") 
    141141            luup.chdev.append(PARENT_DEVICE, child_devices, EO_ID, "Enocean RPS Remote #" .. EO_ID ,  
    142142              "urn:schemas-esweb-nl:device:EnoceanRPS:1","D_EnoceanRPS.xml","","",false) 
    143             Enocean_Count_RPS = Enocean_Count_RPS + 1 
    144             Enocean_Devices_RPS[Enocean_Count_RPS] = EO_ID 
    145             end 
    146  
    147               luup.chdev.sync(PARENT_DEVICE, child_devices) 
    148  
    149               EO_DEV = findChild(PARENT_DEVICE, EO_ID ) 
    150              
    151         end 
     143            Enocean_Count_RPS = Enocean_Count_RPS + 1 
     144            Enocean_Devices_RPS[Enocean_Count_RPS] = EO_ID 
     145        end 
     146 
     147        luup.chdev.sync(PARENT_DEVICE, child_devices) 
     148 
     149        EO_DEV = findChild(PARENT_DEVICE, EO_ID ) 
     150         
     151      end 
    152152 
    153153      if EO_DEV ~= nil then 
    154154 
    155           if lsMsgT == "1BS" then 
    156               local TrippedValue = "1"   
    157               if ( get1BSDataContact( dataBuf) ) then TrippedValue = "0" end 
    158             --luup.log( "set tripped value " .. TrippedValue .. " to dev " .. EO_ID )    
     155        if lsMsgT == "1BS" then 
     156          local TrippedValue = "1"   
     157          if ( get1BSDataContact( dataBuf) ) then TrippedValue = "0" end 
     158          --luup.log( "set tripped value " .. TrippedValue .. " to dev " .. EO_ID )  
    159159          luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", TrippedValue, EO_DEV) 
    160160           
    161161        end 
    162162       
    163           if lsMsgT == "RPS" then 
    164          
     163        if lsMsgT == "RPS" then 
     164       
    165165          if (getRPSStatusNU( dataBuf) ) then 
    166                 local lsValue = getRPSButton( dataBuf ) 
    167               local ReleasedValue = "0"  
    168                 --luup.log("Sending button " .. lsValue .. " and releasedvalue " .. ReleasedValue ) 
    169                 luup.variable_set("urn:upnp-esweb-nl:serviceId:EnoceanRPS1", "Button", lsValue, EO_DEV) 
    170                 luup.variable_set("urn:upnp-esweb-nl:serviceId:EnoceanRPS1", "Released", ReleasedValue, EO_DEV) 
    171               else 
    172                 local ReleasedValue = "0"    
    173                 if ( getRPSAction( dataBuf ) == "released" ) then ReleasedValue = "1" end 
    174                 --luup.log("Sending releasedvalue " .. ReleasedValue ) 
    175                 luup.variable_set("urn:upnp-esweb-nl:serviceId:EnoceanRPS1", "Released", ReleasedValue, EO_DEV) 
     166            local lsValue = getRPSButton( dataBuf ) 
     167            local ReleasedValue = "0"  
     168            --luup.log("Sending button " .. lsValue .. " and releasedvalue " .. ReleasedValue ) 
     169            luup.variable_set("urn:upnp-esweb-nl:serviceId:EnoceanRPS1", "Button", lsValue, EO_DEV) 
     170            luup.variable_set("urn:upnp-esweb-nl:serviceId:EnoceanRPS1", "Released", ReleasedValue, EO_DEV) 
     171          else 
     172            local ReleasedValue = "0"  
     173            if ( getRPSAction( dataBuf ) == "released" ) then ReleasedValue = "1" end 
     174            --luup.log("Sending releasedvalue " .. ReleasedValue ) 
     175            luup.variable_set("urn:upnp-esweb-nl:serviceId:EnoceanRPS1", "Released", ReleasedValue, EO_DEV) 
    176176          end 
    177177        end 
    178178      end 
    179179    end 
    180      
     180   
    181181    function formattohex(dataBuf) 
    182           local resultstr = "" 
    183          
    184           if ( dataBuf ~= nil) then 
    185           for teller = 1, string.len(dataBuf) do 
    186               resultstr = resultstr .. string.format("%02X ", string.byte(dataBuf, teller) ) 
    187           end 
    188       end 
    189           -- Received data A5 5A B 5 30 0 0 0 0 15 A5 BB 30 E5 
    190           -- [RPS: ID=00:15:A5:BB, Data=Button A1: pressed 2Button B1, Status=[T21=1, NU=1, RP_COUNTER=0]] 
    191          
    192           return resultstr 
    193       end 
    194      
    195       --Enocean ID is formatted as: 00:15:A5:BB 
    196       function getEnoceanID( dataBuf ) 
    197         local eID = string.format("%02X:%02X:", string.byte(dataBuf, EO_ID3), string.byte(dataBuf, EO_ID2)) 
    198         eID = eID ..    string.format("%02X:%02X", string.byte(dataBuf, EO_ID1), string.byte(dataBuf, EO_ID0) )  
    199         return eID 
    200       end 
    201      
    202       function getEnoceanMsg( dataBuf ) 
    203         local lsMsg = getMsgType( dataBuf) 
    204      
    205         if lsMsg == "RPS" then 
    206           lsMsg = lsMsg .. ": " .. getRPS( dataBuf ) 
    207         end 
    208         if lsMsg == "1BS" then 
    209           lsMsg = lsMsg .. ": " .. get1BS( dataBuf ) 
    210         end 
    211  
    212         return lsMsg 
    213       end 
    214      
    215       function getMsgType(podataBuf) 
    216         local lsMsg = "unknown" 
    217      
    218         if string.byte(podataBuf, EO_ORG) == 5 then 
    219           lsMsg = "RPS" 
    220         end 
    221         if string.byte(podataBuf, EO_ORG) == 6 then 
    222           lsMsg = "1BS" 
    223         end 
    224  
    225         return lsMsg 
    226       end 
    227      
    228       function getRPS( podataBuf ) 
    229           local lsValue = "" 
    230           if (getRPSStatusNU( podataBuf) ) then 
    231           lsValue = "Button " .. getRPSButton( podataBuf ) .. " " .. getRPSAction( podataBuf ) 
    232           else 
    233             lsValue = "Button " .. getRPSAction( podataBuf ) 
    234           end 
    235           return lsValue 
    236       end 
    237  
    238       function get1BS( podataBuf ) 
    239           local lsValue = "Contact open" 
    240  
    241           if get1BSDataContact( podataBuf) then 
    242           lsValue = "Contact closed" 
    243           end 
    244           return lsValue 
    245       end 
    246  
    247       function get1BSDataContact( podataBuf ) 
    248         return (bitw.band( string.byte(podataBuf, EO_DB3), 0x01) > 0)  
    249       end 
    250  
    251  
    252       -- When statusNu = 1 then button pressed and button identified. when 0: released and unknown 
    253       function getRPSStatusNU( podataBuf ) 
    254         return (bitw.band( string.byte(podataBuf, EO_Status), 0x10) > 0) 
    255       end 
    256  
    257      
    258       -- There are four possible buttons: A1, A0, B1, B0 
    259       function getRPSButton( podataBuf ) 
    260         local lsBtn = string.char( 65 + bitw.rshift( string.byte(podataBuf, EO_DB3), 6) ) 
    261         if (bitw.band( string.byte(podataBuf, EO_DB3), 0x20) > 0) then lsBtn = lsBtn .. "0" else lsBtn = lsBtn .. "1" end 
    262         return lsBtn 
    263       end 
    264      
    265       -- Get pressed or released 
    266       function getRPSAction( podataBuf ) 
    267         local lsAction = "released" 
    268         if ( bitw.band( string.byte(podataBuf, EO_DB3), 0x10) > 0) then lsAction = "pressed" end  
    269         return lsAction 
    270       end 
     182      local resultstr = "" 
     183     
     184      if ( dataBuf ~= nil) then 
     185        for teller = 1, string.len(dataBuf) do 
     186          resultstr = resultstr .. string.format("%02X ", string.byte(dataBuf, teller) ) 
     187        end 
     188      end 
     189      -- Received data A5 5A B 5 30 0 0 0 0 15 A5 BB 30 E5 
     190      -- [RPS: ID=00:15:A5:BB, Data=Button A1: pressed 2Button B1, Status=[T21=1, NU=1, RP_COUNTER=0]] 
     191     
     192      return resultstr 
     193    end 
     194   
     195    --Enocean ID is formatted as: 00:15:A5:BB 
     196    function getEnoceanID( dataBuf ) 
     197      local eID = string.format("%02X:%02X:", string.byte(dataBuf, EO_ID3), string.byte(dataBuf, EO_ID2)) 
     198      eID = eID ..  string.format("%02X:%02X", string.byte(dataBuf, EO_ID1), string.byte(dataBuf, EO_ID0) )  
     199      return eID 
     200    end 
     201   
     202    function getEnoceanMsg( dataBuf ) 
     203      local lsMsg = getMsgType( dataBuf) 
     204   
     205      if lsMsg == "RPS" then 
     206        lsMsg = lsMsg .. ": " .. getRPS( dataBuf ) 
     207      end 
     208      if lsMsg == "1BS" then 
     209        lsMsg = lsMsg .. ": " .. get1BS( dataBuf ) 
     210      end 
     211 
     212      return lsMsg 
     213    end 
     214   
     215    function getMsgType(podataBuf) 
     216      local lsMsg = "unknown" 
     217   
     218      if string.byte(podataBuf, EO_ORG) == 5 then 
     219        lsMsg = "RPS" 
     220      end 
     221      if string.byte(podataBuf, EO_ORG) == 6 then 
     222        lsMsg = "1BS" 
     223      end 
     224 
     225      return lsMsg 
     226    end 
     227   
     228    function getRPS( podataBuf ) 
     229      local lsValue = "" 
     230      if (getRPSStatusNU( podataBuf) ) then 
     231        lsValue = "Button " .. getRPSButton( podataBuf ) .. " " .. getRPSAction( podataBuf ) 
     232      else 
     233        lsValue = "Button " .. getRPSAction( podataBuf ) 
     234      end 
     235      return lsValue 
     236    end 
     237 
     238    function get1BS( podataBuf ) 
     239      local lsValue = "Contact open" 
     240 
     241      if get1BSDataContact( podataBuf) then 
     242        lsValue = "Contact closed" 
     243      end 
     244      return lsValue 
     245    end 
     246 
     247    function get1BSDataContact( podataBuf ) 
     248      return (bitw.band( string.byte(podataBuf, EO_DB3), 0x01) > 0)  
     249    end 
     250 
     251 
     252    -- When statusNu = 1 then button pressed and button identified. when 0: released and unknown 
     253    function getRPSStatusNU( podataBuf ) 
     254      return (bitw.band( string.byte(podataBuf, EO_Status), 0x10) > 0) 
     255    end 
     256 
     257   
     258    -- There are four possible buttons: A1, A0, B1, B0 
     259    function getRPSButton( podataBuf ) 
     260      local lsBtn = string.char( 65 + bitw.rshift( string.byte(podataBuf, EO_DB3), 6) ) 
     261      if (bitw.band( string.byte(podataBuf, EO_DB3), 0x20) > 0) then lsBtn = lsBtn .. "0" else lsBtn = lsBtn .. "1" end 
     262      return lsBtn 
     263    end 
     264   
     265    -- Get pressed or released 
     266    function getRPSAction( podataBuf ) 
     267      local lsAction = "released" 
     268      if ( bitw.band( string.byte(podataBuf, EO_DB3), 0x10) > 0) then lsAction = "pressed" end  
     269      return lsAction 
     270    end 
    271271 
    272272 
     
    278278      local duration 
    279279 
    280             if ( string.len(buffer) == 0 ) then 
     280      if ( string.len(buffer) == 0 ) then 
    281281        startTime = socket.gettime() 
    282             else 
     282      else 
    283283        endTime = socket.gettime() 
    284               duration = math.floor((endTime - startTime) * 1000)    
    285               if (duration > 500) then 
    286                 luup.log("timeout on buffer : " .. buffer) 
     284        duration = math.floor((endTime - startTime) * 1000)  
     285        if (duration > 500) then 
     286          luup.log("timeout on buffer : " .. buffer) 
    287287             
    288                 startTime = socket.gettime() 
    289                   buffer = "" 
    290               end    
    291             end 
    292  
    293             buffer = buffer .. data 
    294              
    295             if ( string.len(buffer) == 14 ) then 
     288          startTime = socket.gettime() 
     289          buffer = "" 
     290        end  
     291      end 
     292 
     293      buffer = buffer .. data 
     294       
     295      if ( string.len(buffer) == 14 ) then 
    296296        processData( buffer ) 
    297               buffer = "" 
    298             end 
    299              
     297        buffer = "" 
     298      end 
     299       
    300300    </lua> 
    301301  </incoming> 
     
    303303  <startup>mainStartup</startup> 
    304304  <actionList> 
    305       <action> 
    306         <serviceId>urn:micasaverde-com:serviceId:SecuritySensor1</serviceId> 
    307         <name>GetArmed</name> 
    308         <run> 
    309           luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1","Armed",lul_device) 
    310         </run> 
    311       </action> 
    312       <action> 
    313         <serviceId>urn:micasaverde-com:serviceId:SecuritySensor1</serviceId> 
    314         <name>SetArmed</name> 
    315         <run> 
    316           luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Armed",lul_settings.newArmedValue,lul_device) 
    317         </run> 
    318       </action> 
    319       <action> 
    320         <serviceId>urn:micasaverde-com:serviceId:SecuritySensor1</serviceId> 
    321         <name>GetTripped</name> 
    322         <run> 
    323           luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1","Tripped",lul_device) 
    324         </run> 
    325       </action> 
    326       <action> 
    327         <serviceId>urn:micasaverde-com:serviceId:SecuritySensor1</serviceId> 
    328         <name>SetTripped</name> 
    329         <run> 
    330           luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Tripped",lul_settings.newTrippedValue,lul_device) 
    331         </run> 
    332       </action> 
     305    <action> 
     306      <serviceId>urn:micasaverde-com:serviceId:SecuritySensor1</serviceId> 
     307      <name>GetArmed</name> 
     308      <run> 
     309        luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1","Armed",lul_device) 
     310      </run> 
     311    </action> 
     312    <action> 
     313      <serviceId>urn:micasaverde-com:serviceId:SecuritySensor1</serviceId> 
     314      <name>SetArmed</name> 
     315      <run> 
     316        luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Armed",lul_settings.newArmedValue,lul_device) 
     317      </run> 
     318    </action> 
     319    <action> 
     320      <serviceId>urn:micasaverde-com:serviceId:SecuritySensor1</serviceId> 
     321      <name>GetTripped</name> 
     322      <run> 
     323        luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1","Tripped",lul_device) 
     324      </run> 
     325    </action> 
     326    <action> 
     327      <serviceId>urn:micasaverde-com:serviceId:SecuritySensor1</serviceId> 
     328      <name>SetTripped</name> 
     329      <run> 
     330        luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Tripped",lul_settings.newTrippedValue,lul_device) 
     331      </run> 
     332    </action> 
    333333  </actionList> 
    334334 
  • /D_Enocean.json

    r1 r3  
    77    "imgIconMax": "", 
    88    "halloIconsDir": "pics\/hallo", 
     9    "inScene": "0", 
    910    "DisplayStatus": { 
    1011    }, 
     
    1415        "doc_version": 1, 
    1516        "doc_platform": 0, 
    16         "doc_page": "devices"  
     17        "doc_page": "devices" 
    1718    }, 
    1819    "Tabs": [ 
     
    2021            "Label": { 
    2122                "lang_tag": "tabname_control", 
    22                 "text": "Settings"  
     23                "text": "Settings" 
    2324            }, 
    2425            "Position": "0", 
    2526            "TabType": "flash", 
     27            "SceneGroup":[ 
     28                { 
     29                    "id": "1", 
     30                    "top": "1", 
     31                    "left": "0", 
     32                    "x": "2", 
     33                    "y": "1" 
     34                } 
     35            ], 
    2636            "ControlGroup": [ 
    2737                { 
    2838                    "id": "1", 
    29                     "type": "info" 
     39                          "type": "info", 
     40                    "scenegroup": "1" 
    3041                } 
    3142            ], 
    3243            "Control": [ 
    3344                { 
    34                     "ControlGroup": "1", 
    35                     "ControlPair": "1", 
    36                     "ControlHeader": "1", 
    3745                    "ControlType": "label", 
    3846                    "Label": { 
    3947                        "lang_tag": "device_settings_page", 
    40                         "text": "Port"  
     48                        "text": "Port" 
    4149                    }, 
    4250                    "Display": { 
     
    4452                        "Left": 50, 
    4553                        "Width": 120, 
    46                         "Height": 20  
    47                     }  
     54                        "Height": 20 
     55                    } 
    4856                }, 
    4957                { 
    50                     "ControlGroup": "1", 
    51                     "ControlPair": "1", 
    52                     "ControlHeader": "1", 
    5358                    "ControlType": "variable", 
    5459                    "Display": { 
     
    5863                        "Left": 170, 
    5964                        "Width": 120, 
    60                         "Height": 20  
    61                     }  
     65                        "Height": 20 
     66                    } 
    6267                }, 
    63             ]  
     68            ] 
    6469        }, 
    6570        { 
    6671            "Label": { 
    6772                "lang_tag": "advanced", 
    68                 "text": "Advanced"  
     73                "text": "Advanced" 
    6974            }, 
    7075            "Position": "2", 
    7176            "TabType": "javascript", 
    7277            "ScriptName": "shared.js", 
    73             "Function": "advanced_device"  
     78            "Function": "advanced_device" 
    7479        } 
    7580    ] 
Note: See TracChangeset for help on using the changeset viewer.