- Files:
-
- 1 added
- 2 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
/D_RFXCOMHarrison.json
r20 r30 145 145 "Function": "advanced_device" 146 146 }, 147 {148 "Label": {149 "lang_tag": "logs",150 "text": "Logs"151 },152 "Position": "4",153 "TabType": "javascript",154 "ScriptName": "shared.js",155 "Function": "device_logs"156 },157 147 { 158 148 "Label": { … … 186 176 } 187 177 } , 178 "eventList": { 179 "event_1": { 180 "label": "Curtain is closed", 181 "serviceId": "urn:upnp-esweb-nl:serviceId:RFXCOMHarrison1", 182 "serviceStateTable": { 183 "CurtainStatus": { 184 "value": "1", 185 "comparisson": "=" 186 } 187 } 188 }, 189 "event_2": { 190 "label": "Curtain is opened", 191 "serviceId": "urn:upnp-esweb-nl:serviceId:RFXCOMHarrison1", 192 "serviceStateTable": { 193 "CurtainStatus": { 194 "value": "0", 195 "comparisson": "=" 196 } 197 } 198 } 199 }, 188 200 "eventList2": [ 189 201 { -
/S_EZAnemoSensor.xml
r20 r30 25 25 <name>SpeedAv</name> 26 26 <dataType>string</dataType> 27 <shortCode>speed Av</shortCode>27 <shortCode>speedav</shortCode> 28 28 </stateVariable> 29 29 -
/D_RainSensor1.json
r20 r30 136 136 } 137 137 ], 138 "DeviceType": "urn: upnp-org:serviceId:RainSensor1"138 "DeviceType": "urn:schemas-micasaverde-com:device:RainSensor:1" 139 139 } -
/D_EZAnemoSensor.json
r20 r30 97 97 "ControlType": "label", 98 98 "Label": { 99 "lang_tag": " gust",99 "lang_tag": "speed", 100 100 "text": "Speed" 101 101 }, … … 127 127 "ControlType": "label", 128 128 "Label": { 129 "lang_tag": " gust_unit",129 "lang_tag": "speed_unit", 130 130 "text": "m/s" 131 131 }, … … 198 198 "Function": "advanced_device" 199 199 }, 200 { 201 "Label": { 202 "lang_tag": "notifications", 203 "text": "Notifications" 204 }, 205 "Position": "5", 206 "TabType": "javascript", 207 "ScriptName": "shared.js", 208 "Function": "device_notifications" 209 } 200 210 ], 201 "DeviceType": "urn:schemas-micasaverde-com:device:EZAnemoSensor:1" 211 "eventList": { 212 "event_1": { 213 "label": "Wind speed goes above", 214 "serviceId": "urn:upnp-org:serviceId:EZAnemoSensor1", 215 "norepeat": "1", 216 "argumentList" : { 217 "argument_1" : { 218 "dataType": "i4", 219 "name": "Speed", 220 "comparisson": ">", 221 "prefix": "speed: ", 222 "suffix": " m/s" 223 } 224 } 225 }, 226 "event_2": { 227 "label": "Wind speed goes below", 228 "serviceId": "urn:upnp-org:serviceId:EZAnemoSensor1", 229 "norepeat": "1", 230 "argumentList" : { 231 "argument_1" : { 232 "dataType": "i4", 233 "name": "Speed", 234 "comparisson": "<", 235 "prefix": "speed: ", 236 "suffix": " m/s" 237 } 238 } 239 }, 240 "event_3": { 241 "label": "Battery level goes below", 242 "serviceId": "urn:micasaverde-com:serviceId:HaDevice1", 243 "argumentList": { 244 "argument_1": { 245 "prefix":"Level", 246 "dataType": "i4", 247 "name": "BatteryLevel", 248 "comparisson": "<", 249 "suffix": "%" 250 } 251 } 252 } 253 } , 254 "eventList2": [ 255 { 256 "id": 1, 257 "label": { 258 "lang_tag": "speed_goes_above", 259 "text": "Wind speed goes above" 260 }, 261 "serviceId": "urn:upnp-org:serviceId:EZAnemoSensor1", 262 "norepeat": "1", 263 "argumentList": [ 264 { 265 "id": 1, 266 "dataType": "i4", 267 "name": "Speed", 268 "comparisson": ">", 269 "prefix": { 270 "lang_tag": "speed", 271 "text": "Speed" 272 }, 273 "suffix": { 274 "lang_tag": "m/s", 275 "text": "m/s" 276 }, 277 "HumanFriendlyText": { 278 "lang_tag": "hft_speed_goes_above", 279 "text": "The wind speed goes above _DEVICE_NAME_ m/s _ARGUMENT_VALUE_" 280 } 281 } 282 ] 283 }, 284 { 285 "id": 2, 286 "label": { 287 "lang_tag": "speed_goes_below", 288 "text": "Wind speed goes below" 289 }, 290 "serviceId": "urn:upnp-org:serviceId:EZAnemoSensor1", 291 "norepeat": "1", 292 "argumentList": [ 293 { 294 "id": 1, 295 "dataType": "i4", 296 "name": "Speed", 297 "comparisson": "<", 298 "prefix": { 299 "lang_tag": "speed", 300 "text": "Speed av" 301 }, 302 "suffix": { 303 "lang_tag": "m/s", 304 "text": "m/s" 305 }, 306 "HumanFriendlyText": { 307 "lang_tag": "hft_speed_goes_below", 308 "text": "The wind speed goes below _DEVICE_NAME_ m/s _ARGUMENT_VALUE_" 309 } 310 } 311 ] 312 }, 313 { 314 "id": 3, 315 "label": { 316 "lang_tag": "battery_level_goes_below", 317 "text": "Battery level goes below" 318 }, 319 "serviceId": "urn:micasaverde-com:serviceId:HaDevice1", 320 "argumentList": [ 321 { 322 "id": 1, 323 "prefix": { 324 "lang_tag": "Level", 325 "text": "Niveau" 326 }, 327 "dataType": "i4", 328 "name": "BatteryLevel", 329 "comparisson": "<", 330 "suffix": { 331 "lang_tag": "percent_sign", 332 "text": "%" 333 }, 334 "HumanFriendlyText": { 335 "lang_tag": "hft_battery_level_goes_below", 336 "text": "Battery level for _DEVICE_NAME_ goes below _ARGUMENT_VALUE_%" 337 } 338 } 339 ] 340 } 341 ], 342 "DeviceType": "urn:schemas-upnp-org:device:EZAnemoSensor:1" 202 343 } -
/D_EZAnemoSensor_fr.json
r20 r30 146 146 "ControlType": "label", 147 147 "Label": { 148 "lang_tag": "average_sp ped",148 "lang_tag": "average_speed", 149 149 "text": "Vitesse moy" 150 150 }, … … 198 198 "Function": "advanced_device" 199 199 }, 200 { 201 "Label": { 202 "lang_tag": "notifications", 203 "text": "Notifications" 204 }, 205 "Position": "5", 206 "TabType": "javascript", 207 "ScriptName": "shared.js", 208 "Function": "device_notifications" 209 } 200 210 ], 201 "DeviceType": "urn:schemas-micasaverde-com:device:EZAnemoSensor:1" 211 "eventList": { 212 "event_1": { 213 "label": "Vitesse vent passe en dessus de", 214 "serviceId": "urn:upnp-org:serviceId:EZAnemoSensor1", 215 "norepeat": "1", 216 "argumentList" : { 217 "argument_1" : { 218 "dataType": "i4", 219 "name": "Speed", 220 "comparisson": ">", 221 "prefix": "speed: ", 222 "suffix": " m/s" 223 } 224 } 225 }, 226 "event_2": { 227 "label": "Vitesse vent descend en dessous de", 228 "serviceId": "urn:upnp-org:serviceId:EZAnemoSensor1", 229 "norepeat": "1", 230 "argumentList" : { 231 "argument_1" : { 232 "dataType": "i4", 233 "name": "Speed", 234 "comparisson": "<", 235 "prefix": "speed: ", 236 "suffix": " m/s" 237 } 238 } 239 }, 240 "event_3": { 241 "label": "Niveau de la batterie descend en dessous de", 242 "serviceId": "urn:micasaverde-com:serviceId:HaDevice1", 243 "argumentList": { 244 "argument_1": { 245 "prefix":"Level", 246 "dataType": "i4", 247 "name": "BatteryLevel", 248 "comparisson": "<", 249 "suffix": "%" 250 } 251 } 252 } 253 } , 254 "eventList2": [ 255 { 256 "id": 1, 257 "label": { 258 "lang_tag": "speed_goes_above", 259 "text": "Vitesse vent passe en dessus de" 260 }, 261 "serviceId": "urn:upnp-org:serviceId:EZAnemoSensor1", 262 "norepeat": "1", 263 "argumentList": [ 264 { 265 "id": 1, 266 "dataType": "i4", 267 "name": "Speed", 268 "comparisson": ">", 269 "prefix": { 270 "lang_tag": "speed", 271 "text": "Speed" 272 }, 273 "suffix": { 274 "lang_tag": "m/s", 275 "text": "m/s" 276 }, 277 "HumanFriendlyText": { 278 "lang_tag": "hft_speed_goes_above", 279 "text": "La vitesse du vent pour _DEVICE_NAME_ passe en dessus de _ARGUMENT_VALUE_ m/s" 280 } 281 } 282 ] 283 }, 284 { 285 "id": 2, 286 "label": { 287 "lang_tag": "speed_goes_below", 288 "text": "Vitesse vent descend en dessous de" 289 }, 290 "serviceId": "urn:upnp-org:serviceId:EZAnemoSensor1", 291 "norepeat": "1", 292 "argumentList": [ 293 { 294 "id": 1, 295 "dataType": "i4", 296 "name": "Speed", 297 "comparisson": "<", 298 "prefix": { 299 "lang_tag": "speed", 300 "text": "Speed av" 301 }, 302 "suffix": { 303 "lang_tag": "m/s", 304 "text": "m/s" 305 }, 306 "HumanFriendlyText": { 307 "lang_tag": "hft_speed_goes_below", 308 "text": "La vitesse du vent pour _DEVICE_NAME_ descend en dessous de _ARGUMENT_VALUE_ m/s" 309 } 310 } 311 ] 312 }, 313 { 314 "id": 3, 315 "label": { 316 "lang_tag": "battery_level_goes_below", 317 "text": "Niveau de la batterie descend en dessous de" 318 }, 319 "serviceId": "urn:micasaverde-com:serviceId:HaDevice1", 320 "argumentList": [ 321 { 322 "id": 1, 323 "prefix": { 324 "lang_tag": "Level", 325 "text": "Niveau" 326 }, 327 "dataType": "i4", 328 "name": "BatteryLevel", 329 "comparisson": "<", 330 "suffix": { 331 "lang_tag": "percent_sign", 332 "text": "%" 333 }, 334 "HumanFriendlyText": { 335 "lang_tag": "hft_battery_level_goes_below", 336 "text": "Le niveau de la batterie pour _DEVICE_NAME_ descend en dessous de _ARGUMENT_VALUE_%" 337 } 338 } 339 ] 340 } 341 ], 342 "DeviceType": "urn:schemas-upnp-org:device:EZAnemoSensor:1" 202 343 } -
/I_RFXCOM.xml
r20 r30 19 19 ipPortRead = 0 20 20 ipPortSend = 0 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 21 22 RFXConstants = { 23 sensorTypeMotion = 1, 24 sensorTypeDoor = 2, 25 sensorTypeKeyFob = 4, 26 sensorTypeRemote = 8, 27 sensorTypeControler = 16, 28 sensorTypeWindowCovering = 32, 29 sensorTypeTemperature = 64, 30 sensorTypeHumidity = 128, 31 sensorTypeWindDirection = 256, 32 sensorTypeWindSpeed = 512, 33 sensorTypeWindSpeedAv = 1024, 34 sensorTypeBarometer = 2048, 35 sensorTypeRain = 4096, 36 37 sensorManufacturerX10 = "X10", 38 sensorManufacturerHomeEasy = "HOMEEASY", 39 sensorManufacturerVisonic = "VISONIC", 40 sensorManufacturerOregon = "OREGON", 41 sensorManufacturerHarrison = "HARRISON", 42 43 cmdGroupOn = 1, 44 cmdGroupOff = 2, 45 cmdOn = 4, 46 cmdOff = 8, 47 cmdArmAway = 16, 48 cmdArmHome = 32, 49 cmdDisarm = 64, 50 cmdTamper = 128, 51 cmdJamming = 256, 52 cmdBatteryLow = 512, 53 cmdNormal = 1024, 54 cmdAlert = 2048 55 } 56 57 57 function mainStartup(lul_device) 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 -- Check all devices if they are childeren. If so, register in115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 end 132 133 134 135 136 137 end 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 58 RFXDevicesLS = {} 59 RFXCountLS = 0 60 RFXDevicesDS = {} 61 RFXCountDS = 0 62 RFXDevicesMS = {} 63 RFXCountMS = 0 64 RFXDevicesKF = {} 65 RFXCountKF = 0 66 RFXCountTS2 = 0 67 RFXDevicesTS2 = {} 68 RFXCountHS2 = 0 69 RFXDevicesHS2 = {} 70 RFXCountBS2 = 0 71 RFXDevicesBS2 = {} 72 RFXCountRS2 = 0 73 RFXDevicesRS2 = {} 74 RFXCountAS2 = 0 75 RFXDevicesAS2 = {} 76 RFXCOM_HAR_Count = 0 77 RFXCOM_HAR_Devices = {} 78 79 THIS_DEVICE = lul_device 80 luup.log("Starting RFXCOM device: " .. tostring(THIS_DEVICE)) 81 local device = luup.devices[THIS_DEVICE] 82 83 -- Set our device IP number 84 if (device.ip == "") then 85 return false, "IP Address attribute must be configured", "rfxcom" 86 end 87 ipAddress = device.ip 88 89 -- Get defined read and write port. If not set, set the default port numbers 10001 and 10002 90 local portList = luup.variable_get("urn:upnp-esweb-nl:serviceId:rfxcom1", "portRead", lul_device) 91 if ((portList or "") == "") then 92 portList = "10001" 93 luup.variable_set("urn:upnp-esweb-nl:serviceId:rfxcom1", "portRead", portList, lul_device) 94 elseif (portList:find("%d") == nil) then 95 return false, "The Port Read parameter must be of the form nnnn. eg. 10001" 96 end 97 ipPortRead = portList 98 99 local portList = luup.variable_get("urn:upnp-esweb-nl:serviceId:rfxcom1", "portWrite", lul_device) 100 if ((portList or "") == "") then 101 portList = "10002" 102 luup.variable_set("urn:upnp-esweb-nl:serviceId:rfxcom1", "portWrite", portList, lul_device) 103 elseif (portList:find("%d") == nil) then 104 return false, "The Port Write parameter must be of the form nnnn. eg. 10002" 105 end 106 ipPortSend = portList 107 108 -- Check if we should create the devices automaticly 109 local RFXAutoCreate = luup.variable_get("urn:upnp-esweb-nl:serviceId:rfxcom1", "AutoCreate", lul_device) 110 if ((RFXAutoCreate or "") == "") then 111 luup.variable_set("urn:upnp-esweb-nl:serviceId:rfxcom1", "AutoCreate", "0", lul_device) 112 end 113 114 -- Check all devices if they are children. If so, register in 115 -- the correct array based on the device type 116 for k, v in pairs(luup.devices) do 117 -- Look for devices with this device as parent 118 if (v.device_num_parent == lul_device) then 119 luup.log( "Found child device, lets save! id " .. tostring(v.id) .. " device " .. tostring(v.device_type)) 120 121 -- Check on door sensors 122 if (tostring(v.device_type) == "urn:schemas-micasaverde-com:device:DoorSensor:1") then 123 RFXCountDS = RFXCountDS + 1 124 RFXDevicesDS[RFXCountDS] = v.id 125 end 126 127 -- Check on motion sensors 128 if (tostring(v.device_type) == "urn:schemas-micasaverde-com:device:MotionSensor:1") then 129 RFXCountMS = RFXCountMS + 1 130 RFXDevicesMS[RFXCountMS] = v.id 131 end 132 133 -- Check on keyfobs 134 if (tostring(v.device_type) == "urn:schemas-ActiveRFID:device:RFIDTransmitter:1") then 135 RFXCountKF = RFXCountKF + 1 136 RFXDevicesKF[RFXCountKF] = v.id 137 end 138 139 -- Check on light switches 140 if (tostring(v.device_type) == "urn:schemas-upnp-org:device:BinaryLight:1") then 141 RFXCountLS = RFXCountLS + 1 142 RFXDevicesLS[RFXCountLS] = v.id 143 end 144 145 -- Check on Harrison window coverings 146 if (tostring(v.device_type) == "urn:schemas-micasaverde-com:device:WindowCovering:1") then 147 RFXCOM_HAR_Count = RFXCOM_HAR_Count + 1 148 RFXCOM_HAR_Devices[RFXCOM_HAR_Count] = v.id 149 end 150 151 -- Check on temperature devices 152 if (tostring(v.device_type) == "urn:schemas-micasaverde-com:device:TemperatureSensor:1") then 153 RFXCountTS2 = RFXCountTS2 + 1 154 RFXDevicesTS2[RFXCountTS2] = v.id 155 luup.log("Registered device " .. RFXDevicesTS2[RFXCountTS2] .. " as temperature sensor ".. RFXCountTS2) 156 end 157 158 -- Check on humidity devices 159 if (tostring(v.device_type) == "urn:schemas-micasaverde-com:device:HumiditySensor:1") then 160 RFXCountHS2 = RFXCountHS2 + 1 161 RFXDevicesHS2[RFXCountHS2] = v.id 162 luup.log("Registered device " .. RFXDevicesHS2[RFXCountHS2] .. " as humidity sensor ".. RFXCountHS2) 163 end 164 165 -- Check on barometer devices 166 if (tostring(v.device_type) == "urn:schemas-micasaverde-com:device:BarometerSensor:1") then 167 RFXCountBS2 = RFXCountBS2 + 1 168 RFXDevicesBS2[RFXCountBS2] = v.id 169 luup.log("Registered device " .. RFXDevicesBS2[RFXCountBS2] .. " as barometer sensor ".. RFXCountBS2) 170 end 171 172 -- Check on barometer devices 173 if (tostring(v.device_type) == "urn:schemas-micasaverde-com:device:RainSensor:1") then 174 RFXCountRS2 = RFXCountRS2 + 1 175 RFXDevicesRS2[RFXCountRS2] = v.id 176 luup.log("Registered device " .. RFXDevicesRS2[RFXCountRS2] .. " as rain sensor ".. RFXCountRS2) 177 end 178 179 -- Check on EZAnemoSensor devices 180 if (tostring(v.device_type) == "urn:schemas-upnp-org:device:EZAnemoSensor:1") then 181 RFXCountAS2 = RFXCountAS2 + 1 182 RFXDevicesAS2[RFXCountAS2] = v.id 183 luup.log("Registered device " .. RFXDevicesAS2[RFXCountAS2] .. " as Anemo sensor ".. RFXCountAS2) 184 end 185 end 186 end 187 luup.log("Tree with number child devices:") 188 luup.log(" door sensors: " .. RFXCountDS) 189 luup.log(" motion sensors: " .. RFXCountMS) 190 luup.log(" keyfob sensors: " .. RFXCountKF) 191 luup.log(" light switches: " .. RFXCountLS) 192 luup.log(" window covering: " .. RFXCOM_HAR_Count) 193 luup.log("temperature sensors: " .. RFXCountTS2) 194 luup.log(" humidity sensors: " .. RFXCountHS2) 195 luup.log(" pressure sensors: " .. RFXCountBS2) 196 luup.log(" rain sensors: " .. RFXCountBS2) 197 luup.log(" anemo sensors: " .. RFXCountAS2) 198 199 luup.log("Open socket for read " .. ipAddress .. " port " .. ipPortRead ) 200 luup.io.open(THIS_DEVICE, ipAddress, ipPortRead) 201 startupReady = 1 202 203 luup.log("Startup RFXCOM ready") 204 205 return true, "ok", "rfxcom" 206 206 end 207 207 … … 247 247 return lsResult 248 248 end 249 250 249 250 function SendHarrisonCmd( psHouse, psCmd) 251 251 local liMODEHAR = 0x34 252 253 254 255 256 257 252 local liMODERFXCOM = 0x33 253 local client = nil 254 local lsSend = "" 255 local lsSendStat = "" 256 local lsRecvStat = "" 257 258 258 luup.log("Connect to rfxtrans ip " .. ipAddress .. " port " .. ipPortSend) 259 259 client = socket.connect(ipAddress, ipPortSend) 260 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 261 if client ~= nil then 262 client:settimeout(2) 263 264 luup.log("Send cmd " .. psCmd .. " to " .. psHouse) 265 266 --to send a command we need to specify: F0 CMD F0 CMD where CMD has special meaning. 267 lsSend = string.char(0xf0) .. string.char(liMODEHAR) .. string.char(0xf0) .. string.char(liMODEHAR) 268 --luup.log("send cmd: " .. formattohex(lsSend)) 269 270 lsSendStat = client:send(lsSend) 271 --luup.log("send cmd result: " .. formattohex(lsSendStat)) 272 273 -- We will receive an ack with the last byte of the command sent. or a nack 0x5a 274 lsRecvStat=client:receive(1) 275 --luup.log("recv result: " .. formattohex(lsRecvStat)) 276 277 --to send a command we need to specify: [House Code][Command] 278 -- House code is 2 bytes. Open up the remote. There are 8 dip switches with a 3 state. 279 -- note down the bits where state top = 2 bits: 11, middle = 10, down = 00. 280 -- write down the bits starting from switch 1 to 8. 281 -- I get the following code of bits: 00 00 11 11 00 10 10 10 282 -- This is binary and can be written in hex as follows: 0F2A and there you have the house code 283 -- The curtain has three command: open, close, stop: F380, CF80 and FC80 284 -- 285 if ( psCmd == "OPEN" ) then 286 lsSend = psHouse .. "F380" 287 luup.log("send open command for Harrison house code: " .. psHouse) 288 elseif ( psCmd == "CLOSE") then 289 lsSend = psHouse .. "CF80" 290 luup.log("send close command for Harrison house code: " .. psHouse) 291 else 292 --stop 293 lsSend = psHouse .. "FC80" 294 luup.log("send stop command for Harrison house code: " .. psHouse) 295 end 296 297 lsSend = ToByteString( lsSend ) 298 299 local lsSendStat = client:send(lsSend) 300 --luup.log("send cmd result: " .. formattohex(lsSendStat)) 301 302 -- We will recieve an ack with the last byte. or a nack 0x5a 303 local lsRecvStat=client:receive(1) 304 --luup.log("recv result: " .. formattohex(lsRecvStat)) 305 306 -- Close client connection 307 client:close() 308 else 309 return false 310 end 311 luup.log("finished: ") 312 312 end 313 313 314 314 function SendCmd( psID, psCmd ) 315 315 local liMODERESET = 0x30 316 316 local liMODEHAR = 0x34 317 318 319 320 321 322 323 324 325 317 local liMODEVAR = 0x33 318 local liMODEBRB48 = 0x37 319 local liMODEKAKURF = 0x3d 320 local client = nil 321 local lsSend = "" 322 local lsSendStat = "" 323 local lsRecvStat = "" 324 325 326 326 luup.log("Connect to rfxtrans ip " .. ipAddress .. " port " .. ipPortSend) 327 327 client = socket.connect(ipAddress, ipPortSend) 328 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 329 if client ~= nil then 330 client:settimeout(2) 331 332 luup.log("Send cmd " .. psCmd .. " to " .. psID) 333 334 -- Because this is a homeeasy, kaku device, calc the 335 -- command to be send based on the ID of the device 336 337 local lsDeviceType = string.sub( psID, 1, 3) 338 luup.log("Device type is " .. lsDeviceType .. " based on id " .. psID) 339 340 if lsDeviceType == "HEA" then 341 --to send a command we need to specify: F0 CMD F0 CMD where CMD has special meaning. 342 lsSend = string.char(0xf0) .. string.char(liMODERESET) .. string.char(0xf0) .. string.char(liMODERESET) 343 343 lsRecvStat = DoSend( client, lsSend) 344 344 lsSend = string.char(0xf0) .. string.char(liMODEVAR) .. string.char(0xf0) .. string.char(liMODEVAR) 345 345 lsRecvStat = DoSend( client, lsSend) 346 346 347 348 349 --to send a command we need to specify: F0 CMD F0 CMD where CMD has special meaning.350 -- 347 lsSend = RecodeHomeEasy34(psID, psCmd) 348 elseif lsDeviceType == "X10" then 349 -- to send a command we need to specify: F0 CMD F0 CMD where CMD has special meaning. 350 -- lsSend = string.char(0xf0) .. string.char(liMODERESET) .. string.char(0xf0) .. string.char(liMODERESET) 351 351 -- lsRecvStat = DoSend( client, lsSend) 352 352 lsSend = string.char(0xf0) .. string.char(liMODEKAKURF) .. string.char(0xf0) .. string.char(liMODEKAKURF) 353 353 lsRecvStat = DoSend( client, lsSend) 354 355 356 357 358 359 360 361 354 lsSend = RecodeX10(psID, psCmd) 355 else 356 lsSend = nil 357 end 358 359 if lsSend ~= nil then 360 lsSend = ToByteString(lsSend) 361 luup.log("send command " .. psCmd .. " as " .. formattohex(lsSend)) 362 362 363 -- We will recieve an ack with the last byte. or a nack 0x5a364 365 366 367 368 369 370 371 372 373 363 -- We will receive an ack with the last byte. or a nack 0x5a 364 lsRecvStat = DoSend( client, lsSend) 365 end 366 367 -- Close client connection 368 client:close() 369 else 370 luup.log("connection failed.") 371 return false 372 end 373 luup.log("finished: ") 374 374 end 375 375 376 376 function DoSend( poClient, psMessage) 377 if psMessage ~= nil then luup.log("send cmd: " .. formattohex(psMessage)) end 378 379 local lsSendStat = poClient:send(psMessage) 380 381 -- We will receive an ack with the last byte of the command sent. or a nack 0x5a 382 local lsRecvStat = poClient:receive(1) 383 if lsRecvStat ~= nil then luup.log("recv result: " .. formattohex(lsRecvStat)) end 384 return lsRecvStat 385 end 386 387 function RecodeHomeEasy33(psID,psCmd) 388 local lbCmd = string.byte(psID, 5) 389 390 if psCmd == RFXConstants.cmdOff then 391 lbCmd = bitw.bor(lbCmd,0x00) 392 elseif psCmd == RFXConstants.cmdOn then 393 lbCmd = bitw.bor(lbCmd,0x10) 394 elseif psCmd == RFXConstants.cmdGroupOff then 395 lbCmd = bitw.bor(lbCmd,0x20) 396 elseif psCmd == RFXConstants.cmdGroupOn then 397 lbCmd = bitw.bor(lbCmd,0x30) 398 end 399 400 return string.format("%02x%02x%02x%02x%02x%02x",string.byte(psID, 1),string.byte(psID, 2),string.byte(psID, 3), 401 string.byte(psID, 4),lbCmd, string.byte(psID, 6)) 402 end 403 404 function RecodeHomeEasy34(psID, psCmd) 405 luup.log("Recode homeeasy" ) 406 407 local lsIDBytes = ToByteString( string.sub(psID, 4, 14 ) ) 408 local lsID = "21" 409 luup.log("Raw data " .. formattohex( lsIDBytes) ) 410 411 local liCommandCorrection = 0 377 if psMessage ~= nil then luup.log("send cmd: " .. formattohex(psMessage)) end 378 379 local lsSendStat = poClient:send(psMessage) 380 381 -- We will receive an ack with the last byte of the command sent. or a nack 0x5a 382 local lsRecvStat = poClient:receive(1) 383 if lsRecvStat ~= nil then luup.log("recv result: " .. formattohex(lsRecvStat)) end 384 return lsRecvStat 385 end 386 387 function RecodeHomeEasy33(psID, psCmd) 388 luup.log("Recode homeeasy33" ) 389 return "21" .. RecodeHomeEasyBase( psID, psCmd) 390 end 391 392 function RecodeHomeEasy34(psID, psCmd) 393 luup.log("Recode homeeasy34" ) 394 return "22" .. RecodeHomeEasyBase( psID, psCmd) 395 end 396 397 function RecodeHomeEasyBase(psID, psCmd) 398 local lsIDBytes = ToByteString( string.sub(psID, 4, 14 ) ) 399 400 local lbCmd = 0 401 if psCmd == RFXConstants.cmdOff then 402 lbCmd = 0x00 403 elseif psCmd == RFXConstants.cmdOn then 404 lbCmd = 0x10 405 elseif psCmd == RFXConstants.cmdGroupOff then 406 lbCmd = 0x20 407 elseif psCmd == RFXConstants.cmdGroupOn then 408 lbCmd = 0x30 409 end 410 412 411 local lsEnd = "00" 413 if psCmd == RFXConstants.cmdOn then 414 liCommandCorrection = 0x10 415 lsEnd = "00" 416 end 417 --Raw data 00 0E 28 73 0A 0B wordt 22 03 8A 1C DA 418 -- 00.0C.86.0A.B cmd 4 moet worden 22 03 A1 C2 9B 80 419 -- Make ID as received bytes minus command 412 local lsID = "" 420 413 lsID = lsID .. string.format("%02X", bitw.lshift( bitw.band( string.byte(lsIDBytes, 1), 0x03 ), 6) + bitw.rshift( bitw.band( string.byte(lsIDBytes, 2), 0xFC ), 2)) 421 414 lsID = lsID .. string.format("%02X", bitw.lshift( bitw.band( string.byte(lsIDBytes, 2), 0x03 ), 6) + bitw.rshift( bitw.band( string.byte(lsIDBytes, 3), 0xFC ), 2)) 422 415 lsID = lsID .. string.format("%02X", bitw.lshift( bitw.band( string.byte(lsIDBytes, 3), 0x03 ), 6) + bitw.rshift( bitw.band( string.byte(lsIDBytes, 4), 0xFC ), 2)) 423 lsID = lsID .. string.format("%02X", bitw.lshift( bitw.band( string.byte(lsIDBytes, 4), 0x03 ), 6) + liCommandCorrection + bitw.band( string.byte(lsIDBytes, 5), 0x0F)) 424 425 return lsID .. lsEnd 426 end 427 428 function RecodeHomeEasy36(psID,psCmd) 429 return nil 430 end 431 432 function RecodeX10( psID, psCmd) 433 416 lsID = lsID .. string.format("%02X", bitw.lshift( bitw.band( string.byte(lsIDBytes, 4), 0x03 ), 6) + lbCmd + bitw.band( string.byte(lsIDBytes, 5), 0x0F)) 417 418 return lsID .. lsEnd 419 end 420 421 422 function RecodeHomeEasy36(psID,psCmd) 423 luup.log("Recode homeeasy36 not implemented" ) 424 return nil 425 end 426 427 function RecodeX10( psID, psCmd) 428 434 429 luup.log("RecodeX10") 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 end 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 ------------------------------------------------------------------------------------ 481 482 ------------------------------------------------------------------------------------ 483 484 430 431 local laX10HOUSE = { 0x60, 0x70, 0x40, 0x50, 0x80, 0x90, 0xa0, 0xb0, 0xe0, 0xf0, 0xc0, 0xd0, 0x00, 0x10, 0x20, 0x30 } 432 local laX10UNIT = { 0x00, 0x10, 0x08, 0x18, 0x40, 0x50, 0x48, 0x58, 0x00, 0x10, 0x08, 0x18, 0x40, 0x50, 0x48, 0x58 } 433 434 local lsHouseCode = string.sub(psID, 4, 4) 435 local liHouseCode = 1 + string.byte(lsHouseCode) - string.byte("A") 436 local liHouseByte = laX10HOUSE[ liHouseCode ] 437 438 local lsUnitCode = "" 439 local liUnitCode = 0 440 local liUnitByte = 0 441 local liCommandCorrection = 0 442 443 if ( string.len( psID ) > 5 ) then 444 lsUnitCode = string.sub(psID, 5, 6) 445 liUnitCode = tonumber(lsUnitCode) 446 liUnitByte = laX10UNIT[ liUnitCode ] 447 448 if ((psCmd == RFXConstants.cmdOff) or (psCmd == RFXConstants.CmdGroupOff)) then 449 liCommandCorrection = 32 450 luup.log("cmdoff corr") 451 end 452 else 453 -- group command! 80 = off, 90 = on 454 liUnitByte = 0x80 455 liCommandCorrection = 0 456 if ((psCmd == RFXConstants.cmdOn) or (psCmd == RFXConstants.CmdGroupOn)) then 457 liCommandCorrection = 16 458 end 459 luup.log("group cmd " .. liCommandCorrection ) 460 end 461 462 local liHouseCorrection = 0 463 if (liUnitCode >= 9) then 464 liHouseCorrection = 4 465 end 466 liHouseByte = liHouseCorrection + liHouseByte 467 liUnitByte = liCommandCorrection + liUnitByte 468 469 local lsResultstrA = string.format("%02X", bitw.band(bitw.bnot(liHouseByte),0x7fffffff)) 470 local lsResultstrB = string.format("%02X", bitw.band(bitw.bnot(liUnitByte),0x7fffffff)) 471 local lsResultstr = string.format("%02X%02X%s%02X%s", 0x20, liHouseByte, string.sub(lsResultstrA,7,8), liUnitByte, string.sub(lsResultstrB,7,8)) 472 return lsResultstr 473 end 474 475 ------------------------------------------------------------------------------------ 476 -- decode X10 commands 477 ------------------------------------------------------------------------------------ 478 function decodeX10(psCommand) 479 local lsCommand = string.sub( psCommand, 2) 485 480 local liCommandLength = string.len(lsCommand) 486 481 local lsRFXMSG = "" 487 488 489 490 482 local lsSensorManufacturer = RFXConstants.sensorManufacturerX10 483 local lnSensorType = RFXConstants.sensorTypeControler 484 local lsID = "" 485 local lsCmd = "" 491 486 492 487 luup.log("trying x10") … … 520 515 liRecBytes = liRecBytes + bitw.rshift( bitw.band( string.byte(lsCommand, 3) , 0x8), 2) 521 516 liRecBytes = liRecBytes + bitw.rshift( bitw.band( string.byte(lsCommand, 3) , 0x40), 4) 522 liRecBytes = liRecBytes + bitw.lshift( bitw.band( string.byte(lsCommand, 1) , 0x4), 1) 517 518 -- hhg tip on forum. X10 Unit code 9 to 16 was recognized as 1 to 8. please read reply #87 519 liRecBytes = liRecBytes + bitw.lshift( bitw.band( string.byte(lsCommand, 3) , 0x4), 1) 523 520 liRecBytes = liRecBytes + 1 524 521 … … 541 538 end 542 539 543 544 545 546 ------------------------------------------------------------------------------------ 547 548 ------------------------------------------------------------------------------------ 549 550 551 552 553 554 555 556 540 return lsRFXMSG,lnSensorType,lsID,lsCmd,lsSensorManufacturer 541 end 542 543 ------------------------------------------------------------------------------------ 544 -- decode homeeasy / kaku commands 545 ------------------------------------------------------------------------------------ 546 function decodeHomeEasy36(psCommand) 547 local lsSensorManufacturer = RFXConstants.sensorManufacturerHomeEasy 548 local lnSensorType = RFXConstants.sensorTypeControler 549 local lsID = "" 550 local lsCmd = "" 551 552 -- 22 03 A1 C2 8B C0 -> 553 -- Make ID as received bytes minus command 557 554 lsID = lsID .. string.format("%02X", bitw.rshift( string.byte(psCommand, 2), 6)) 558 555 lsID = lsID .. string.format("%02X", bitw.lshift( bitw.band(string.byte(psCommand, 2), 0x3F), 2) + bitw.rshift(string.byte(psCommand, 3), 6)) … … 561 558 -- add button id to device. 562 559 lsID = "HEA" .. lsID .. string.format("%01X", bitw.band( string.byte(psCommand, 5), 0x0F ) ) 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 ------------------------------------------------------------------------------------ 588 589 ------------------------------------------------------------------------------------ 590 591 592 593 594 595 596 560 561 -- Extract on/off/group on/group off command 562 local lnDataM = bitw.rshift( bitw.band( string.byte(psCommand, 5) , 0x30 ), 4 ) 563 if (lnDataM == 0) then lsCmd = RFXConstants.cmdOff end 564 if (lnDataM == 1) then lsCmd = RFXConstants.cmdOn end 565 if (lnDataM == 2) then lsCmd = RFXConstants.cmdGroupOff end 566 if (lnDataM == 3) then lsCmd = RFXConstants.cmdGroupOn end 567 568 -- Make message 569 lsRFXMSG = string.format ("[%s:%d ID: %s CMD: %d]", lsSensorManufacturer,lnSensorType, lsID, lsCmd) 570 571 return lsRFXMSG,lnSensorType,lsID,lsCmd,lsSensorManufacturer 572 end 573 574 function decodeHomeEasy34(psCommand) 575 local lsSensorManufacturer = RFXConstants.sensorManufacturerHomeEasy 576 local lnSensorType = RFXConstants.sensorTypeControler 577 local lsID = "" 578 local lsCmd = "" 579 580 lsRFXMSG,lnSensorType,lsID,lsCmd,lsSensorManufacturer = decodeHomeEasy36(psCommand) 581 return lsRFXMSG,lnSensorType,lsID,lsCmd,lsSensorManufacturer 582 end 583 584 ------------------------------------------------------------------------------------ 585 -- decode Visonic commands 586 ------------------------------------------------------------------------------------ 587 function decodeVisonic( psCommand ) 588 local lsRFXMSG = "" 589 local liCommandLength = string.len(psCommand) 590 local lnSensorType = 0 591 local lsSensorManufacturer = RFXConstants.sensorManufacturerVisonic 592 local lsCmd = "" 593 local lsID = "" 597 594 598 595 luup.log("trying Visonic") 599 596 luup.log("decodeV msg : " .. formattohex(psCommand)) 600 597 if ( liCommandLength >= 6 ) then 601 598 602 -- First decode ID 603 -- lsID = "VIS" .. string.format("%02X%02X%02X-%d",string.byte(psCommand, 2),string.byte(psCommand, 3),string.byte(psCommand, 6),string.byte(psCommand,2) * 256 + string.byte(psCommand,3)) 604 lsID = "VIS" .. string.format("%02X", string.byte(psCommand, 2) ) 605 local liHsAddr = 0 606 --liHsAddr = createhsaddr(psCommand) 607 608 --if protocol = MODEB32 then 609 -- lsRFXMSG = string.format(" addr: %02x%d",string.byte(psCommand, 2),liHsAddr) 610 --else 611 -- lsRFXMSG = string.format(" addr: %s ID: %d,lsDevice,liHsAddr) 612 --end 613 -- Next decode message data 614 if string.byte(psCommand, 4) == 0x44 then 615 lnSensorType = RFXConstants.sensorTypeDoor 616 lsCmd = RFXConstants.cmdAlert + RFXConstants.cmdTamper 617 elseif string.byte(psCommand, 4) == 0xC4 then 618 lnSensorType = RFXConstants.sensorTypeDoor 619 lsCmd = RFXConstants.cmdNormal + RFXConstants.cmdTamper 620 elseif string.byte(psCommand, 4) == 0x4 then 621 lnSensorType = RFXConstants.sensorTypeDoor 622 lsCmd = RFXConstants.cmdAlert 623 elseif string.byte(psCommand, 4) == 0x5 then 624 lnSensorType = RFXConstants.sensorTypeDoor 625 lsCmd = RFXConstants.cmdAlert + RFXConstants.cmdBatteryLow 626 elseif string.byte(psCommand, 4) == 0x84 then 627 lnSensorType = RFXConstants.sensorTypeDoor 628 lsCmd = RFXConstants.cmdNormal 629 elseif string.byte(psCommand, 4) == 0x85 then 630 lnSensorType = RFXConstants.sensorTypeDoor 631 lsCmd = RFXConstants.cmdNormal + RFXConstants.cmdBatteryLow 632 elseif string.byte(psCommand, 4) == 0x4C then 633 lnSensorType = RFXConstants.sensorTypeMotion 634 lsCmd = RFXConstants.cmdAlert + RFXConstants.cmdTamper 635 elseif string.byte(psCommand, 4) == 0xCC then 636 lnSensorType = RFXConstants.sensorTypeMotion 637 lsCmd = RFXConstants.cmdNormal + RFXConstants.cmdTamper 638 elseif string.byte(psCommand, 4) == 0x0C then 639 lnSensorType = RFXConstants.sensorTypeMotion 640 lsCmd = RFXConstants.cmdAlert 641 elseif string.byte(psCommand, 4) == 0x0D then 642 lnSensorType = RFXConstants.sensorTypeMotion 643 lsCmd = RFXConstants.cmdAlert + RFXConstants.cmdBatteryLow 644 elseif string.byte(psCommand, 4) == 0x8C then 645 lnSensorType = RFXConstants.sensorTypeMotion 646 lsCmd = RFXConstants.cmdNormal 647 elseif string.byte(psCommand, 4) == 0x8D then 648 lnSensorType = RFXConstants.sensorTypeMotion 649 lsCmd = RFXConstants.cmdNormal + RFXConstants.cmdBatteryLow 650 elseif string.byte(psCommand, 4) == 0xE0 then 651 if string.byte(psCommand, 2) == 0xff then 652 lsCmd = RFXConstants.cmdJamming -- Master receiver jamming detected 653 elseif string.byte(psCommand, 2) == 0x0 then 654 lsCmd = RFXConstants.cmdJamming -- Slave receiver jamming detected 655 else 656 -- Unknown data packet received 657 end 658 elseif string.byte(psCommand, 4) == 0xF8 then 659 if string.byte(psCommand, 2) == 0xff then 660 lsCmd = RFXConstants.cmdJamming -- Master receiver jamming detected 661 elseif string.byte(psCommand, 2) == 0x0 then 662 lsCmd = RFXConstants.cmdJamming -- Slave receiver jamming detected 663 else 664 -- Unknown command 665 end 666 667 -- Marmitek KR21 code 668 elseif string.byte(psCommand, 4) == 0x6 then 669 lnSensorType = RFXConstants.sensorTypeKeyFob 670 lsCmd = RFXConstants.cmdArmAway 671 elseif string.byte(psCommand, 4) == 0x86 then 672 lnSensorType = RFXConstants.sensorTypeKeyFob 673 lsCmd = RFXConstants.cmdDisarm 674 elseif string.byte(psCommand, 4) == 0x46 then 675 lnSensorType = RFXConstants.sensorTypeKeyFob 676 lsCmd = RFXConstants.cmdOn 677 elseif string.byte(psCommand, 4) == 0xC6 then 678 lnSensorType = RFXConstants.sensorTypeKeyFob 679 lsCmd = RFXConstants.cmdOff 680 681 elseif string.byte(psCommand, 4) == 0x2 then 682 lnSensorType = RFXConstants.sensorTypeKeyFob 683 lsCmd = RFXConstants.cmdArmAway 684 elseif string.byte(psCommand, 4) == 0xE then 685 lnSensorType = RFXConstants.sensorTypeKeyFob 686 lsCmd = RFXConstants.cmdArmHome 687 elseif string.byte(psCommand, 4) == 0x22 then 688 lnSensorType = RFXConstants.sensorTypeKeyFob 689 lsCmd = RFXConstants.cmdPanic 690 elseif string.byte(psCommand, 4) == 0x42 then 691 lnSensorType = RFXConstants.sensorTypeKeyFob 692 lsCmd = RFXConstants.cmdGroupOn 693 elseif string.byte(psCommand, 4) == 0x82 then 694 lnSensorType = RFXConstants.sensorTypeKeyFob 695 lsCmd = RFXConstants.cmdDisarm 599 -- First decode ID 600 -- lsID = "VIS" .. string.format("%02X%02X%02X-%d",string.byte(psCommand, 2),string.byte(psCommand, 3),string.byte(psCommand, 6),string.byte(psCommand,2) * 256 + string.byte(psCommand,3)) 601 lsID = "VIS" .. string.format("%02X", string.byte(psCommand, 2) ) 602 local liHsAddr = 0 603 --liHsAddr = createhsaddr(psCommand) 604 605 --if protocol = MODEB32 then 606 -- lsRFXMSG = string.format(" addr: %02x%d",string.byte(psCommand, 2),liHsAddr) 607 --else 608 -- lsRFXMSG = string.format(" addr: %s ID: %d,lsDevice,liHsAddr) 609 --end 610 -- Next decode message data 611 if string.byte(psCommand, 4) == 0x44 then 612 lnSensorType = RFXConstants.sensorTypeDoor 613 lsCmd = RFXConstants.cmdAlert + RFXConstants.cmdTamper 614 elseif string.byte(psCommand, 4) == 0xC4 then 615 lnSensorType = RFXConstants.sensorTypeDoor 616 lsCmd = RFXConstants.cmdNormal + RFXConstants.cmdTamper 617 elseif string.byte(psCommand, 4) == 0x4 then 618 lnSensorType = RFXConstants.sensorTypeDoor 619 lsCmd = RFXConstants.cmdAlert 620 elseif string.byte(psCommand, 4) == 0x5 then 621 lnSensorType = RFXConstants.sensorTypeDoor 622 lsCmd = RFXConstants.cmdAlert + RFXConstants.cmdBatteryLow 623 elseif string.byte(psCommand, 4) == 0x84 then 624 lnSensorType = RFXConstants.sensorTypeDoor 625 lsCmd = RFXConstants.cmdNormal 626 elseif string.byte(psCommand, 4) == 0x85 then 627 lnSensorType = RFXConstants.sensorTypeDoor 628 lsCmd = RFXConstants.cmdNormal + RFXConstants.cmdBatteryLow 629 elseif string.byte(psCommand, 4) == 0x4C then 630 lnSensorType = RFXConstants.sensorTypeMotion 631 lsCmd = RFXConstants.cmdAlert + RFXConstants.cmdTamper 632 elseif string.byte(psCommand, 4) == 0xCC then 633 lnSensorType = RFXConstants.sensorTypeMotion 634 lsCmd = RFXConstants.cmdNormal + RFXConstants.cmdTamper 635 elseif string.byte(psCommand, 4) == 0x0C then 636 lnSensorType = RFXConstants.sensorTypeMotion 637 lsCmd = RFXConstants.cmdAlert 638 elseif string.byte(psCommand, 4) == 0x0D then 639 lnSensorType = RFXConstants.sensorTypeMotion 640 lsCmd = RFXConstants.cmdAlert + RFXConstants.cmdBatteryLow 641 elseif string.byte(psCommand, 4) == 0x8C then 642 lnSensorType = RFXConstants.sensorTypeMotion 643 lsCmd = RFXConstants.cmdNormal 644 elseif string.byte(psCommand, 4) == 0x8D then 645 lnSensorType = RFXConstants.sensorTypeMotion 646 lsCmd = RFXConstants.cmdNormal + RFXConstants.cmdBatteryLow 647 elseif string.byte(psCommand, 4) == 0xE0 then 648 if string.byte(psCommand, 2) == 0xff then 649 lsCmd = RFXConstants.cmdJamming -- Master receiver jamming detected 650 elseif string.byte(psCommand, 2) == 0x0 then 651 lsCmd = RFXConstants.cmdJamming -- Slave receiver jamming detected 696 652 else 697 -- Unknown data packet received 698 end 699 700 -- Create RFXMSG text 701 lsRFXMSG = string.format ("[%s:%d ID: %s CMD: %s]", lsSensorManufacturer,lnSensorType, lsID, lsCmd) 702 end 703 704 return lsRFXMSG,lnSensorType,lsID,lsCmd,lsSensorManufacturer 705 end 706 707 653 -- Unknown data packet received 654 end 655 elseif string.byte(psCommand, 4) == 0xF8 then 656 if string.byte(psCommand, 2) == 0xff then 657 lsCmd = RFXConstants.cmdJamming -- Master receiver jamming detected 658 elseif string.byte(psCommand, 2) == 0x0 then 659 lsCmd = RFXConstants.cmdJamming -- Slave receiver jamming detected 660 else 661 -- Unknown command 662 end 663 664 -- Marmitek KR21 code 665 elseif string.byte(psCommand, 4) == 0x6 then 666 lnSensorType = RFXConstants.sensorTypeKeyFob 667 lsCmd = RFXConstants.cmdArmAway 668 elseif string.byte(psCommand, 4) == 0x86 then 669 lnSensorType = RFXConstants.sensorTypeKeyFob 670 lsCmd = RFXConstants.cmdDisarm 671 elseif string.byte(psCommand, 4) == 0x46 then 672 lnSensorType = RFXConstants.sensorTypeKeyFob 673 lsCmd = RFXConstants.cmdOn 674 elseif string.byte(psCommand, 4) == 0xC6 then 675 lnSensorType = RFXConstants.sensorTypeKeyFob 676 lsCmd = RFXConstants.cmdOff 677 678 elseif string.byte(psCommand, 4) == 0x2 then 679 lnSensorType = RFXConstants.sensorTypeKeyFob 680 lsCmd = RFXConstants.cmdArmAway 681 elseif string.byte(psCommand, 4) == 0xE then 682 lnSensorType = RFXConstants.sensorTypeKeyFob 683 lsCmd = RFXConstants.cmdArmHome 684 elseif string.byte(psCommand, 4) == 0x22 then 685 lnSensorType = RFXConstants.sensorTypeKeyFob 686 lsCmd = RFXConstants.cmdPanic 687 elseif string.byte(psCommand, 4) == 0x42 then 688 lnSensorType = RFXConstants.sensorTypeKeyFob 689 lsCmd = RFXConstants.cmdGroupOn 690 elseif string.byte(psCommand, 4) == 0x82 then 691 lnSensorType = RFXConstants.sensorTypeKeyFob 692 lsCmd = RFXConstants.cmdDisarm 693 else 694 -- Unknown data packet received 695 end 696 697 -- Create RFXMSG text 698 lsRFXMSG = string.format ("[%s:%d ID: %s CMD: %s]", lsSensorManufacturer,lnSensorType, lsID, lsCmd) 699 end 700 701 return lsRFXMSG,lnSensorType,lsID,lsCmd,lsSensorManufacturer 702 end 703 704 708 705 function createhsaddr(psCommand) 709 706 local liHsAddr = 0 … … 757 754 liHsAddr = bitw.bor(liHsAddr,0x100) 758 755 end 759 756 760 757 return liHsAddr 761 758 end … … 763 760 764 761 function decodeOregon(psCommand) 765 766 767 768 769 770 771 772 773 774 775 762 local lsCommand = string.sub( psCommand, 2) 763 local lsRFXMSG = "" 764 local lnSensorType = 0 765 local lsID = "" 766 local lsCmd = "" 767 local lsSensorManufacturer = "" 768 local liBitLength = bitw.band( string.byte(psCommand, 1), 0x7f) 769 if ( ( string.byte(lsCommand, 1) == 0x3a ) and ( string.byte(lsCommand, 2) == 0x0d ) ) then 770 luup.log("Identified Oregon WGR918") 771 772 lnSensorType = RFXConstants.sensorTypeWindDirection + RFXConstants.sensorTypeWindSpeed + RFXConstants.sensorTypeWindSpeedAv 776 773 lsSensorManufacturer = RFXConstants.sensorManufacturerOregon 777 local l iDataDir = string.byte(lsCommand, 6) * 10 + bitw.rshift(string.byte(lsCommand, 5), 4)774 local lnDataDir = (string.byte(lsCommand, 6) * 10 + bitw.rshift(string.byte(lsCommand, 5), 4) ) / 10 778 775 local lnDataSpeed = bitw.band( string.byte(lsCommand, 8) , 0x0f) * 10 + (string.byte(lsCommand, 7) / 10 ) 779 776 local lnDataSpeedav = string.byte(lsCommand, 9) + ( bitw.rshift( string.byte(lsCommand, 8), 4) / 10) 780 777 781 782 lsCmd = string.format("direction=%3d;speed=%5.2f;speedav=%5.2f",liDataDir, lnDataSpeed, lnDataSpeedav)783 lsRFXMSG = string.format("[OREGON: WIND3 Device: %s Direction: % 3d Speed: %5.2f Speed av: %5.2f]", lsID, liDataDir, lnDataSpeed, lnDataSpeedav)784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 lsRFXMSG = string.format("[OREGON: Temperature Device: %s Temperature: %5.1f Battery: %d]", lsID, lnDataTemp, lnDataBattery)812 813 814 815 816 817 818 819 820 821 822 823 824 825 lsRFXMSG = string.format("[OREGON: Temp1 Device: %s Temperature: %5.1f Humidity: %d Battery: %d]", lsID, lnDataTemp, lnDataHum, lnDataBattery)826 827 828 829 830 831 832 833 834 835 836 837 838 839 lsRFXMSG = string.format("[OREGON: Temp1 Device: %s Temperature: %5.1f Humidity: %d Battery: %d]", lsID, lnDataTemp, lnDataHum, lnDataBattery)840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 lsRFXMSG = string.format("[OREGON: Temp1 Device: %s Temperature: %5.1f Humidity: %d Battery: %d]", lsID, lnDataTemp, lnDataHum, lnDataBattery)855 856 857 858 859 860 861 862 863 864 865 866 867 868 lsRFXMSG = string.format("[OREGON: Temp1 Device: %s Temperature: %5.1f Humidity: %d Battery: %d]", lsID, lnDataTemp, lnDataHum, lnDataBattery)869 870 871 872 873 874 875 876 877 878 879 880 881 882 lsRFXMSG = string.format("[OREGON: Temperature Device: %s Temperature: %5.1f Humidity: %d Battery: %d]", lsID, lnDataTemp, lnDataHum, lnDataPercentBattery)883 884 885 886 887 888 778 lsID = "ORE" .. string.format("%02X", string.byte(lsCommand, 4) ) 779 lsCmd = string.format("direction=%.1f;speed=%.2f;speedav=%.2f",lnDataDir, lnDataSpeed, lnDataSpeedav) 780 lsRFXMSG = string.format("[OREGON: WIND3 Device: %s Direction: %.1f Speed: %.2f Speed av: %.2f]", lsID, lnDataDir, lnDataSpeed, lnDataSpeedav) 781 782 elseif ( ( string.byte(lsCommand, 1) == 0x1A ) and ( string.byte(lsCommand, 2) == 0x2d ) ) then 783 luup.log("Identified Oregon THGN122N,THGR122NX,THGR228N,THGR268") 784 785 lnSensorType = RFXConstants.sensorTypeTemperature + RFXConstants.sensorTypeHumidity 786 lsSensorManufacturer = RFXConstants.sensorManufacturerOregon 787 788 local lnDataTemp = getOregonTemperature(lsCommand) 789 local lnDataBattery = getOregonBattery(lsCommand) 790 local lnDataHum = getOregonHumidity(lsCommand) 791 792 lsID = "ORE" .. string.format("%02X", string.byte(lsCommand, 4) ) 793 lsCmd = string.format("temperature=%.1f;humidity=%d;battery=%d", lnDataTemp, lnDataHum, lnDataBattery) 794 lsRFXMSG = string.format("[OREGON: Temp1 Device: %s Temperature: %5.1f Humidity: %d Battery: %d]", lsID, lnDataTemp, lnDataHum, lnDataBattery) 795 796 -- Support for Oregon THWR800 ca48 68 797 elseif ( ( string.byte(lsCommand, 1) == 0xca ) and ( string.byte(lsCommand, 2) == 0x48 ) ) then 798 luup.log("Identified Oregon THWR800") 799 800 lnSensorType = RFXConstants.sensorTypeTemperature 801 lsSensorManufacturer = RFXConstants.sensorManufacturerOregon 802 803 local lnDataTemp = getOregonTemperature(lsCommand) 804 local lnDataBattery = getOregonBattery(lsCommand) 805 806 lsID = "ORE" .. string.format("%02X", string.byte(lsCommand, 4) ) 807 lsCmd = string.format("temperature=%.1f;battery=%d", lnDataTemp, lnDataBattery) 808 lsRFXMSG = string.format("[OREGON: Temperature Device: %s Temperature: %.1f Battery: %d]", lsID, lnDataTemp, lnDataBattery) 809 810 -- Support for Oregon THGR810 fa28 80 811 elseif ( ( string.byte(lsCommand, 1) == 0xfa ) and ( string.byte(lsCommand, 2) == 0x28 ) ) then 812 luup.log("Identified Oregon THGR810") 813 lnSensorType = RFXConstants.sensorTypeTemperature + RFXConstants.sensorTypeHumidity 814 lsSensorManufacturer = RFXConstants.sensorManufacturerOregon 815 816 local lnDataTemp = getOregonTemperature(lsCommand) 817 local lnDataBattery = getOregonBattery(lsCommand) 818 local lnDataHum = getOregonHumidity(lsCommand) 819 820 lsID = "ORE" .. string.format("%02X", string.byte(lsCommand, 4) ) 821 lsCmd = string.format("temperature=%.1f;humidity=%d;battery=%d", lnDataTemp, lnDataHum, lnDataBattery) 822 lsRFXMSG = string.format("[OREGON: Temp1 Device: %s Temperature: %.1f Humidity: %d Battery: %d]", lsID, lnDataTemp, lnDataHum, lnDataBattery) 823 824 -- Support for Oregon THWR288A ea4c 68 825 elseif ( ( string.byte(lsCommand, 1) == 0xea ) and ( string.byte(lsCommand, 2) == 0x4c ) ) then 826 luup.log("Identified Oregon THWR288A") 827 lnSensorType = RFXConstants.sensorTypeTemperature + RFXConstants.sensorTypeHumidity 828 lsSensorManufacturer = RFXConstants.sensorManufacturerOregon 829 830 local lnDataTemp = getOregonTemperature(lsCommand) 831 local lnDataBattery = getOregonBattery(lsCommand) 832 local lnDataHum = getOregonHumidity(lsCommand) 833 834 lsID = "ORE" .. string.format("%02X", string.byte(lsCommand, 4) ) 835 lsCmd = string.format("temperature=%.1f;humidity=%d;battery=%d", lnDataTemp, lnDataHum, lnDataBattery) 836 lsRFXMSG = string.format("[OREGON: Temp1 Device: %s Temperature: %.1f Humidity: %d Battery: %d]", lsID, lnDataTemp, lnDataHum, lnDataBattery) 837 838 839 -- Support for Oregon TH3 Oregon RTGR328N 840 elseif ( ( bitw.band(string.byte(lsCommand, 1), 0x0f) == 0x0a ) and ( string.byte(lsCommand, 2) == 0xcc ) ) then 841 luup.log("Identified Oregon TH3 RTGR328N ") 842 lnSensorType = RFXConstants.sensorTypeTemperature + RFXConstants.sensorTypeHumidity 843 lsSensorManufacturer = RFXConstants.sensorManufacturerOregon 844 845 local lnDataTemp = getOregonTemperature(lsCommand) 846 local lnDataBattery = getOregonBattery(lsCommand) 847 local lnDataHum = getOregonHumidity(lsCommand) 848 849 lsID = "ORE" .. string.format("%02X", string.byte(lsCommand, 4) ) 850 lsCmd = string.format("temperature=%.1f;humidity=%d;battery=%d", lnDataTemp, lnDataHum, lnDataBattery) 851 lsRFXMSG = string.format("[OREGON: Temp1 Device: %s Temperature: %.1f Humidity: %d Battery: %d]", lsID, lnDataTemp, lnDataHum, lnDataBattery) 852 853 -- Support for Oregon TH4 Oregon THGR328 854 elseif ( ( string.byte(lsCommand, 1) == 0xca ) and ( string.byte(lsCommand, 2) == 0x2c ) ) then 855 luup.log("Identified Oregon TH4 RTGR328 ") 856 lnSensorType = RFXConstants.sensorTypeTemperature + RFXConstants.sensorTypeHumidity 857 lsSensorManufacturer = RFXConstants.sensorManufacturerOregon 858 859 local lnDataTemp = getOregonTemperature(lsCommand) 860 local lnDataBattery = getOregonBattery(lsCommand) 861 local lnDataHum = getOregonHumidity(lsCommand) 862 863 lsID = "ORE" .. string.format("%02X", string.byte(lsCommand, 4) ) 864 lsCmd = string.format("temperature=%.1f;humidity=%d;battery=%d", lnDataTemp, lnDataHum, lnDataBattery) 865 lsRFXMSG = string.format("[OREGON: Temp1 Device: %s Temperature: %.1f Humidity: %d Battery: %d]", lsID, lnDataTemp, lnDataHum, lnDataBattery) 866 867 -- Support for Oregon WTGR800 fab8 80 868 elseif ( ( string.byte(lsCommand, 1) == 0xfa ) and ( string.byte(lsCommand, 2) == 0xb8 ) ) then 869 luup.log("Identified Oregon WTGR800") 870 lnSensorType = RFXConstants.sensorTypeTemperature + RFXConstants.sensorTypeHumidity 871 lsSensorManufacturer = RFXConstants.sensorManufacturerOregon 872 873 local lnDataTemp = getOregonTemperature(lsCommand) 874 local lnDataPercentBattery = getOregonPercentBattery(lsCommand) 875 local lnDataHum = getOregonHumidity(lsCommand) 876 877 lsID = "ORF" .. string.format("%02X", string.byte(lsCommand, 4) ) 878 lsCmd = string.format("temperature=%.1f;humidity=%d;battery=%d", lnDataTemp, lnDataHum, lnDataPercentBattery) 879 lsRFXMSG = string.format("[OREGON: Temperature Device: %s Temperature: %.1f Humidity: %d Battery: %d]", lsID, lnDataTemp, lnDataHum, lnDataPercentBattery) 880 881 -- Support for Oregon WTGR800 1A99 88 882 elseif ( ( string.byte(lsCommand, 1) == 0x1a ) and ( string.byte(lsCommand, 2) == 0x99 ) ) then 883 luup.log("Identified Oregon Anemo WTGR800") 884 885 lnSensorType = RFXConstants.sensorTypeWindDirection 889 886 -- + RFXConstants.sensorTypeWindSpeed + RFXConstants.sensorTypeWindSpeedAv 890 891 892 893 894 895 896 897 898 899 900 901 902 903 lsRFXMSG = string.format("[OREGON: Anemometer Device: %s Direction: %5.1f Speed: %5.1f mps Speed av: %5.1f mps Battery: %d]", lsID, liDataDir, lnDataSpeed, lnDataSpeedav, lnDataPercentBattery)904 887 lsSensorManufacturer = RFXConstants.sensorManufacturerOregon 888 889 local liDataDir = nib(lsCommand,8) * 22.5 890 local lnDataSpeed = nib(lsCommand,15)*10 + nib(lsCommand,12) + nib(lsCommand,13)/10 891 local lnDataSpeedav = nib(lsCommand,16)*10 + nib(lsCommand,17) + nib(lsCommand,14)/10 892 local lnDataPercentBattery = getOregonPercentBattery(lsCommand) 893 894 --conversion mps en kmh 895 --lnDataSpeed = lnDataSpeed * 3.6 896 --lnDataSpeedav = lnDataSpeedav * 3.6 897 898 lsID = "ORE" .. string.format("%02X", string.byte(lsCommand, 4) ) 899 lsCmd = string.format("direction=%.2f;speed=%.2f;speedav=%.2f;battery=%d",liDataDir, lnDataSpeed, lnDataSpeedav, lnDataPercentBattery) 900 lsRFXMSG = string.format("[OREGON: Anemometer Device: %s Direction: %.1f Speed: %.1f mps Speed av: %.1f mps Battery: %d]", lsID, liDataDir, lnDataSpeed, lnDataSpeedav, lnDataPercentBattery) 901 905 902 -- Support for Oregon BTHR918N 5a6d 96 906 elseif ( ( string.byte(lsCommand, 1) == 0x5a ) and ( string.byte(lsCommand, 2) == 0x6d ) ) then 907 luup.log("Identified Oregon BTHR918N") 908 lnSensorType = RFXConstants.sensorTypeTemperature + RFXConstants.sensorTypeHumidity + RFXConstants.sensorTypeBarometer 909 lsSensorManufacturer = RFXConstants.sensorManufacturerOregon 910 911 local lnDataTemp = getOregonTemperature(lsCommand) 912 local lnDataBattery = getOregonBattery(lsCommand) 913 local lnDataHum = getOregonHumidity(lsCommand) 914 915 lnDataPres = 856 + string.byte(lsCommand, 9) 916 lsID = "ORE" .. string.format("%02X", string.byte(lsCommand, 4) ) 917 lsCmd = string.format("temperature=%.1f;humidity=%d;pressure=%s;battery=%d", lnDataTemp, lnDataHum, lnDataPres, lnDataBattery) 918 lsRFXMSG = string.format("[OREGON: Temperature Device: %s Temperature: %5.1f Humidity: %d Pressure: %s Battery: %s]", lsID, lnDataTemp, lnDataHum, lnDataPres, lnDataBattery) 919 920 -- Support for Oregon PCR800 2a19 92 921 elseif ( ( string.byte(lsCommand, 1) == 0x2a ) and ( string.byte(lsCommand, 2) == 0x19 ) ) then 922 luup.log("Identified Oregon PCR800") 923 lnSensorType = RFXConstants.sensorTypeRain 924 lsSensorManufacturer = RFXConstants.sensorManufacturerOregon 925 local lnDataRain = 0.0 926 local lnDataTRain = 0.0 927 local lnDataBattery = getOregonBattery(lsCommand) 928 929 lnDataRain = bitw.band(bitw.lshift(string.byte(lsCommand, 7), 0),0x0f) * 10 + bitw.band(bitw.rshift(string.byte(lsCommand, 6), 4),0x0f) 930 + bitw.band(bitw.lshift(string.byte(lsCommand, 6), 0),0x0f) / 10 + bitw.band(bitw.rshift(string.byte(lsCommand, 5), 4),0x0f) / 100 931 lnDataRain = 25.4 * lnDataRain 932 933 lnDataTRain = bitw.band(bitw.lshift(string.byte(lsCommand, 10), 0),0x0f) * 1000 + bitw.band(bitw.rshift(string.byte(lsCommand, 9), 4),0x0f) * 10 934 + bitw.band(bitw.lshift(string.byte(lsCommand, 9), 0),0x0f) + bitw.band(bitw.rshift(string.byte(lsCommand, 8), 4),0x0f) / 10 935 + bitw.band(bitw.lshift(string.byte(lsCommand, 8), 0),0x0f) / 100 + bitw.band(bitw.rshift(string.byte(lsCommand, 7), 4),0x0f) / 1000 936 937 lnDataTRain = 25.4 * lnDataTRain 938 939 lsID = "ORE" .. string.format("%02X", string.byte(lsCommand, 4) ) 940 lsCmd = string.format("rain=%s;train=%s;battery=%d", lnDataRain, lnDataTRain, lnDataBattery) 941 lsRFXMSG = string.format("[OREGON: Rain Device: %s Rain: %s TRain: %s Battery: %s]", lsID, lnDataRain, lnDataTRain, lnDataBattery) 942 end 943 944 return lsRFXMSG,lnSensorType,lsID,lsCmd,lsSensorManufacturer 903 elseif ( ( string.byte(lsCommand, 1) == 0x5a ) and ( string.byte(lsCommand, 2) == 0x6d ) ) then 904 luup.log("Identified Oregon BTHR918N") 905 lnSensorType = RFXConstants.sensorTypeTemperature + RFXConstants.sensorTypeHumidity + RFXConstants.sensorTypeBarometer 906 lsSensorManufacturer = RFXConstants.sensorManufacturerOregon 907 908 local lnDataTemp = getOregonTemperature(lsCommand) 909 local lnDataBattery = getOregonBattery(lsCommand) 910 local lnDataHum = getOregonHumidity(lsCommand) 911 912 lnDataPres = 856 + string.byte(lsCommand, 9) 913 lsID = "ORE" .. string.format("%02X", string.byte(lsCommand, 4) ) 914 lsCmd = string.format("temperature=%.1f;humidity=%d;pressure=%s;battery=%d", lnDataTemp, lnDataHum, lnDataPres, lnDataBattery) 915 lsRFXMSG = string.format("[OREGON: Temperature Device: %s Temperature: %.1f Humidity: %d Pressure: %s Battery: %s]", lsID, lnDataTemp, lnDataHum, lnDataPres, lnDataBattery) 916 917 -- Support for Oregon PCR800 2a19 92 918 elseif ( ( string.byte(lsCommand, 1) == 0x2a ) and ( string.byte(lsCommand, 2) == 0x19 ) ) then 919 luup.log("Identified Oregon PCR800") 920 lnSensorType = RFXConstants.sensorTypeRain 921 lsSensorManufacturer = RFXConstants.sensorManufacturerOregon 922 local lnDataRain = 0.0 923 local lnDataTRain = 0.0 924 local lnDataBattery = getOregonBattery(lsCommand) 925 926 lnDataRain = bitw.band(bitw.lshift(string.byte(lsCommand, 7), 0),0x0f) * 10 + bitw.band(bitw.rshift(string.byte(lsCommand, 6), 4),0x0f) 927 + bitw.band(bitw.lshift(string.byte(lsCommand, 6), 0),0x0f) / 10 + bitw.band(bitw.rshift(string.byte(lsCommand, 5), 4),0x0f) / 100 928 lnDataRain = 25.4 * lnDataRain 929 930 lnDataTRain = bitw.band(bitw.lshift(string.byte(lsCommand, 10), 0),0x0f) * 1000 + bitw.band(bitw.rshift(string.byte(lsCommand, 9), 4),0x0f) * 10 931 + bitw.band(bitw.lshift(string.byte(lsCommand, 9), 0),0x0f) + bitw.band(bitw.rshift(string.byte(lsCommand, 8), 4),0x0f) / 10 932 + bitw.band(bitw.lshift(string.byte(lsCommand, 8), 0),0x0f) / 100 + bitw.band(bitw.rshift(string.byte(lsCommand, 7), 4),0x0f) / 1000 933 934 lnDataTRain = 25.4 * lnDataTRain 935 936 lsID = "ORE" .. string.format("%02X", string.byte(lsCommand, 4) ) 937 lsCmd = string.format("rain=%s;train=%s;battery=%d", lnDataRain, lnDataTRain, lnDataBattery) 938 lsRFXMSG = string.format("[OREGON: Rain Device: %s Rain: %s TRain: %s Battery: %s]", lsID, lnDataRain, lnDataTRain, lnDataBattery) 939 940 -- Support for Oregon RGR126,RGR682,RGR918 2A1D 84 : 54 2A 1D 00 F9 00 00 12 91 A5 43 04 941 elseif ( ( string.byte(lsCommand, 1) == 0x2a ) and ( string.byte(lsCommand, 2) == 0x1D ) ) then 942 luup.log("Identified Oregon RGR126,RGR682,RGR918") 943 lnSensorType = RFXConstants.sensorTypeRain 944 lsSensorManufacturer = RFXConstants.sensorManufacturerOregon 945 local lnDataRain = 0.0 946 local lnDataTRain = 0.0 947 local lnDataBattery = getOregonBattery(lsCommand) 948 949 lnDataRain = bitw.band(bitw.lshift(string.byte(lsCommand, 6), 0),0xff) * 10 + bitw.band(bitw.rshift(string.byte(lsCommand, 5), 4),0x0f) 950 951 lnDataTRain = bitw.band(bitw.lshift(string.byte(lsCommand, 9), 0),0x0f) * 1000 + bitw.band(bitw.rshift(string.byte(lsCommand, 8), 0),0xff) * 10 952 + bitw.band(bitw.rshift(string.byte(lsCommand, 7), 4),0x0f) 953 954 lsID = "ORE" .. string.format("%02X", string.byte(lsCommand, 4) ) 955 lsCmd = string.format("rain=%s;train=%s;battery=%d", lnDataRain, lnDataTRain, lnDataBattery) 956 lsRFXMSG = string.format("[OREGON: Rain Device: %s Rain: %s TRain: %s Battery: %s]", lsID, lnDataRain, lnDataTRain, lnDataBattery) 957 958 -- Support for Oregon THGR918 1A3D 959 elseif ( ( string.byte(lsCommand, 1) == 0x1a ) and ( string.byte(lsCommand, 2) == 0x3D ) ) then 960 luup.log("Identified Oregon THGR918") 961 lnSensorType = RFXConstants.sensorTypeTemperature + RFXConstants.sensorTypeHumidity + RFXConstants.sensorTypeBarometer 962 lsSensorManufacturer = RFXConstants.sensorManufacturerOregon 963 964 local lnDataTemp = getOregonTemperature(lsCommand) 965 local lnDataBattery = getOregonBattery(lsCommand) 966 local lnDataHum = getOregonHumidity(lsCommand) 967 968 lnDataPres = 795 + string.byte(lsCommand, 9) 969 lsID = "ORE" .. string.format("%02X", string.byte(lsCommand, 4) ) 970 lsCmd = string.format("temperature=%.1f;humidity=%d;pressure=%s;battery=%d", lnDataTemp, lnDataHum, lnDataPres, lnDataBattery) 971 lsRFXMSG = string.format("[OREGON: Temperature Device: %s Temperature: %.1f Humidity: %d Pressure: %s Battery: %s]", lsID, lnDataTemp, lnDataHum, lnDataPres, lnDataBattery) 972 973 end 974 975 return lsRFXMSG,lnSensorType,lsID,lsCmd,lsSensorManufacturer 945 976 end 946 947 948 949 950 951 952 953 954 977 978 function getOregonTemperature(lsCommand) 979 local lnData = nib(lsCommand,10) * 10 + nib(lsCommand,11) + nib(lsCommand,8)/10 980 if (bitw.band( string.byte(lsCommand, 7) , 0x08) == 0) then 981 lnData = lnData 982 else 983 lnData = 0-lnData 984 end 985 return lnData 955 986 end 956 987 957 988 function getOregonHumidity(lsCommand) 958 959 989 local lnData = nib(lsCommand,15) * 10 + nib(lsCommand,12) 990 return lnData 960 991 end 961 992 962 993 function getOregonBattery(lsCommand) 963 964 local lnData = 90 --'hight'965 966 967 994 local battery_low = bitw.band( string.byte(lsCommand, 3) , 0x04) 995 local lnData = 90 --'high' 996 if battery_low == 1 then 997 lnData = 10 --'low' 998 end 968 999 return lnData 969 1000 end 970 1001 971 1002 function getOregonPercentBattery(lsCommand) 972 973 1003 local lnData = 100 - 10*nib(lsCommand,9) 1004 return lnData 974 1005 end 975 1006 976 1007 function nib(lsCommand,i) 977 978 979 980 981 982 1008 local n = (i-i%2)/2 + 1 1009 if (i%2 == 0) then 1010 return bitw.band(bitw.rshift(string.byte(lsCommand, n), 4),0x0f) 1011 else 1012 return bitw.band(string.byte(lsCommand, n),0x0f) 1013 end 983 1014 end 984 1015 … … 1013 1044 -- Log found message and decode!! 1014 1045 if ( lsCommand ~= nil and #lsCommand > 0 ) then 1015 1016 1017 1046 -- luup.log("RFX message compleet: " .. formattohex(lsCommand)) 1047 table.insert( RFXmsgTable, lsCommand ) 1048 luup.call_delay("processMessage", 0 , "none") 1018 1049 end 1019 1050 … … 1024 1055 end 1025 1056 1026 ------------------------------------------------------------------------------------ 1027 1028 ------------------------------------------------------------------------------------ 1057 ------------------------------------------------------------------------------------ 1058 -- Main routine to decode and process the received messages 1059 ------------------------------------------------------------------------------------ 1029 1060 function processMessage(psCommand) 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 luup.log("decodeRFXSensor32") 1061 while ( #RFXmsgTable > 0 ) do 1062 local lsRFXMSG = "" 1063 local lnSensorType = 0 1064 local lsID = "" 1065 local lsCmd = "" 1066 local lsSensorManufacturer = "" 1067 1068 psCommand = table.remove( RFXmsgTable, 1) 1069 local liBitLength = bitw.band( string.byte(psCommand, 1), 0x7f) 1070 1071 luup.log(string.format("decodeMessage bits:%d data:%s",liBitLength,formattohex(psCommand))) 1072 1073 --psCommand = GetStringPart( psCommand, 2, string.len( psCommand ) -1 ) 1074 --local liCommandLength = string.len(psCommand) 1075 1076 -- Decode based on bitlength 1077 if liBitLength == 12 then 1078 luup.log("decodeHomeEasyHeater12") 1079 elseif liBitLength == 13 then 1080 luup.log("decodeMertikMaxitrol13") 1081 elseif liBitLength == 20 then 1082 luup.log("decodeATIRemoteWonder20") 1083 elseif liBitLength == 22 then 1084 luup.log("decodeRobocamNinja22") 1085 elseif liBitLength == 24 then 1086 luup.log("decodeArc24") 1087 luup.log("decodeWaveman24") 1088 elseif liBitLength == 25 then 1089 luup.log("decodeHarrison25") 1090 elseif liBitLength == 26 then 1091 luup.log("decodeIkeaKoppla26") 1092 elseif liBitLength == 32 then 1093 luup.log("decodeX1032") 1094 luup.log("decodeDM1032") 1095 luup.log("decodePCRemote32") 1096 luup.log("decodeRFXSensor32") 1066 1097 lsRFXMSG,lnSensorType,lsID,lsCmd,lsSensorManufacturer = decodeX10( psCommand ) 1067 1068 luup.log("decodeHomeEasy33") 1069 1070 1071 1072 1073 1074 luup.log("decodeHomeEasy37") 1075 1076 1077 1078 1079 luup.log("decodeDigimaxRTS1044") 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 ------------------------------------------------------------------------------------ 1091 1092 1093 1094 1095 1096 ------------------------------------------------------------------------------------ 1097 1098 1099 1100 1101 1102 1103 actOnMessage(lnSensorType,lsID,lsCmd) 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1098 elseif liBitLength == 33 then 1099 luup.log("decodeHomeEasy33") 1100 elseif liBitLength == 34 then 1101 lsRFXMSG,lnSensorType,lsID,lsCmd,lsSensorManufacturer = decodeHomeEasy34(psCommand) 1102 elseif liBitLength == 36 then 1103 lsRFXMSG,lnSensorType,lsID,lsCmd,lsSensorManufacturer = decodeHomeEasy36(psCommand) 1104 elseif liBitLength == 37 then 1105 luup.log("decodeHomeEasy37") 1106 elseif liBitLength == 41 then 1107 luup.log("decodeX10Security41") 1108 lsRFXMSG,lnSensorType,lsID,lsCmd,lsSensorManufacturer = decodeVisonic(psCommand) 1109 elseif liBitLength == 44 then 1110 luup.log("decodeDigimaxRTS1044") 1111 elseif liBitLength == 47 then 1112 luup.log("decodeCheaperTronics47") 1113 elseif liBitLength == 56 or liBitLength > 59 then 1114 luup.log("decodeoregon") 1115 lsRFXMSG,lnSensorType,lsID,lsCmd,lsSensorManufacturer = decodeOregon(psCommand) 1116 end 1117 1118 if ( string.len( lsRFXMSG ) == 0 ) then 1119 luup.log("Unknown Msg : " .. formattohex(psCommand) ) 1120 else 1121 ------------------------------------------------------------------------------------ 1122 -- ignore repeated messages. 1123 -- Really new and decoded messages must be processed. After processing, update 1124 -- last message variable 1125 -- Unfortunately this sometimes has an unwanted effect. This is why after a pause we need 1126 -- to forget the last message... 1127 ------------------------------------------------------------------------------------ 1128 1129 if ((os.time() - RFXLastMsgTime) > 10) then 1130 RFXLastMsg = "" 1131 end 1132 1133 if ( RFXLastMsg ~= lsRFXMSG ) then 1134 actOnMessage(lnSensorType,lsID,lsCmd) 1135 luup.variable_set("urn:upnp-esweb-nl:serviceId:rfxcom1", "Message", lsRFXMSG, THIS_DEVICE) 1136 luup.log( lsRFXMSG ) 1137 end 1138 end 1139 1140 RFXLastMsgTime = os.time() 1141 RFXLastMsg = lsRFXMSG 1142 end 1143 end 1144 1145 1146 ------------------------------------------------------------------------ 1147 -- Act on decoded message 1148 -- 1149 -- If variable 'AutoCreate' is set to 1 and a received sensor doesn't 1150 -- exist yet, it's created. 1151 -- Next execution depends on kind of sensor 1152 -- Controller (lightswitch): Status variable is set based on cmdOn or cmdOff 1153 -- Motion Sensor: Tripped status is set 1154 -- Door Sensor: Tripped status is set 1155 -- KeyFox: All door and motion sensors are armed or disarmed 1156 ------------------------------------------------------------------------ 1157 1158 function actOnMessage(lnSensorType,lsID,lsCmd) 1159 1160 luup.log("Received command " .. lsCmd .. " for " .. lnSensorType .. " with ID " .. lsID) 1161 1162 -- Check if we can find a device with the decoded ID and ourself as parent 1163 local device = findChild(THIS_DEVICE, lsID ) 1133 1164 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 ------------------------------------------------------------------------------------ 1144 -- First add all 'old' children to the three1145 1146 ------------------------------------------------------------------------------------ 1147 1148 1149 1150 1151 ------------------------------------------------------------------------------------ 1152 1153 ------------------------------------------------------------------------------------ 1154 1155 1156 1157 end 1158 ------------------------------------------------------------------------------------ 1159 1160 ------------------------------------------------------------------------------------ 1161 1162 1163 1164 end 1165 ------------------------------------------------------------------------------------ 1166 1167 ------------------------------------------------------------------------------------ 1168 1169 1170 1171 end 1172 ------------------------------------------------------------------------------------ 1173 1174 ------------------------------------------------------------------------------------ 1175 1176 1177 1178 1179 1180 ------------------------------------------------------------------------------------ 1181 1182 ------------------------------------------------------------------------------------ 1183 1184 1185 1186 1187 end 1188 ------------------------------------------------------------------------------------ 1189 1190 ------------------------------------------------------------------------------------ 1191 1192 1193 1194 end 1195 ------------------------------------------------------------------------------------ 1196 1197 ------------------------------------------------------------------------------------ 1198 1199 1200 1201 end 1202 1203 ------------------------------------------------------------------------------------ 1204 1205 ------------------------------------------------------------------------------------ 1206 1207 1208 1209 end 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 ------------------------------------------------------------------------------------ 1220 1221 ------------------------------------------------------------------------------------ 1222 1223 1224 1225 ------------------------------------------------------------------------------------ 1226 1227 ------------------------------------------------------------------------------------ 1228 1229 1230 1231 1232 1233 1234 1235 ------------------------------------------------------------------------------------ 1236 1237 ------------------------------------------------------------------------------------ 1238 1239 1240 1241 1242 1243 1244 1245 ------------------------------------------------------------------------------------ 1246 1247 ------------------------------------------------------------------------------------ 1248 1249 1250 1251 1252 1253 1254 1255 ------------------------------------------------------------------------------------ 1256 1257 ------------------------------------------------------------------------------------ 1258 1259 1260 1261 1262 1263 1264 end 1265 ------------------------------------------------------------------------------------ 1266 1267 ------------------------------------------------------------------------------------ 1268 1269 1270 "urn:schemas-micasaverde-com:device:WindowCovering:1","D_RFXCOMHarrison.xml","","",false) 1271 1272 1273 end 1274 ------------------------------------------------------------------------------------ 1275 1276 ------------------------------------------------------------------------------------ 1277 1278 1279 1280 1281 1282 end 1283 ------------------------------------------------------------------------------------ 1284 1285 ------------------------------------------------------------------------------------ 1286 1287 1288 1289 1290 1291 end 1292 ------------------------------------------------------------------------------------ 1293 1294 ------------------------------------------------------------------------------------ 1295 1296 1297 1298 1299 1300 end 1301 1302 ------------------------------------------------------------------------------------ 1303 1304 ------------------------------------------------------------------------------------ 1305 1306 1307 1308 1309 1310 end 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 --" v.device_type: " .. tostring(v.device_type) ..1357 --" v.device_num_parent: " .. tostring(v.device_num_parent) ..1358 --" v.id: " .. tostring(v.id)1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 -- Set trip state keyfoxas indication home or away1373 1374 1375 1376 1377 1378 1379 1380 --local newArmedValue = "1" -- armed1381 --local newTrippedValue = "1" -- home1382 1383 --if lsCmd == RFXConstants.cmdDisarm then1384 --newArmedValue = "0"1385 --newTrippedValue = "0"1386 --end1387 --if lsCmd == RFXConstants.cmdArmAway then newTrippedValue = "0" end1388 1389 --luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Armed",newArmedValue, device)1390 --luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", newTrippedValue, device)1391 1392 1393 elseif lsCmd == RFXConstants.cmdOnthen1394 1395 1396 1397 1398 1399 1400 1401 elseif lsCmd == RFXConstants.cmdOffthen1402 1403 1404 1405 1406 1407 1408 1409 end 1410 end 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 end 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 end 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 --luup.log("Key=" .. lsKey .. ";Value=" .. lsValue .. ";")1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 luup.variable_set("urn:micasaverde-com:serviceId:HaDevice1", "BatteryLevel", lsValue, device)1520 1521 1522 1523 1524 1525 1526 1527 1165 ---------------------------------------------------------------------------------------- 1166 -- If we can't find a device and we have autocreate active, setup a new tree with child devices 1167 -- and add a new child with the correct type and ID 1168 ---------------------------------------------------------------------------------------- 1169 if device == nil and luup.variable_get("urn:upnp-esweb-nl:serviceId:rfxcom1", "AutoCreate", lul_device) == "1" then 1170 luup.log( "device not found and autocreate enabled..." ) 1171 1172 local child_devices = luup.chdev.start(THIS_DEVICE); 1173 1174 ------------------------------------------------------------------------------------ 1175 -- First add all 'old' children to the tree 1176 -- Start with door sensors 1177 ------------------------------------------------------------------------------------ 1178 for teller = 1, RFXCountDS do 1179 luup.chdev.append(THIS_DEVICE, child_devices, RFXDevicesDS[teller], "RFX DS sensor #" .. RFXDevicesDS[teller] , 1180 "urn:schemas-micasaverde-com:device:DoorSensor:1","D_DoorSensor1.xml","","",false) 1181 end 1182 ------------------------------------------------------------------------------------ 1183 -- Next with motion sensors 1184 ------------------------------------------------------------------------------------ 1185 for teller = 1, RFXCountMS do 1186 luup.chdev.append(THIS_DEVICE, child_devices, RFXDevicesMS[teller], "RFX MS sensor #" .. RFXDevicesMS[teller] , 1187 "urn:schemas-micasaverde-com:device:MotionSensor:1","D_MotionSensor1.xml","","",false) 1188 end 1189 ------------------------------------------------------------------------------------ 1190 -- Next with keyfobs 1191 ------------------------------------------------------------------------------------ 1192 for teller = 1, RFXCountKF do 1193 luup.chdev.append(THIS_DEVICE, child_devices, RFXDevicesKF[teller], "RFX KF sensor #" .. RFXDevicesKF[teller] , 1194 "urn:schemas-ActiveRFID:device:RFIDTransmitter:1","D_RFIDTransmitter.xml","","",false) 1195 end 1196 ------------------------------------------------------------------------------------ 1197 -- Next with light switches 1198 ------------------------------------------------------------------------------------ 1199 for teller = 1, RFXCountLS do 1200 luup.chdev.append(THIS_DEVICE, child_devices, RFXDevicesLS[teller], "RFX LS #" .. RFXDevicesLS[teller] , 1201 "urn:schemas-upnp-org:device:BinaryLight:1","D_BinaryLight1.xml","","",false) 1202 end 1203 ------------------------------------------------------------------------------------ 1204 -- Next Harrison window covering 1205 ------------------------------------------------------------------------------------ 1206 for teller = 1, RFXCOM_HAR_Count do 1207 luup.chdev.append(THIS_DEVICE, child_devices, RFXCOM_HAR_Devices[teller], 1208 "Harrison #" .. RFXCOM_HAR_Devices[teller] , "urn:schemas-micasaverde-com:device:WindowCovering:1", 1209 "D_RFXCOMHarrison.xml","","",false) 1210 end 1211 ------------------------------------------------------------------------------------ 1212 -- Next with temperature devices 1213 ------------------------------------------------------------------------------------ 1214 for teller = 1, RFXCountTS2 do 1215 luup.log("debut temp:" .. RFXDevicesTS2[teller]) 1216 luup.chdev.append(THIS_DEVICE, child_devices, RFXDevicesTS2[teller], "RFX TS #" .. RFXDevicesTS2[teller] , 1217 "urn:schemas-micasaverde-com:device:TemperatureSensor:1", "D_TemperatureSensor1.xml","","",false) 1218 end 1219 ------------------------------------------------------------------------------------ 1220 -- Next with humidity devices 1221 ------------------------------------------------------------------------------------ 1222 for teller = 1, RFXCountHS2 do 1223 luup.chdev.append(THIS_DEVICE, child_devices, RFXDevicesHS2[teller], "RFX HS #" .. RFXDevicesHS2[teller] , 1224 "urn:schemas-micasaverde-com:device:HumiditySensor:1", "D_HumiditySensor1.xml","","",false) 1225 end 1226 ------------------------------------------------------------------------------------ 1227 -- Next with barometer devices 1228 ------------------------------------------------------------------------------------ 1229 for teller = 1, RFXCountBS2 do 1230 luup.chdev.append(THIS_DEVICE, child_devices, RFXDevicesBS2[teller], "RFX BS #" .. RFXDevicesBS2[teller] , 1231 "urn:schemas-micasaverde-com:device:BarometerSensor:1", "D_BarometerSensor1.xml","","",false) 1232 end 1233 1234 ------------------------------------------------------------------------------------ 1235 -- Next with rain devices 1236 ------------------------------------------------------------------------------------ 1237 for teller = 1, RFXCountRS2 do 1238 luup.chdev.append(THIS_DEVICE, child_devices, RFXDevicesRS2[teller], "RFX RS #" .. RFXDevicesRS2[teller] , 1239 "urn:schemas-micasaverde-com:device:RainSensor:1", "D_RainSensor1.xml","","",false) 1240 end 1241 1242 ------------------------------------------------------------------------------------ 1243 -- Next with EZAnemoSensor devices 1244 ------------------------------------------------------------------------------------ 1245 for teller = 1, RFXCountAS2 do 1246 luup.chdev.append(THIS_DEVICE, child_devices, RFXDevicesAS2[teller], "RFX AS #" .. RFXDevicesAS2[teller] , 1247 "urn:schemas-upnp-org:device:EZAnemoSensor:1", "D_EZAnemoSensor.xml","","",false) 1248 end 1249 1250 ------------------------------------------------------------------------------------ 1251 -- Now add the new device to the tree depending on the sensor type 1252 ------------------------------------------------------------------------------------ 1253 1254 luup.log("Tree buildup, now add " .. lsID .. " with sensortype " .. lnSensorType) 1255 1256 ------------------------------------------------------------------------------------ 1257 -- Add if doorsensor 1258 ------------------------------------------------------------------------------------ 1259 if bitw.band(lnSensorType,RFXConstants.sensorTypeDoor) ~= 0 then 1260 luup.log("CREATING CHILD DEVICE DOOR SENSOR WITH ID " .. lsID) 1261 luup.chdev.append(THIS_DEVICE, child_devices, lsID, "RFX DS sensor #" .. lsID , 1262 "urn:schemas-micasaverde-com:device:DoorSensor:1","D_DoorSensor1.xml","","",false) 1263 RFXCountDS = RFXCountDS + 1 1264 RFXDevicesDS[RFXCountDS] = lsID 1265 end 1266 ------------------------------------------------------------------------------------ 1267 -- Add if motionsensor 1268 ------------------------------------------------------------------------------------ 1269 if bitw.band(lnSensorType,RFXConstants.sensorTypeMotion) ~= 0 then 1270 luup.log("CREATING CHILD DEVICE MOTION SENSOR WITH ID " .. lsID) 1271 luup.chdev.append(THIS_DEVICE, child_devices, lsID, "RFX MS sensor #" .. lsID , 1272 "urn:schemas-micasaverde-com:device:MotionSensor:1","D_MotionSensor1.xml","","",false) 1273 RFXCountMS = RFXCountMS + 1 1274 RFXDevicesMS[RFXCountMS] = lsID 1275 end 1276 ------------------------------------------------------------------------------------ 1277 -- Add if keybof 1278 ------------------------------------------------------------------------------------ 1279 if bitw.band(lnSensorType,RFXConstants.sensorTypeKeyFob) ~= 0 then 1280 luup.log("CREATING CHILD DEVICE KEYFOB WITH ID " .. lsID) 1281 luup.chdev.append(THIS_DEVICE, child_devices, "KF/" .. lsID, "RFX KF sensor #" .. lsID , 1282 "urn:schemas-ActiveRFID:device:RFIDTransmitter:1","D_RFIDTransmitter.xml","","",false) 1283 RFXCountKF = RFXCountKF + 1 1284 RFXDevicesKF[RFXCountKF] = "KF/" .. lsID 1285 end 1286 ------------------------------------------------------------------------------------ 1287 -- Add if lightswitch 1288 ------------------------------------------------------------------------------------ 1289 if bitw.band(lnSensorType,RFXConstants.sensorTypeControler) ~= 0 then 1290 luup.log("CREATING CHILD DEVICE LIGHT SWITCH WITH ID " .. lsID) 1291 luup.chdev.append(THIS_DEVICE, child_devices, lsID, "RFX LS #" .. lsID , 1292 "urn:schemas-upnp-org:device:BinaryLight:1","D_BinaryLight1.xml","","",false) 1293 RFXCountLS = RFXCountLS + 1 1294 RFXDevicesLS[RFXCountLS] = lsID 1295 end 1296 ------------------------------------------------------------------------------------ 1297 -- Add if Harrison window covering 1298 ------------------------------------------------------------------------------------ 1299 if bitw.band(lnSensorType,RFXConstants.sensorTypeWindowCovering) ~= 0 then 1300 luup.chdev.append(THIS_DEVICE, child_devices, lsID, "Harrison #" .. lsID , 1301 "urn:schemas-micasaverde-com:device:WindowCovering:1","D_RFXCOMHarrison.xml","","",false) 1302 RFXCOM_HAR_Count = RFXCOM_HAR_Count + 1 1303 RFXCOM_HAR_Devices[RFXCOM_HAR_Count] = lsID 1304 end 1305 ------------------------------------------------------------------------------------ 1306 -- Add temperature sensor 1307 ------------------------------------------------------------------------------------ 1308 if bitw.band(lnSensorType,RFXConstants.sensorTypeTemperature) ~= 0 then 1309 luup.chdev.append(THIS_DEVICE, child_devices, "TS/" .. lsID, "RFX TS #" .. lsID, 1310 "urn:schemas-micasaverde-com:device:TemperatureSensor:1", "D_TemperatureSensor1.xml","","",false) 1311 RFXCountTS2 = RFXCountTS2 + 1 1312 RFXDevicesTS2[RFXCountTS2] = "TS/" .. lsID 1313 end 1314 ------------------------------------------------------------------------------------ 1315 -- Add humidity sensor 1316 ------------------------------------------------------------------------------------ 1317 if bitw.band(lnSensorType,RFXConstants.sensorTypeHumidity) ~= 0 then 1318 luup.chdev.append(THIS_DEVICE, child_devices, "HS/" .. lsID, "RFX HS #" .. lsID, 1319 "urn:schemas-micasaverde-com:device:HumiditySensor:1", "D_HumiditySensor1.xml","","",false) 1320 RFXCountHS2 = RFXCountHS2 + 1 1321 RFXDevicesHS2[RFXCountHS2] = "HS/" .. lsID 1322 end 1323 ------------------------------------------------------------------------------------ 1324 -- Add barometer sensor 1325 ------------------------------------------------------------------------------------ 1326 if bitw.band(lnSensorType,RFXConstants.sensorTypeBarometer) ~= 0 then 1327 luup.chdev.append(THIS_DEVICE, child_devices, "BS/" .. lsID, "RFX BS #" .. lsID, 1328 "urn:schemas-micasaverde-com:device:BarometerSensor:1", "D_BarometerSensor1.xml","","",false) 1329 RFXCountBS2 = RFXCountBS2 + 1 1330 RFXDevicesBS2[RFXCountBS2] = "BS/" .. lsID 1331 end 1332 1333 ------------------------------------------------------------------------------------ 1334 -- Add rain sensor 1335 ------------------------------------------------------------------------------------ 1336 if bitw.band(lnSensorType,RFXConstants.sensorTypeRain) ~= 0 then 1337 luup.chdev.append(THIS_DEVICE, child_devices, "RS/" .. lsID, "RFX RS #" .. lsID, 1338 "urn:schemas-micasaverde-com:device:RainSensor:1", "D_RainSensor1.xml","","",false) 1339 RFXCountRS2 = RFXCountRS2 + 1 1340 RFXDevicesRS2[RFXCountRS2] = "RS/" .. lsID 1341 end 1342 1343 ------------------------------------------------------------------------------------ 1344 -- Add D_EZAnemoSensor sensor 1345 ------------------------------------------------------------------------------------ 1346 if bitw.band(lnSensorType,RFXConstants.sensorTypeWindDirection) ~= 0 then 1347 luup.chdev.append(THIS_DEVICE, child_devices, "AS/" .. lsID, "RFX AS #" .. lsID, 1348 "urn:schemas-upnp-org:device:EZAnemoSensor:1", "D_EZAnemoSensor.xml","","",false) 1349 RFXCountAS2 = RFXCountAS2 + 1 1350 RFXDevicesAS2[RFXCountAS2] = "AS/" .. lsID 1351 end 1352 1353 1354 1355 luup.log("Tree buildup with number child devices:") 1356 luup.log(" door sensors: " .. RFXCountDS) 1357 luup.log(" motion sensors: " .. RFXCountMS) 1358 luup.log(" keyfob sensors: " .. RFXCountKF) 1359 luup.log(" light switches: " .. RFXCountLS) 1360 luup.log(" window coverings: " .. RFXCOM_HAR_Count) 1361 luup.log("temperature sensors: " .. RFXCountTS2) 1362 luup.log(" humidity sensors: " .. RFXCountHS2) 1363 luup.log(" pressure sensors: " .. RFXCountBS2) 1364 luup.log(" rain sensors: " .. RFXCountRS2) 1365 luup.log(" Anemo sensors: " .. RFXCountAS2) 1366 1367 -- Synch the new tree with the old three 1368 luup.log("Start sync") 1369 luup.chdev.sync(THIS_DEVICE, child_devices) 1370 luup.log("End sync") 1371 end 1372 1373 ------------------------------------------------------------------------------ 1374 -- Deliver message to all devices with the correct altid (multiple 1375 -- devices can have the correct altid!) 1376 ------------------------------------------------------------------------------ 1377 1378 local fullId = "" 1379 for k, v in pairs(luup.devices) do 1380 -- Check if we have a device with the correct parent (THIS_DEVICE) and 1381 -- altid we are looking for (lsID) 1382 if (v.device_num_parent == THIS_DEVICE) then 1383 device = k 1384 1385 -- luup.log("Device found or created, now processing command " .. lsCmd .. " for " .. lsID) 1386 -- luup.log("Device Number: " .. k .. 1387 -- " v.device_type: " .. tostring(v.device_type) .. 1388 -- " v.device_num_parent: " .. tostring(v.device_num_parent) .. 1389 -- " v.id: " .. tostring(v.id) 1390 -- ) 1391 1392 -- Execution door sensors same as motion sensors 1393 if bitw.band(lnSensorType,RFXConstants.sensorTypeDoor) ~= 0 or bitw.band(lnSensorType,RFXConstants.sensorTypeMotion) ~= 0 1394 and v.id == lsId then 1395 local TrippedValue = "0" 1396 if lsCmd == RFXConstants.cmdAlert then TrippedValue = "1" end 1397 luup.log( "Set tripped value " .. TrippedValue .. " to device " .. lsID ) 1398 luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", TrippedValue, device) 1399 end 1400 1401 -- Execution for keyfobs 1402 -- Arm or Disarm all door and motion sensors when keyfob armed or disarmed 1403 -- Set trip state keyfob as indication home or away 1404 fullId = "KF/" .. lsID 1405 if bitw.band(lnSensorType,RFXConstants.sensorTypeKeyFob) ~= 0 1406 and v.id == fullId then 1407 luup.log("KeyFob action: " .. lsCmd) 1408 1409 if lsCmd == RFXConstants.cmdArmAway or lsCmd == RFXConstants.cmdArmHome or lsCmd == RFXConstants.cmdDisarm then 1410 ArmDisarmAll(lsCmd) 1411 -- local newArmedValue = "1" -- armed 1412 -- local newTrippedValue = "1" -- home 1413 1414 -- if lsCmd == RFXConstants.cmdDisarm then 1415 -- newArmedValue = "0" 1416 -- newTrippedValue = "0" 1417 -- end 1418 -- if lsCmd == RFXConstants.cmdArmAway then newTrippedValue = "0" end 1419 -- luup.log( "Set ArmedValue value " .. newArmedValue .. " to device " .. device ) 1420 -- luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Armed",newArmedValue, device) 1421 -- luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", newTrippedValue, device) 1422 elseif lsCmd == RFXConstants.cmdPanic then 1423 -- not implemented 1424 elseif lsCmd == RFXConstants.cmdOn then 1425 luup.log("urn:ActiveRFID:serviceId:RFIDTransmitter1 Action:On:Portail" .. fullId) 1426 local Pstatus = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1","Status",26) 1427 if Pstatus == "0" then 1428 luup.variable_set("urn:upnp-org:serviceId:SwitchPower1","Status","1",26) 1429 else 1430 luup.variable_set("urn:upnp-org:serviceId:SwitchPower1","Status","0",26) 1431 end 1432 elseif lsCmd == RFXConstants.cmdOff then 1433 luup.log("urn:ActiveRFID:serviceId:RFIDTransmitter1 Action:Off:Garage" .. fullId) 1434 local Pstatus = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1","Status",27) 1435 if Pstatus == "0" then 1436 luup.variable_set("urn:upnp-org:serviceId:SwitchPower1","Status","1",27) 1437 else 1438 luup.variable_set("urn:upnp-org:serviceId:SwitchPower1","Status","0",27) 1439 end 1440 end 1441 end 1442 1443 -- Execution light switches. 1444 -- Set Status based on cmdOn or cmdOff 1445 if bitw.band(lnSensorType,RFXConstants.sensorTypeControler) ~= 0 1446 and v.id == lsID then 1447 local newTargetValue = "0" 1448 1449 if lsCmd == RFXConstants.cmdOn then newTargetValue = "1" end 1450 if lsCmd == RFXConstants.cmdGroupOn then newTargetValue = "1" end 1451 1452 luup.log("SET TARGET from " .. lsID .. " with value " .. newTargetValue) 1453 luup.variable_set("urn:upnp-org:serviceId:SwitchPower1","Status",newTargetValue,device) 1454 end 1455 1456 -- Execution for temperature sensor 1457 -- Set temperature to command 1458 fullId = "TS/" .. lsID 1459 if bitw.band(lnSensorType,RFXConstants.sensorTypeTemperature) ~= 0 1460 and tostring(v.device_type) == "urn:schemas-micasaverde-com:device:TemperatureSensor:1" 1461 and v.id == fullId then 1462 for lsKey,lsValue in string.gmatch(lsCmd, "(%w+)=([%w%.%-_]+)") do 1463 -- luup.log("Key=" .. lsKey .. ";Value=" .. lsValue .. ";") 1464 if lsKey == "temperature" then 1465 luup.log("SET CURRENTTEMPERATURE from " .. lsID .. " with value " .. lsValue) 1466 luup.variable_set("urn:upnp-org:serviceId:TemperatureSensor1", "CurrentTemperature", 1467 lsValue, device) 1468 elseif lsKey == "battery" then 1469 luup.log("SET BATTERY from " .. lsID .. " with value " .. lsValue) 1470 luup.variable_set("urn:micasaverde-com:serviceId:HaDevice1", "BatteryLevel", lsValue, device) 1471 end 1472 end 1473 end 1474 1475 -- Execution for humidity sensor 1476 -- Set humidity to command 1477 fullId = "HS/" .. lsID 1478 if bitw.band(lnSensorType,RFXConstants.sensorTypeHumidity) ~= 0 1479 and tostring(v.device_type) == "urn:schemas-micasaverde-com:device:HumiditySensor:1" 1480 and v.id == fullId then 1481 for lsKey,lsValue in string.gmatch(lsCmd, "(%w+)=([%w%.%-_]+)") do 1482 -- luup.log("Key=" .. lsKey .. ";Value=" .. lsValue .. ";") 1483 if lsKey == "humidity" then 1484 luup.log("SET CURRENTLEVEL from " .. lsID .. " with value " .. lsValue) 1485 luup.variable_set("urn:micasaverde-com:serviceId:HumiditySensor1", "CurrentLevel", 1486 lsValue, device) 1487 elseif lsKey == "battery" then 1488 luup.log("SET BATTERY from " .. lsID .. " with value " .. lsValue) 1489 luup.variable_set("urn:micasaverde-com:serviceId:HaDevice1", "BatteryLevel", lsValue, device) 1490 end 1491 end 1492 end 1493 1494 -- Execution for pressure sensor 1495 -- Set pressure to command 1496 fullId = "BS/" .. lsID 1497 if bitw.band(lnSensorType,RFXConstants.sensorTypeBarometer) ~= 0 1498 and tostring(v.device_type) == "urn:schemas-micasaverde-com:device:BarometerSensor:1" 1499 and v.id == fullId then 1500 for lsKey,lsValue in string.gmatch(lsCmd, "(%w+)=([%w%.%-_]+)") do 1501 -- luup.log("Key=" .. lsKey .. ";Value=" .. lsValue .. ";") 1502 if lsKey == "pressure" then 1503 luup.log("SET CURRENTPRESSURE from " .. lsID .. " with value " .. lsValue) 1504 luup.variable_set("urn:upnp-org:serviceId:BarometerSensor1", "CurrentPressure", 1505 lsValue, device) 1506 elseif lsKey == "battery" then 1507 luup.log("SET BATTERY from " .. lsID .. " with value " .. lsValue) 1508 luup.variable_set("urn:micasaverde-com:serviceId:HaDevice1", "BatteryLevel", lsValue, device) 1509 end 1510 end 1511 end 1512 fullId = "RS/" .. lsID 1513 if bitw.band(lnSensorType,RFXConstants.sensorTypeRain) ~= 0 1514 and tostring(v.device_type) == "urn:schemas-micasaverde-com:device:RainSensor:1" 1515 and v.id == fullId then 1516 for lsKey,lsValue in string.gmatch(lsCmd, "(%w+)=([%w%.%-_]+)") do 1517 -- luup.log("Key=" .. lsKey .. ";Value=" .. lsValue .. ";") 1518 if lsKey == "rain" then 1519 luup.log("SET CURRENTRAIN from " .. lsID .. " with value " .. lsValue) 1520 luup.variable_set("urn:upnp-org:serviceId:RainSensor1", "CurrentRain", lsValue, device) 1521 elseif lsKey == "train" then 1522 luup.log("SET CURRENTTRAIN from " .. lsID .. " with value " .. lsValue) 1523 luup.variable_set("urn:upnp-org:serviceId:RainSensor1", "CurrentTRain", lsValue, device) 1524 elseif lsKey == "battery" then 1525 luup.log("SET BATTERY from " .. lsID .. " with value " .. lsValue) 1526 luup.variable_set("urn:micasaverde-com:serviceId:HaDevice1", "BatteryLevel", lsValue, device) 1527 end 1528 end 1529 end 1530 fullId = "AS/" .. lsID 1531 if bitw.band(lnSensorType,RFXConstants.sensorTypeWindDirection) ~= 0 1532 and tostring(v.device_type) == "urn:schemas-upnp-org:device:EZAnemoSensor:1" 1533 and v.id == fullId then 1534 for lsKey,lsValue in string.gmatch(lsCmd, "(%w+)=([%w%.%-_]+)") do 1535 luup.log("Key=" .. lsKey .. ";Value=" .. lsValue .. ";") 1536 if lsKey == "direction" then 1537 luup.log("SET DIRECTION from " .. lsID .. " with value " .. lsValue) 1538 luup.variable_set("urn:upnp-org:serviceId:EZAnemoSensor1", "Direction", lsValue, device) 1539 end 1540 if lsKey == "speed" then 1541 luup.log("SET SPEED from " .. lsID .. " with value " .. lsValue) 1542 luup.variable_set("urn:upnp-org:serviceId:EZAnemoSensor1", "Speed", lsValue, device) 1543 end 1544 if lsKey == "speedav" then 1545 luup.log("SET SPEEDAV from " .. lsID .. " with value " .. lsValue) 1546 luup.variable_set("urn:upnp-org:serviceId:EZAnemoSensor1", "SpeedAv", lsValue, device) 1547 end 1548 if lsKey == "battery" then 1549 luup.log("SET BATTERY from " .. lsID .. " with value " .. lsValue) 1550 luup.variable_set("urn:upnp-org:serviceId:EZAnemoSensor1", "Battery", lsValue, device) 1551 end 1552 end 1553 end 1554 end 1555 1556 end 1557 1558 end 1528 1559 1529 ------------------------------------------------------------------------ 1530 -- Arm or Disarm 1531 -- 1532 -- Arm or Disarm all motion and door sensors based on command given. 1533 -- KeyFob sensor gets armed or disarmed also and trip state 1534 -- is used to indicate home or away status (triped = home) 1535 ------------------------------------------------------------------------ 1536 1537 function ArmDisarmAll(lsCmd) 1538 local newArmedValue = "1" -- armed 1539 local newTrippedValue = "1" -- home 1540 1541 if lsCmd == RFXConstants.cmdDisarm then 1542 newArmedValue = "0" 1543 newTrippedValue = "0" 1544 end 1545 if lsCmd == RFXConstants.cmdArmAway then newTrippedValue = "0" end 1546 luup.log("urn:ActiveRFID:serviceId:RFIDTransmitter1 Action::SetArmed:" .. newArmedValue .. "device:" .. RFXDevicesKF[1]) 1547 luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Armed",newArmedValue, 41) 1548 luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Armed",newArmedValue, 42) 1549 luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Armed",newArmedValue, 43) 1550 luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Armed",newArmedValue, 44) 1551 1552 -- Iterate all door sensors and set armed value 1553 -- for teller = 1, RFXCountDS do 1554 -- local lsOtherDevices = findChild(THIS_DEVICE, RFXDevicesDS[teller] ) 1555 1556 -- luup.log("Action::SetArmed: " .. newArmedValue .. " for door sensor device " .. RFXDevicesDS[teller] .. "/" .. lsOtherDevices) 1557 -- luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Armed",newArmedValue,lsOtherDevices) 1558 -- end 1559 1560 -- Iterate all motion sensors and set armed value 1561 -- for teller = 1, RFXCountMS do 1562 -- local lsOtherDevices = findChild(THIS_DEVICE, RFXDevicesMS[teller] ) 1563 -- 1564 -- luup.log("Action::SetArmed: " .. newArmedValue .. " for motion sensor device " .. RFXDevicesMS[teller] .. "/" .. lsOtherDevices) 1565 -- luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Armed",newArmedValue,lsOtherDevices) 1566 1567 -- end 1568 1569 -- Iterate all keyfobs and set armed value and 1570 -- set tripped value based on armed-home (1) or armed-away (0) 1571 -- for teller = 1, RFXCountKF do 1572 -- local lsOtherDevices = findChild(THIS_DEVICE, RFXDevicesKF[teller] ) 1573 -- 1574 -- luup.log("Action::SetArmed: " .. newArmedValue .. "for KeyFob device " .. RFXDevicesKF[teller] .. "/" .. lsOtherDevices) 1575 -- luup.log("Action::SetTripped: " .. newTrippedValue .. "for KeyFob device " .. RFXDevicesKF[teller] .. "/" .. lsOtherDevices) 1576 -- 1577 -- luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Armed",newArmedValue,lsOtherDevices) 1578 -- luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Tripped",newTrippedValue,lsOtherDevices) 1579 --end 1580 end 1581 1582 1560 ------------------------------------------------------------------------ 1561 -- Arm or Disarm 1562 -- 1563 -- Arm or Disarm all motion and door sensors based on command given. 1564 -- KeyFob sensor gets armed or disarmed also and trip state 1565 -- is used to indicate home or away status (tripped = home) 1566 ------------------------------------------------------------------------ 1567 1568 function ArmDisarmAll(lsCmd) 1569 local newArmedValue = "1" -- armed 1570 local newTrippedValue = "1" -- home 1571 1572 if lsCmd == RFXConstants.cmdDisarm then 1573 newArmedValue = "0" 1574 newTrippedValue = "0" 1575 end 1576 if lsCmd == RFXConstants.cmdArmAway then 1577 newTrippedValue = "0" 1578 end 1579 1580 -- Iterate all door sensors and set armed value 1581 for teller = 1, RFXCountDS do 1582 local lsOtherDevices = findChild(THIS_DEVICE, RFXDevicesDS[teller] ) 1583 1584 luup.log("Action::SetArmed: " .. newArmedValue .. " for door sensor device " .. RFXDevicesDS[teller] .. "/" .. lsOtherDevices) 1585 luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Armed",newArmedValue,lsOtherDevices) 1586 end 1587 1588 -- Iterate all motion sensors and set armed value 1589 for teller = 1, RFXCountMS do 1590 local lsOtherDevices = findChild(THIS_DEVICE, RFXDevicesMS[teller] ) 1591 1592 luup.log("Action::SetArmed: " .. newArmedValue .. " for motion sensor device " .. RFXDevicesMS[teller] .. "/" .. lsOtherDevices) 1593 luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Armed",newArmedValue,lsOtherDevices) 1594 1595 end 1596 1597 -- Iterate all keyfobs and set armed value and 1598 -- set tripped value based on armed-home (1) or armed-away (0) 1599 for teller = 1, RFXCountKF do 1600 local lsOtherDevices = findChild(THIS_DEVICE, RFXDevicesKF[teller] ) 1601 1602 luup.log("Action::SetArmed: " .. newArmedValue .. "for KeyFob device " .. RFXDevicesKF[teller] .. "/" .. lsOtherDevices) 1603 luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Armed",newArmedValue,lsOtherDevices) 1604 1605 luup.log("Action::SetTripped: " .. newTrippedValue .. "for KeyFob device " .. RFXDevicesKF[teller] .. "/" .. lsOtherDevices) 1606 luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Tripped",newTrippedValue,lsOtherDevices) 1607 end 1608 end 1609 1610 1583 1611 1584 1612 -- Thanks to guessed for this snippet. 1585 1613 function findChild(parentDevice, label) 1586 1614 for k, v in pairs(luup.devices) do 1587 1588 1615 if (v.device_num_parent == parentDevice and string.find(v.id, label .. "$", 1) ~= nil) then 1616 return k 1589 1617 end 1590 1618 end … … 1627 1655 1628 1656 <startup>mainStartup</startup> 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1657 <actionList> 1658 <action> 1659 <serviceId>urn:upnp-org:serviceId:SwitchPower1</serviceId> 1660 <name>SetTarget</name> 1661 <run> 1662 local ls_id = luup.devices[lul_device].id 1663 local lul_reverse = luup.variable_get("urn:micasaverde-com:serviceId:HaDevice1","ReverseOnOff",lul_device) 1664 1665 luup.log("SET TARGET from " .. ls_id .. " with value " .. lul_settings.newTargetValue) 1666 1667 if ( lul_settings.newTargetValue == "1" or (lul_settings.newTargetValue=="0" and lul_reverse=="1") ) then 1668 SendCmd( ls_id,RFXConstants.cmdOn ) 1669 else 1670 SendCmd( ls_id,RFXConstants.cmdOff ) 1671 end 1672 luup.variable_set("urn:upnp-org:serviceId:SwitchPower1","Status",lul_settings.newTargetValue,lul_device) 1673 </run> 1674 </action> 1675 1676 <action> 1677 <serviceId>urn:micasaverde-com:serviceId:SecuritySensor1</serviceId> 1678 <name>SetArmed</name> 1679 <run> 1680 --debug("Action::SetArmed:"..lul_settings.newArmedValue) 1681 luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1", "Armed", lul_settings.newArmedValue, lul_device) 1682 </run> 1683 </action> 1684 1685 <action> 1686 <serviceId>urn:micasaverde-com:serviceId:HaDevice1</serviceId> 1687 <name>ToggleState</name> 1688 <run> 1689 --debug("Action::ToggleState:" .. lul_device) 1690 </run> 1691 </action> 1692 1693 1694 <action> 1695 <serviceId>urn:upnp-esweb-nl:serviceId:rfxcom1</serviceId> 1696 <name>AddHarrisonCurtain</name> 1697 <run> 1698 local lsHouseCode = lul_settings.HouseCode 1699 actOnMessage(RFXConstants.sensorTypeWindowCovering,lsHouseCode,"") 1700 </run> 1701 </action> 1702 <action> 1703 <serviceId>urn:upnp-org:serviceId:WindowCovering1</serviceId> 1704 <name>Stop</name> 1705 <run> 1706 local har_id = luup.devices[lul_device].id 1707 SendHarrisonCmd( har_id, "STOP") 1708 </run> 1709 </action> 1710 <action> 1711 <serviceId>urn:upnp-org:serviceId:WindowCovering1</serviceId> 1712 <name>Up</name> 1713 <run> 1714 luup.variable_set("urn:upnp-esweb-nl:serviceId:RFXCOMHarrison1","CurtainStatus",0,lul_device) 1715 local har_id = luup.devices[lul_device].id 1716 SendHarrisonCmd( har_id, "OPEN") 1717 </run> 1718 </action> 1719 <action> 1720 <serviceId>urn:upnp-org:serviceId:WindowCovering1</serviceId> 1721 <name>Down</name> 1722 <run> 1723 luup.variable_set("urn:upnp-esweb-nl:serviceId:RFXCOMHarrison1","CurtainStatus",1,lul_device) 1724 local har_id = luup.devices[lul_device].id 1725 SendHarrisonCmd( har_id, "CLOSE") 1726 </run> 1727 </action> 1728 1729 <action> 1730 <serviceId>urn:upnp-esweb-nl:serviceId:RFXCOMHarrison1</serviceId> 1731 <name>SetStatus</name> 1732 <run> 1733 luup.variable_set("urn:upnp-esweb-nl:serviceId:RFXCOMHarrison1","CurtainStatus",lul_settings.newStatusValue,lul_device) 1734 local har_id = luup.devices[lul_device].id 1735 if ( lul_settings.newStatusValue == "1" ) then 1736 SendHarrisonCmd( har_id, "OPEN") 1737 else 1738 SendHarrisonCmd( har_id, "CLOSE") 1739 end 1740 </run> 1741 </action> 1742 <action> 1743 <serviceId>urn:upnp-esweb-nl:serviceId:RFXCOMHarrison1</serviceId> 1744 <name>GetStatus</name> 1745 <run> 1746 lul_settings.ResultStatus = luup.variable_get("urn:upnp-esweb-nl:serviceId:RFXCOMHarrison1","CurtainStatus",lul_device) 1747 </run> 1748 </action> 1749 </actionList> 1722 1750 </implementation> -
/D_EZAnemoSensor.xml
r20 r30 24 24 <SCPDURL>S_EZAnemoSensor.xml</SCPDURL> 25 25 </service> 26 <service> 27 <serviceType>urn:schemas-micasaverde-com:service:HaDevice:1</serviceType> 28 <serviceId>urn:micasaverde-com:serviceId:HaDevice1</serviceId> 29 <SCPDURL>S_HaDevice1.xml</SCPDURL> 30 </service> 26 31 </serviceList> 27 32 </device> -
/D_RainSensor1.xml
r20 r30 7 7 <device> 8 8 <deviceType>urn:schemas-micasaverde-com:device:RainSensor:1</deviceType> 9 <staticJson>D_RainSensor1.json</staticJson>9 <staticJson>D_RainSensor1.json</staticJson> 10 10 <serviceList> 11 11 <service>
Note: See TracChangeset
for help on using the changeset viewer.