Changeset 14
- Timestamp:
- 2012-04-21 10:50:03 (14 years ago)
- Files:
-
- 9 added
- 3 edited
-
D_BarometerSensor1.json (added)
-
D_BarometerSensor1.xml (added)
-
D_EZAnemoSensor.json (added)
-
D_EZAnemoSensor.xml (added)
-
D_RFXCOM.json (modified) (3 diffs)
-
D_RFXCOMHarrison.json (modified) (10 diffs)
-
D_RainSensor1.json (added)
-
D_RainSensor1.xml (added)
-
I_RFXCOM.xml (modified) (25 diffs)
-
S_BarometerSensor1.xml (added)
-
S_EZAnemoSensor.xml (added)
-
S_RainSensor1.xml (added)
Legend:
- Unmodified
- Added
- Removed
-
D_RFXCOM.json
r3 r14 7 7 "imgIconMax": "", 8 8 "halloIconsDir": "pics\/hallo", 9 "inScene": "0", 9 10 "DisplayStatus": { 10 11 }, … … 14 15 "doc_version": 1, 15 16 "doc_platform": 0, 16 "doc_page": "devices" 17 "doc_page": "devices" 17 18 }, 18 19 "Tabs": [ … … 20 21 "Label": { 21 22 "lang_tag": "tabname_control", 22 "text": "Settings" 23 "text": "Settings" 23 24 }, 24 25 "Position": "0", 25 26 "TabType": "flash", 27 "SceneGroup": [ 28 { 29 "id": 1, 30 "top": 0.5, 31 "left": 0, 32 "x": 2, 33 "y": 3 34 } 35 ], 26 36 "ControlGroup": [ 27 37 { 28 38 "id": "1", 29 "type": "info" 39 "type": "info", 40 "scenegroup": 1 30 41 } 31 42 ], 32 43 "Control": [ 33 { 34 "ControlType": "label", 35 "Label": { 36 "lang_tag": "lblMsg", 37 "text": "Last msg:" 38 }, 39 "Display": { 40 "Top": 110, 41 "Left": 20, 42 "Width": 75, 43 "Height": 20 44 } 45 }, 46 { 47 "ControlGroup":"1", 48 "ControlPair":"1", 49 "ControlHeader":"1", 50 "ControlType": "variable", 51 "Display": { 52 "Service": "urn:upnp-esweb-nl:serviceId:rfxcom1", 53 "Variable": "Message", 54 "Top": 110, 55 "Left": 100, 56 "Width": 500, 57 "Height": 20 58 } 59 }, 60 { 61 "ControlType": "label", 62 "Label": { 63 "lang_tag": "device_settings_page", 64 "text": "Port Read" 65 }, 66 "Display": { 67 "Top": 20, 68 "Left": 20, 69 "Width": 75, 70 "Height": 20 71 } 72 }, 73 { 74 "ControlType": "variable", 75 "Display": { 76 "Service": "urn:upnp-esweb-nl:serviceId:rfxcom1", 77 "Variable": "portRead", 78 "Top": 20, 79 "Left": 100, 80 "Width": 120, 81 "Height": 20 82 } 83 }, 84 { 85 "ControlType": "label", 86 "Label": { 87 "lang_tag": "device_settings_page", 88 "text": "Port Write" 89 }, 90 "Display": { 91 "Top": 50, 92 "Left": 20, 93 "Width": 75, 94 "Height": 20 95 } 96 }, 97 { 98 "ControlType": "variable", 99 "Display": { 100 "Service": "urn:upnp-esweb-nl:serviceId:rfxcom1", 101 "Variable": "portWrite", 102 "Top": 50, 103 "Left": 100, 104 "Width": 120, 105 "Height": 20 106 } 107 }, 108 { 109 "ControlType": "label", 110 "Label": { 111 "lang_tag": "device_settings_page", 112 "text": "Harrison curtain" 113 }, 114 "Display": { 115 "Top": 80, 116 "Left": 20, 117 "Width": 75, 118 "Height": 20 119 } 120 }, 121 { 122 "ControlType": "input", 123 "ID": "HarrisonCode", 124 "Display": { 125 "Top": 80, 126 "Left": 100, 127 "Width": 100, 128 "Height": 20 129 } 130 }, 131 { 132 "ControlType": "button", 133 "Label": { 134 "lang_tag": "cmd_add", 135 "text": "Add" 136 }, 137 "Display": { 138 "Top": 80, 139 "Left": 210, 140 "Width": 50, 141 "Height": 20 142 }, 143 "Command": { 144 "Service": "urn:upnp-esweb-nl:serviceId:rfxcom1", 145 "Action": "AddHarrisonCurtain", 146 "Parameters": [ 147 { 148 "Name": "HouseCode", 149 "ID": "HarrisonCode" 150 } 151 ] 152 } 153 } 154 ] 44 { 45 "ControlType": "label", 46 "Label": { 47 "lang_tag": "device_settings_page", 48 "text": "Port Read" 49 }, 50 "Display": { 51 "Top": 20, 52 "Left": 20, 53 "Width": 75, 54 "Height": 20 55 } 56 }, 57 { 58 "ControlType": "variable", 59 "Display": { 60 "Service": "urn:upnp-esweb-nl:serviceId:rfxcom1", 61 "Variable": "portRead", 62 "Top": 20, 63 "Left": 115, 64 "Width": 120, 65 "Height": 20 66 } 67 }, 68 { 69 "ControlType": "label", 70 "Label": { 71 "lang_tag": "device_settings_page", 72 "text": "Port Write" 73 }, 74 "Display": { 75 "Top": 50, 76 "Left": 20, 77 "Width": 75, 78 "Height": 20 79 } 80 }, 81 { 82 "ControlType": "variable", 83 "Display": { 84 "Service": "urn:upnp-esweb-nl:serviceId:rfxcom1", 85 "Variable": "portWrite", 86 "Top": 50, 87 "Left": 115, 88 "Width": 120, 89 "Height": 20 90 } 91 }, 92 { 93 "ControlType": "label", 94 "Label": { 95 "lang_tag": "device_settings_page", 96 "text": "Harrison curtain" 97 }, 98 "Display": { 99 "Top": 80, 100 "Left": 20, 101 "Width": 90, 102 "Height": 20 103 } 104 }, 105 { 106 "ControlType": "input", 107 "ID": "HarrisonCode", 108 "Display": { 109 "Top": 80, 110 "Left": 115, 111 "Width": 100, 112 "Height": 20 113 } 114 }, 115 { 116 "ControlType": "button", 117 "Label": { 118 "lang_tag": "cmd_add", 119 "text": "Add" 120 }, 121 "Display": { 122 "Top": 80, 123 "Left": 220, 124 "Width": 50, 125 "Height": 20 126 }, 127 "Command": { 128 "Service": "urn:upnp-esweb-nl:serviceId:rfxcom1", 129 "Action": "AddHarrisonCurtain", 130 "Parameters": [ 131 { 132 "Name": "HouseCode", 133 "ID": "HarrisonCode" 134 } 135 ] 136 } 137 }, 138 { 139 "ControlType": "label", 140 "Label": { 141 "lang_tag": "lblMsg", 142 "text": "Last msg:" 143 }, 144 "Display": { 145 "Top": 110, 146 "Left": 20, 147 "Width": 75, 148 "Height": 20 149 } 150 }, 151 { 152 "ControlGroup": "1", 153 "ControlPair": "1", 154 "ControlHeader": "1", 155 "ControlType": "variable", 156 "top": "0", 157 "left": "0", 158 "Display": { 159 "Service": "urn:upnp-esweb-nl:serviceId:rfxcom1", 160 "Variable": "Message", 161 "Top": 110, 162 "Left": 115, 163 "Width": 500, 164 "Height": 20 165 } 166 } 167 ] 155 168 }, 156 169 { 157 170 "Label": { 158 171 "lang_tag": "advanced", 159 "text": "Advanced" 172 "text": "Advanced" 160 173 }, 161 174 "Position": "2", 162 175 "TabType": "javascript", 163 176 "ScriptName": "shared.js", 164 "Function": "advanced_device" 177 "Function": "advanced_device" 165 178 } 166 179 ] -
D_RFXCOMHarrison.json
r1 r14 7 7 "imgIconMax": "", 8 8 "halloIconsDir": "pics\/hallo", 9 "inScene": "0", 9 10 "DisplayStatus": { 10 11 "Service": "urn:upnp-esweb-nl:serviceId:RFXCOMHarrison1", 11 12 "Variable": "CurtainStatus", 12 13 "MinValue": "0", 13 "MaxValue": "1" 14 "MaxValue": "1" 14 15 }, 15 16 "doc_url": { … … 18 19 "doc_version": 1, 19 20 "doc_platform": 0, 20 "doc_page": "window_coverings" 21 }, 21 "doc_page": "window_coverings" 22 }, 22 23 "Tabs": [ 23 24 { 24 25 "Label": { 25 26 "lang_tag": "tabname_control", 26 "text": "Control" 27 "text": "Control" 27 28 }, 28 29 "Position": "0", 29 30 "TabType": "flash", 31 "SceneGroup":[ 32 { 33 "id": "1", 34 "top": "0.5", 35 "left": "0", 36 "x": "1", 37 "y": "3" 38 } 39 ], 30 40 "ControlGroup":[ 31 41 { 32 "id":"1" 42 "id":"1", 43 "isSingle": "1", 44 "scenegroup": "1" 33 45 } 34 ], 46 ], 35 47 "Control": [ 36 48 { 37 49 38 50 "ControlGroup":"1", 39 51 "ControlType": "button", 40 52 "Label": { 41 53 "lang_tag": "cmd_open", 42 "text": "Open" 43 }, 54 "text": "Open" 55 }, 56 "top": "0", 44 57 "Display": { 45 58 "Service": "urn:upnp-esweb-nl:serviceId:RFXCOMHarrison1", … … 49 62 "Left": 20, 50 63 "Width": 50, 51 "Height": 20 64 "Height": 20 52 65 }, 53 66 "Command": { … … 57 70 { 58 71 "Name": "newStatusValue", 59 "Value": "1" 60 } 61 ] 62 } 72 "Value": "1" 73 } 74 ] 75 } 63 76 }, 64 77 { … … 67 80 "Label": { 68 81 "lang_tag": "cmd_close", 69 "text": "Close" 70 }, 82 "text": "Close" 83 }, 84 "top": "1", 71 85 "Display": { 72 86 "Service": "urn:upnp-esweb-nl:serviceId:RFXCOMHarrison1", … … 76 90 "Left": 80, 77 91 "Width": 50, 78 "Height": 20 92 "Height": 20 79 93 }, 80 94 "Command": { … … 84 98 { 85 99 "Name": "newStatusValue", 86 "Value": "0" 87 } 88 ] 89 } 100 "Value": "0" 101 } 102 ] 103 } 90 104 }, 91 105 { … … 94 108 "Label": { 95 109 "lang_tag": "cmd_stop", 96 "text": "Stop" 97 }, 110 "text": "Stop" 111 }, 112 "top": "2", 98 113 "Display": { 99 114 "Top": 60, 100 115 "Left": 140, 101 116 "Width": 50, 102 "Height": 20 117 "Height": 20 103 118 }, 104 119 "Command": { 105 120 "Service": "urn:upnp-org:serviceId:WindowCovering1", 106 121 "Action": "Stop" 107 108 } 109 } 110 ] 122 123 } 124 } 125 ] 111 126 }, 112 127 { 113 128 "Label": { 114 129 "lang_tag": "settings", 115 "text": "Settings" 130 "text": "Settings" 116 131 }, 117 132 "Position": "1", 118 133 "TabType": "javascript", 119 134 "ScriptName": "shared.js", 120 "Function": "simple_device" 135 "Function": "simple_device" 121 136 }, 122 137 { 123 138 "Label": { 124 139 "lang_tag": "advanced", 125 "text": "Advanced" 140 "text": "Advanced" 126 141 }, 127 142 "Position": "2", 128 143 "TabType": "javascript", 129 144 "ScriptName": "shared.js", 130 "Function": "advanced_device" 145 "Function": "advanced_device" 131 146 }, 132 147 { 133 148 "Label": { 134 149 "lang_tag": "logs", 135 "text": "Logs" 150 "text": "Logs" 136 151 }, 137 152 "Position": "4", 138 153 "TabType": "javascript", 139 154 "ScriptName": "shared.js", 140 "Function": "device_logs" 155 "Function": "device_logs" 141 156 }, 142 157 { 143 158 "Label": { 144 159 "lang_tag": "notifications", 145 "text": "Notifications" 160 "text": "Notifications" 146 161 }, 147 162 "Position": "5", 148 163 "TabType": "javascript", 149 164 "ScriptName": "shared.js", 150 "Function": "device_notifications" 151 } 165 "Function": "device_notifications" 166 } 152 167 ], 153 168 "sceneList": { … … 158 173 "action": "SetStatus", 159 174 "arguments": { 160 "newStatusValue": "1" 161 } 175 "newStatusValue": "1" 176 } 162 177 }, 163 178 "cmd_2": { … … 166 181 "action": "SetStatus", 167 182 "arguments": { 168 "newStatusValue": "0" 169 } 183 "newStatusValue": "0" 184 } 170 185 } 171 } 186 } 172 187 } , 173 "eventList": { 174 "event_1": { 175 "label": "Curtain is closed", 188 "eventList2": [ 189 { 190 "id": 1, 191 "label": { 192 "lang_tag": "curtain_closed", 193 "text": "Curtain is closed" 194 }, 176 195 "serviceId": "urn:upnp-esweb-nl:serviceId:RFXCOMHarrison1", 177 196 "serviceStateTable": { 178 197 "CurtainStatus": { 179 198 "value": "1", 180 "comparisson": "=" 181 } 199 "comparisson": "=" 200 } 182 201 } 183 202 }, 184 "event_2": { 185 "label": "Curtain is opened", 203 { 204 "id": 2, 205 "label": { 206 "lang_tag": "curtain_opened", 207 "text": "Curtain is opened" 208 }, 186 209 "serviceId": "urn:upnp-esweb-nl:serviceId:RFXCOMHarrison1", 187 210 "serviceStateTable": { 188 211 "CurtainStatus": { 189 212 "value": "0", 190 "comparisson": "=" 191 } 213 "comparisson": "=" 214 } 192 215 } 193 } 194 },195 "DeviceType": "urn:schemas-micasaverde-com:device:WindowCovering:1" 216 } 217 ], 218 "DeviceType": "urn:schemas-micasaverde-com:device:WindowCovering:1" 196 219 } -
I_RFXCOM.xml
r13 r14 31 31 sensorTypeWindSpeed = 512, 32 32 sensorTypeWindSpeedAv = 1024, 33 33 sensorTypeBarometer = 2048, 34 sensorTypeRain = 4096, 35 34 36 sensorManufacturerX10 = "X10", 35 37 sensorManufacturerHomeEasy = "HOMEEASY", … … 65 67 RFXCountHS2 = 0 66 68 RFXDevicesHS2 = {} 69 RFXCountBS2 = 0 70 RFXDevicesBS2 = {} 71 RFXCountRS2 = 0 72 RFXDevicesRS2 = {} 73 RFXCountAS2 = 0 74 RFXDevicesAS2 = {} 67 75 RFXCOM_HAR_Count = 0 68 76 RFXCOM_HAR_Devices = {} … … 123 131 124 132 -- Check on keyfobs 125 if (tostring(v.device_type) == "urn:schemas- esweb-nl:device:RFXKeyfob:1") then133 if (tostring(v.device_type) == "urn:schemas-ActiveRFID:device:RFIDTransmitter:1") then 126 134 RFXCountKF = RFXCountKF + 1 127 135 RFXDevicesKF[RFXCountKF] = v.id … … 153 161 luup.log("Registered device " .. RFXDevicesHS2[RFXCountHS2] .. " as humidity sensor ".. RFXCountHS2) 154 162 end 163 164 -- Check on barometer devices 165 if (tostring(v.device_type) == "urn:schemas-micasaverde-com:device:BarometerSensor:1") then 166 RFXCountBS2 = RFXCountBS2 + 1 167 RFXDevicesBS2[RFXCountBS2] = v.id 168 luup.log("Registered device " .. RFXDevicesBS2[RFXCountBS2] .. " as barometer sensor ".. RFXCountBS2) 169 end 170 171 -- Check on barometer devices 172 if (tostring(v.device_type) == "urn:schemas-micasaverde-com:device:RainSensor:1") then 173 RFXCountRS2 = RFXCountRS2 + 1 174 RFXDevicesRS2[RFXCountRS2] = v.id 175 luup.log("Registered device " .. RFXDevicesRS2[RFXCountRS2] .. " as rain sensor ".. RFXCountRS2) 176 end 177 178 -- Check on EZAnemoSensor devices 179 if (tostring(v.device_type) == "urn:schemas-upnp-org:device:EZAnemoSensor:1") then 180 RFXCountAS2 = RFXCountAS2 + 1 181 RFXDevicesAS2[RFXCountAS2] = v.id 182 luup.log("Registered device " .. RFXDevicesAS2[RFXCountAS2] .. " as Anemo sensor ".. RFXCountAS2) 183 end 155 184 end 156 185 end … … 163 192 luup.log("temperature sensors: " .. RFXCountTS2) 164 193 luup.log(" humidity sensors: " .. RFXCountHS2) 194 luup.log(" pressure sensors: " .. RFXCountBS2) 195 luup.log(" rain sensors: " .. RFXCountBS2) 196 luup.log(" anemo sensors: " .. RFXCountAS2) 165 197 166 198 luup.log("Open socket for read " .. ipAddress .. " port " .. ipPortRead ) … … 487 519 liRecBytes = liRecBytes + bitw.rshift( bitw.band( string.byte(lsCommand, 3) , 0x8), 2) 488 520 liRecBytes = liRecBytes + bitw.rshift( bitw.band( string.byte(lsCommand, 3) , 0x40), 4) 489 liRecBytes = liRecBytes + bitw.lshift( bitw.band( string.byte(lsCommand, 3) , 0x4), 1)521 liRecBytes = liRecBytes + bitw.lshift( bitw.band( string.byte(lsCommand, 1) , 0x4), 1) 490 522 liRecBytes = liRecBytes + 1 491 523 … … 564 596 565 597 luup.log("trying Visonic") 566 598 luup.log("decodeV msg : " .. formattohex(psCommand)) 567 599 if ( liCommandLength >= 6 ) then 568 600 569 601 -- First decode ID 570 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)) 602 -- 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)) 603 lsID = "VIS" .. string.format("%02X", string.byte(psCommand, 2) ) 571 604 local liHsAddr = 0 572 605 --liHsAddr = createhsaddr(psCommand) … … 577 610 -- lsRFXMSG = string.format(" addr: %s ID: %d,lsDevice,liHsAddr) 578 611 --end 579 580 -- Next decode message data 612 -- Next decode message data 581 613 if string.byte(psCommand, 4) == 0x44 then 582 614 lnSensorType = RFXConstants.sensorTypeDoor … … 631 663 -- Unknown command 632 664 end 633 elseif string.byte(psCommand, 4) == 0x2 then 665 666 -- Marmitek KR21 code 667 elseif string.byte(psCommand, 4) == 0x6 then 668 lnSensorType = RFXConstants.sensorTypeKeyFob 669 lsCmd = RFXConstants.cmdArmAway 670 elseif string.byte(psCommand, 4) == 0x86 then 671 lnSensorType = RFXConstants.sensorTypeKeyFob 672 lsCmd = RFXConstants.cmdDisarm 673 elseif string.byte(psCommand, 4) == 0x46 then 674 lnSensorType = RFXConstants.sensorTypeKeyFob 675 lsCmd = RFXConstants.cmdOn 676 elseif string.byte(psCommand, 4) == 0xC6 then 677 lnSensorType = RFXConstants.sensorTypeKeyFob 678 lsCmd = RFXConstants.cmdOff 679 680 elseif string.byte(psCommand, 4) == 0x2 then 634 681 lnSensorType = RFXConstants.sensorTypeKeyFob 635 682 lsCmd = RFXConstants.cmdArmAway … … 643 690 lnSensorType = RFXConstants.sensorTypeKeyFob 644 691 lsCmd = RFXConstants.cmdGroupOn 645 elseif string.byte(psCommand, 4) == 0x82 then692 elseif string.byte(psCommand, 4) == 0x82 then 646 693 lnSensorType = RFXConstants.sensorTypeKeyFob 647 lsCmd = RFXConstants.cmdDisarm 648 else694 lsCmd = RFXConstants.cmdDisarm 695 else 649 696 -- Unknown data packet received 650 697 end … … 753 800 local lsSensorManufacturer = "" 754 801 local liBitLength = bitw.band( string.byte(psCommand, 1), 0x7f) 755 756 757 802 if ( ( string.byte(lsCommand, 1) == 0x3a ) and ( string.byte(lsCommand, 2) == 0x0d ) ) then 758 803 luup.log("Identified Oregon WGR918") … … 773 818 lnSensorType = RFXConstants.sensorTypeTemperature + RFXConstants.sensorTypeHumidity 774 819 lsSensorManufacturer = RFXConstants.sensorManufacturerOregon 775 local lnDataTemp = 0.0 776 local lnDataHum = 0.0 777 if (bitw.band( string.byte(lsCommand, 7) , 0x08) == 0) then 778 lnDataTemp = string.byte(lsCommand, 6) + bitw.rshift(string.byte(lsCommand, 5), 4) / 10 779 else 780 lnDataTemp = 0 - (string.byte(lsCommand, 6) + bitw.rshift(string.byte(lsCommand, 5), 4) / 10) 781 end 782 lnDataHum = bitw.band(string.byte(lsCommand, 8),0x0f) * 10 + bitw.band(bitw.rshift(string.byte(lsCommand, 7), 4),0x0f) 820 821 local lnDataTemp = getOregonTemperature(lsCommand) 822 local lnDataBattery = getOregonBattery(lsCommand) 823 local lnDataHum = getOregonHumidity(lsCommand) 783 824 784 825 lsID = "ORE" .. string.format("%02X", string.byte(lsCommand, 4) ) 785 lsCmd = string.format("temperature=%.1f;humidity=%d", lnDataTemp, lnDataHum) 786 lsRFXMSG = string.format("[OREGON: Temp1 Device: %s Temperature: %5.1f Humidity: %d]", lsID, lnDataTemp, lnDataHum) 826 lsCmd = string.format("temperature=%.1f;humidity=%d;Batterie=%d", lnDataTemp, lnDataHum, lnDataBattery) 827 lsRFXMSG = string.format("[OREGON: Temp1 Device: %s Temperature: %5.1f Humidity: %d Batterie: %d]", lsID, lnDataTemp, lnDataHum, lnDataBattery) 828 829 -- Support for Oregon THWR800 ca48 68 830 elseif ( ( string.byte(lsCommand, 1) == 0xca ) and ( string.byte(lsCommand, 2) == 0x48 ) ) then 831 luup.log("Identified Oregon THWR800") 832 833 lnSensorType = RFXConstants.sensorTypeTemperature 834 lsSensorManufacturer = RFXConstants.sensorManufacturerOregon 835 836 local lnDataTemp = getOregonTemperature(lsCommand) 837 local lnDataBattery = getOregonBattery(lsCommand) 838 839 lsID = "ORE" .. string.format("%02X", string.byte(lsCommand, 4) ) 840 lsCmd = string.format("temperature=%.1f;Batterie=%d", lnDataTemp, lnDataBattery) 841 lsRFXMSG = string.format("[OREGON: Temperature Device: %s Temperature: %5.1f Batterie: %d]", lsID, lnDataTemp, lnDataBattery) 842 843 -- Support for Oregon THGR810 fa28 80 844 elseif ( ( string.byte(lsCommand, 1) == 0xfa ) and ( string.byte(lsCommand, 2) == 0x28 ) ) then 845 luup.log("Identified Oregon THGR810") 846 lnSensorType = RFXConstants.sensorTypeTemperature + RFXConstants.sensorTypeHumidity 847 lsSensorManufacturer = RFXConstants.sensorManufacturerOregon 848 849 local lnDataTemp = getOregonTemperature(lsCommand) 850 local lnDataBattery = getOregonBattery(lsCommand) 851 local lnDataHum = getOregonHumidity(lsCommand) 852 853 lsID = "ORE" .. string.format("%02X", string.byte(lsCommand, 4) ) 854 lsCmd = string.format("temperature=%.1f;humidity=%d;Batterie=%d", lnDataTemp, lnDataHum, lnDataBattery) 855 lsRFXMSG = string.format("[OREGON: Temp1 Device: %s Temperature: %5.1f Humidity: %d Batterie: %d]", lsID, lnDataTemp, lnDataHum, lnDataBattery) 856 857 -- Support for Oregon THWR288A ea4c 68 858 elseif ( ( string.byte(lsCommand, 1) == 0xea ) and ( string.byte(lsCommand, 2) == 0x4c ) ) then 859 luup.log("Identified Oregon THWR288A") 860 lnSensorType = RFXConstants.sensorTypeTemperature + RFXConstants.sensorTypeHumidity 861 lsSensorManufacturer = RFXConstants.sensorManufacturerOregon 862 863 local lnDataTemp = getOregonTemperature(lsCommand) 864 local lnDataBattery = getOregonBattery(lsCommand) 865 local lnDataHum = getOregonHumidity(lsCommand) 866 867 lsID = "ORE" .. string.format("%02X", string.byte(lsCommand, 4) ) 868 lsCmd = string.format("temperature=%.1f;humidity=%d;Batterie=%d", lnDataTemp, lnDataHum, lnDataBattery) 869 lsRFXMSG = string.format("[OREGON: Temp1 Device: %s Temperature: %5.1f Humidity: %d Batterie: %d]", lsID, lnDataTemp, lnDataHum, lnDataBattery) 870 871 872 -- Support for Oregon TH3 Oregon RTGR328N 873 elseif ( ( bitw.band(string.byte(lsCommand, 1), 0x0f) == 0x0a ) and ( string.byte(lsCommand, 2) == 0xcc ) ) then 874 luup.log("Identified Oregon TH3 RTGR328N ") 875 lnSensorType = RFXConstants.sensorTypeTemperature + RFXConstants.sensorTypeHumidity 876 lsSensorManufacturer = RFXConstants.sensorManufacturerOregon 877 878 local lnDataTemp = getOregonTemperature(lsCommand) 879 local lnDataBattery = getOregonBattery(lsCommand) 880 local lnDataHum = getOregonHumidity(lsCommand) 881 882 lsID = "ORE" .. string.format("%02X", string.byte(lsCommand, 4) ) 883 lsCmd = string.format("temperature=%.1f;humidity=%d;Batterie=%d", lnDataTemp, lnDataHum, lnDataBattery) 884 lsRFXMSG = string.format("[OREGON: Temp1 Device: %s Temperature: %5.1f Humidity: %d Batterie: %d]", lsID, lnDataTemp, lnDataHum, lnDataBattery) 885 886 -- Support for Oregon TH4 Oregon THGR328 887 elseif ( ( string.byte(lsCommand, 1) == 0xca ) and ( string.byte(lsCommand, 2) == 0x2c ) ) then 888 luup.log("Identified Oregon TH4 RTGR328 ") 889 lnSensorType = RFXConstants.sensorTypeTemperature + RFXConstants.sensorTypeHumidity 890 lsSensorManufacturer = RFXConstants.sensorManufacturerOregon 891 892 local lnDataTemp = getOregonTemperature(lsCommand) 893 local lnDataBattery = getOregonBattery(lsCommand) 894 local lnDataHum = getOregonHumidity(lsCommand) 895 896 lsID = "ORE" .. string.format("%02X", string.byte(lsCommand, 4) ) 897 lsCmd = string.format("temperature=%.1f;humidity=%d;Batterie=%d", lnDataTemp, lnDataHum, lnDataBattery) 898 lsRFXMSG = string.format("[OREGON: Temp1 Device: %s Temperature: %5.1f Humidity: %d Batterie: %d]", lsID, lnDataTemp, lnDataHum, lnDataBattery) 899 900 -- Support for Oregon WTGR800 fab8 80 901 elseif ( ( string.byte(lsCommand, 1) == 0xfa ) and ( string.byte(lsCommand, 2) == 0xb8 ) ) then 902 luup.log("Identified Oregon WTGR800") 903 lnSensorType = RFXConstants.sensorTypeTemperature + RFXConstants.sensorTypeHumidity 904 lsSensorManufacturer = RFXConstants.sensorManufacturerOregon 905 906 local lnDataTemp = getOregonTemperature(lsCommand) 907 local lnDataPercentBattery = getOregonPercentBattery(lsCommand) 908 local lnDataHum = getOregonHumidity(lsCommand) 909 910 lsID = "ORF" .. string.format("%02X", string.byte(lsCommand, 4) ) 911 lsCmd = string.format("temperature=%.1f;humidity=%d;Batterie=%d", lnDataTemp, lnDataHum, lnDataPercentBattery) 912 lsRFXMSG = string.format("[OREGON: Temperature Device: %s Temperature: %5.1f Humidity: %d Batterie: %d]", lsID, lnDataTemp, lnDataHum, lnDataPercentBattery) 913 914 -- Support for Oregon WTGR800 1A99 88 915 elseif ( ( string.byte(lsCommand, 1) == 0x1a ) and ( string.byte(lsCommand, 2) == 0x99 ) ) then 916 luup.log("Identified Oregon Anemo WTGR800") 917 918 lnSensorType = RFXConstants.sensorTypeWindDirection 919 -- + RFXConstants.sensorTypeWindSpeed + RFXConstants.sensorTypeWindSpeedAv 920 lsSensorManufacturer = RFXConstants.sensorManufacturerOregon 921 922 local liDataDir = nib(lsCommand,8) * 22.5 923 local lnDataSpeed = nib(lsCommand,15)*10 + nib(lsCommand,12) + nib(lsCommand,13)/10 924 local lnDataSpeedav = nib(lsCommand,16)*10 + nib(lsCommand,17) + nib(lsCommand,14)/10 925 local lnDataPercentBattery = getOregonPercentBattery(lsCommand) 926 927 --conversion mps en kmh 928 --lnDataSpeed = lnDataSpeed * 3.6 929 --lnDataSpeedav = lnDataSpeedav * 3.6 930 931 lsID = "ORE" .. string.format("%02X", string.byte(lsCommand, 4) ) 932 lsCmd = string.format("direction=%.2f;vitesse=%.2f;vitesseMoy=%.2f;Batterie=%d",liDataDir, lnDataSpeed, lnDataSpeedav, lnDataPercentBattery) 933 lsRFXMSG = string.format("[OREGON: Anemometre Device: %s Direction: %5.1f Vitesse: %5.1f mps Vitesse moy: %5.1f mps Batterie: %d]", lsID, liDataDir, lnDataSpeed, lnDataSpeedav, lnDataPercentBattery) 934 935 -- Support for Oregon BTHR918N 5a6d 96 936 elseif ( ( string.byte(lsCommand, 1) == 0x5a ) and ( string.byte(lsCommand, 2) == 0x6d ) ) then 937 luup.log("Identified Oregon BTHR918N") 938 lnSensorType = RFXConstants.sensorTypeTemperature + RFXConstants.sensorTypeHumidity + RFXConstants.sensorTypeBarometer 939 lsSensorManufacturer = RFXConstants.sensorManufacturerOregon 940 941 local lnDataTemp = getOregonTemperature(lsCommand) 942 local lnDataBattery = getOregonBattery(lsCommand) 943 local lnDataHum = getOregonHumidity(lsCommand) 944 945 lnDataPres = 856 + string.byte(lsCommand, 9) 946 lsID = "ORE" .. string.format("%02X", string.byte(lsCommand, 4) ) 947 lsCmd = string.format("temperature=%.1f;humidity=%d;pressure=%s;Batterie=%d", lnDataTemp, lnDataHum, lnDataPres, lnDataBattery) 948 lsRFXMSG = string.format("[OREGON: Temperature Device: %s Temperature: %5.1f Humidity: %d Pressure: %s Batterie: %s]", lsID, lnDataTemp, lnDataHum, lnDataPres, lnDataBattery) 949 950 -- Support for Oregon PCR800 2a19 92 951 elseif ( ( string.byte(lsCommand, 1) == 0x2a ) and ( string.byte(lsCommand, 2) == 0x19 ) ) then 952 luup.log("Identified Oregon PCR800") 953 lnSensorType = RFXConstants.sensorTypeRain 954 lsSensorManufacturer = RFXConstants.sensorManufacturerOregon 955 local lnDataRain = 0.0 956 local lnDataTRain = 0.0 957 local lnDataBattery = getOregonBattery(lsCommand) 958 959 lnDataRain = bitw.band(bitw.lshift(string.byte(lsCommand, 7), 0),0x0f) * 10 + bitw.band(bitw.rshift(string.byte(lsCommand, 6), 4),0x0f) 960 + bitw.band(bitw.lshift(string.byte(lsCommand, 6), 0),0x0f) / 10 + bitw.band(bitw.rshift(string.byte(lsCommand, 5), 4),0x0f) / 100 961 lnDataRain = 25.4 * lnDataRain 962 963 lnDataTRain = bitw.band(bitw.lshift(string.byte(lsCommand, 10), 0),0x0f) * 1000 + bitw.band(bitw.rshift(string.byte(lsCommand, 9), 4),0x0f) * 10 964 + bitw.band(bitw.lshift(string.byte(lsCommand, 9), 0),0x0f) + bitw.band(bitw.rshift(string.byte(lsCommand, 8), 4),0x0f) / 10 965 + bitw.band(bitw.lshift(string.byte(lsCommand, 8), 0),0x0f) / 100 + bitw.band(bitw.rshift(string.byte(lsCommand, 7), 4),0x0f) / 1000 966 967 lnDataTRain = 25.4 * lnDataTRain 968 969 lsID = "ORE" .. string.format("%02X", string.byte(lsCommand, 4) ) 970 lsCmd = string.format("rain=%s;train=%s;Batterie=%d", lnDataRain, lnDataTRain, lnDataBattery) 971 lsRFXMSG = string.format("[OREGON: Rain Device: %s Rain: %s TRain: %s Batterie: %s]", lsID, lnDataRain, lnDataTRain, lnDataBattery) 787 972 end 788 973 … … 790 975 end 791 976 977 function getOregonTemperature(lsCommand) 978 local lnData = nib(lsCommand,10) * 10 + nib(lsCommand,11) + nib(lsCommand,8)/10 979 if (bitw.band( string.byte(lsCommand, 7) , 0x08) == 0) then 980 lnData = lnData 981 else 982 lnData = 0-lnData 983 end 984 return lnData 985 end 986 987 function getOregonHumidity(lsCommand) 988 local lnData = nib(lsCommand,15) * 10 + nib(lsCommand,12) 989 return lnData 990 end 991 992 function getOregonBattery(lsCommand) 993 local battery_low = bitw.band( string.byte(lsCommand, 3) , 0x04) 994 local lnData = 90 --'hight' 995 if battery_low == 1 then 996 lnData = 10 --'low' 997 end 998 return lnData 999 end 1000 1001 function getOregonPercentBattery(lsCommand) 1002 local lnData = 100 - 10*nib(lsCommand,9) 1003 return lnData 1004 end 1005 1006 function nib(lsCommand,i) 1007 local n = (i-i%2)/2 + 1 1008 if (i%2 == 0) then 1009 return bitw.band(bitw.rshift(string.byte(lsCommand, n), 4),0x0f) 1010 else 1011 return bitw.band(string.byte(lsCommand, n),0x0f) 1012 end 1013 end 1014 792 1015 793 1016 … … 983 1206 ------------------------------------------------------------------------------------ 984 1207 for teller = 1, RFXCountTS2 do 1208 luup.log("debut temp:" .. RFXDevicesTS2[teller]) 985 1209 luup.chdev.append(THIS_DEVICE, child_devices, RFXDevicesTS2[teller], "RFX TS #" .. RFXDevicesTS2[teller] , 986 1210 "urn:schemas-micasaverde-com:device:TemperatureSensor:1", "D_TemperatureSensor1.xml","","",false) … … 992 1216 luup.chdev.append(THIS_DEVICE, child_devices, RFXDevicesHS2[teller], "RFX HS #" .. RFXDevicesHS2[teller] , 993 1217 "urn:schemas-micasaverde-com:device:HumiditySensor:1", "D_HumiditySensor1.xml","","",false) 994 end 1218 end 1219 ------------------------------------------------------------------------------------ 1220 -- Next with barometer devices 1221 ------------------------------------------------------------------------------------ 1222 for teller = 1, RFXCountBS2 do 1223 luup.chdev.append(THIS_DEVICE, child_devices, RFXDevicesBS2[teller], "RFX BS #" .. RFXDevicesBS2[teller] , 1224 "urn:schemas-micasaverde-com:device:BarometerSensor:1", "D_BarometerSensor1.xml","","",false) 1225 end 1226 1227 ------------------------------------------------------------------------------------ 1228 -- Next with rain devices 1229 ------------------------------------------------------------------------------------ 1230 for teller = 1, RFXCountRS2 do 1231 luup.chdev.append(THIS_DEVICE, child_devices, RFXDevicesRS2[teller], "RFX RS #" .. RFXDevicesRS2[teller] , 1232 "urn:schemas-micasaverde-com:device:RainSensor:1", "D_RainSensor1.xml","","",false) 1233 end 1234 1235 ------------------------------------------------------------------------------------ 1236 -- Next with EZAnemoSensor devices 1237 ------------------------------------------------------------------------------------ 1238 for teller = 1, RFXCountAS2 do 1239 luup.chdev.append(THIS_DEVICE, child_devices, RFXDevicesAS2[teller], "RFX AS #" .. RFXDevicesAS2[teller] , 1240 "urn:schemas-upnp-org:device:EZAnemoSensor:1", "D_EZAnemoSensor.xml","","",false) 1241 end 995 1242 996 1243 ------------------------------------------------------------------------------------ … … 1025 1272 if bitw.band(lnSensorType,RFXConstants.sensorTypeKeyFob) ~= 0 then 1026 1273 luup.log("CREATING CHILD DEVICE KEYFOB WITH ID " .. lsID) 1027 luup.chdev.append(THIS_DEVICE, child_devices, lsID, "RFX KF sensor #" .. lsID ,1274 luup.chdev.append(THIS_DEVICE, child_devices, "KF/" .. lsID, "RFX KF sensor #" .. lsID , 1028 1275 "urn:schemas-ActiveRFID:device:RFIDTransmitter:1","D_RFIDTransmitter.xml","","",false) 1029 1276 RFXCountKF = RFXCountKF + 1 1030 RFXDevicesKF[RFXCountKF] = lsID1277 RFXDevicesKF[RFXCountKF] = "KF/" .. lsID 1031 1278 end 1032 1279 ------------------------------------------------------------------------------------ … … 1053 1300 ------------------------------------------------------------------------------------ 1054 1301 if bitw.band(lnSensorType,RFXConstants.sensorTypeTemperature) ~= 0 then 1055 luup.chdev.append(THIS_DEVICE, child_devices, lsID, "RFX TS #" .. lsID,1302 luup.chdev.append(THIS_DEVICE, child_devices, "TS/" .. lsID, "RFX TS #" .. lsID, 1056 1303 "urn:schemas-micasaverde-com:device:TemperatureSensor:1", "D_TemperatureSensor1.xml","","",false) 1057 1304 RFXCountTS2 = RFXCountTS2 + 1 1058 RFXDevicesTS2[RFXCountTS2] = lsID1305 RFXDevicesTS2[RFXCountTS2] = "TS/" .. lsID 1059 1306 end 1060 1307 ------------------------------------------------------------------------------------ … … 1062 1309 ------------------------------------------------------------------------------------ 1063 1310 if bitw.band(lnSensorType,RFXConstants.sensorTypeHumidity) ~= 0 then 1064 luup.chdev.append(THIS_DEVICE, child_devices, lsID, "RFX HS #" .. lsID,1311 luup.chdev.append(THIS_DEVICE, child_devices, "HS/" .. lsID, "RFX HS #" .. lsID, 1065 1312 "urn:schemas-micasaverde-com:device:HumiditySensor:1", "D_HumiditySensor1.xml","","",false) 1066 1313 RFXCountHS2 = RFXCountHS2 + 1 1067 RFXDevicesHS2[RFXCountHS2] = lsID1314 RFXDevicesHS2[RFXCountHS2] = "HS/" .. lsID 1068 1315 end 1316 ------------------------------------------------------------------------------------ 1317 -- Add barometer sensor 1318 ------------------------------------------------------------------------------------ 1319 if bitw.band(lnSensorType,RFXConstants.sensorTypeBarometer) ~= 0 then 1320 luup.chdev.append(THIS_DEVICE, child_devices, "BS/" .. lsID, "RFX BS #" .. lsID, 1321 "urn:schemas-micasaverde-com:device:BarometerSensor:1", "D_BarometerSensor1.xml","","",false) 1322 RFXCountBS2 = RFXCountBS2 + 1 1323 RFXDevicesBS2[RFXCountBS2] = "BS/" .. lsID 1324 end 1325 1326 ------------------------------------------------------------------------------------ 1327 -- Add rain sensor 1328 ------------------------------------------------------------------------------------ 1329 if bitw.band(lnSensorType,RFXConstants.sensorTypeRain) ~= 0 then 1330 luup.chdev.append(THIS_DEVICE, child_devices, "RS/" .. lsID, "RFX RS #" .. lsID, 1331 "urn:schemas-micasaverde-com:device:RainSensor:1", "D_RainSensor1.xml","","",false) 1332 RFXCountRS2 = RFXCountRS2 + 1 1333 RFXDevicesRS2[RFXCountRS2] = "RS/" .. lsID 1334 end 1335 1336 ------------------------------------------------------------------------------------ 1337 -- Add D_EZAnemoSensor sensor 1338 ------------------------------------------------------------------------------------ 1339 if bitw.band(lnSensorType,RFXConstants.sensorTypeWindDirection) ~= 0 then 1340 luup.chdev.append(THIS_DEVICE, child_devices, "AS/" .. lsID, "RFX AS #" .. lsID, 1341 "urn:schemas-upnp-org:device:EZAnemoSensor:1", "D_EZAnemoSensor.xml","","",false) 1342 RFXCountAS2 = RFXCountAS2 + 1 1343 RFXDevicesAS2[RFXCountAS2] = "AS/" .. lsID 1344 end 1345 1069 1346 1070 1347 … … 1077 1354 luup.log("temperature sensors: " .. RFXCountTS2) 1078 1355 luup.log(" humidity sensors: " .. RFXCountHS2) 1356 luup.log(" pressure sensors: " .. RFXCountBS2) 1357 luup.log(" rain sensors: " .. RFXCountRS2) 1358 luup.log(" Anemo sensors: " .. RFXCountAS2) 1079 1359 1080 1360 -- Synch the new tree with the old three … … 1089 1369 ------------------------------------------------------------------------------ 1090 1370 1371 local fullId = "" 1091 1372 for k, v in pairs(luup.devices) do 1092 1373 -- Check if we have a device with the correct parent (THIS_DEVICE) and 1093 1374 -- altid we are looking for (lsID) 1094 if (v.device_num_parent == THIS_DEVICE and v.id == lsID) then1375 if (v.device_num_parent == THIS_DEVICE) then 1095 1376 device = k 1096 1377 1097 luup.log("Device found or created, now processing command " .. lsCmd .. " for " .. lsID)1098 luup.log("Device Number: " .. k ..1099 " v.device_type: " .. tostring(v.device_type) ..1100 " v.device_num_parent: " .. tostring(v.device_num_parent) ..1101 " v.id: " .. tostring(v.id)1102 )1378 -- luup.log("Device found or created, now processing command " .. lsCmd .. " for " .. lsID) 1379 -- luup.log("Device Number: " .. k .. 1380 -- " v.device_type: " .. tostring(v.device_type) .. 1381 -- " v.device_num_parent: " .. tostring(v.device_num_parent) .. 1382 -- " v.id: " .. tostring(v.id) 1383 -- ) 1103 1384 1104 1385 -- Execution door sensors same as motion sensors … … 1113 1394 -- Arm or Disarm all door and motion sensors when keyfob armed or disarmed 1114 1395 -- Set trip state keyfox as indication home or away 1115 if bitw.band(lnSensorType,RFXConstants.sensorTypeKeyFob) ~= 0 then 1396 fullId = "KF/" .. lsID 1397 if bitw.band(lnSensorType,RFXConstants.sensorTypeKeyFob) ~= 0 1398 and v.id == fullId then 1116 1399 luup.log("KeyFob action: " .. lsCmd) 1117 1400 1118 1401 if lsCmd == RFXConstants.cmdArmAway or lsCmd == RFXConstants.cmdArmHome or lsCmd == RFXConstants.cmdDisarm then 1119 ArmDisarmAll(lsCmd) 1402 ArmDisarmAll(lsCmd) 1403 -- local newArmedValue = "1" -- armed 1404 -- local newTrippedValue = "1" -- home 1405 1406 -- if lsCmd == RFXConstants.cmdDisarm then 1407 -- newArmedValue = "0" 1408 -- newTrippedValue = "0" 1409 -- end 1410 -- if lsCmd == RFXConstants.cmdArmAway then newTrippedValue = "0" end 1411 -- luup.log( "Set ArmedValue value " .. newArmedValue .. " to device " .. device ) 1412 -- luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Armed",newArmedValue, device) 1413 -- luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", newTrippedValue, device) 1120 1414 elseif lsCmd == RFXConstants.cmdPanic then 1121 1415 -- not implemented 1122 elseif lsCmd == RFXConstants.cmdGroupOn then 1123 -- not implemented 1416 elseif lsCmd == RFXConstants.cmdOn then 1417 luup.log("urn:ActiveRFID:serviceId:RFIDTransmitter1 Action:On:Portail" .. fullId) 1418 local Pstatus = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1","Status",26) 1419 if Pstatus == "0" then 1420 luup.variable_set("urn:upnp-org:serviceId:SwitchPower1","Status","1",26) 1421 else 1422 luup.variable_set("urn:upnp-org:serviceId:SwitchPower1","Status","0",26) 1423 end 1424 elseif lsCmd == RFXConstants.cmdOff then 1425 luup.log("urn:ActiveRFID:serviceId:RFIDTransmitter1 Action:Off:Garage" .. fullId) 1426 local Pstatus = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1","Status",27) 1427 if Pstatus == "0" then 1428 luup.variable_set("urn:upnp-org:serviceId:SwitchPower1","Status","1",27) 1429 else 1430 luup.variable_set("urn:upnp-org:serviceId:SwitchPower1","Status","0",27) 1431 end 1124 1432 end 1125 1433 end … … 1139 1447 -- Execution for temperature sensor 1140 1448 -- Set temperature to command 1141 if bitw.band(lnSensorType,RFXConstants.sensorTypeTemperature) ~= 0 and tostring(v.device_type) == "urn:schemas-micasaverde-com:device:TemperatureSensor:1" then 1449 fullId = "TS/" .. lsID 1450 if bitw.band(lnSensorType,RFXConstants.sensorTypeTemperature) ~= 0 1451 and tostring(v.device_type) == "urn:schemas-micasaverde-com:device:TemperatureSensor:1" 1452 and v.id == fullId then 1142 1453 for lsKey,lsValue in string.gmatch(lsCmd, "(%w+)=([%w%.%-_]+)") do 1143 luup.log("Key=" .. lsKey .. ";Value=" .. lsValue .. ";")1454 -- luup.log("Key=" .. lsKey .. ";Value=" .. lsValue .. ";") 1144 1455 if lsKey == "temperature" then 1145 1456 luup.log("SET CURRENTTEMPERATURE from " .. lsID .. " with value " .. lsValue) 1146 1457 luup.variable_set("urn:upnp-org:serviceId:TemperatureSensor1", "CurrentTemperature", 1147 1458 lsValue, device) 1459 elseif lsKey == "Batterie" then 1460 luup.log("SET BATTERIE from " .. lsID .. " with value " .. lsValue) 1461 luup.variable_set("urn:micasaverde-com:serviceId:HaDevice1", "BatteryLevel", lsValue, device) 1148 1462 end 1149 1463 end … … 1152 1466 -- Execution for humidity sensor 1153 1467 -- Set humidity to command 1154 if bitw.band(lnSensorType,RFXConstants.sensorTypeHumidity) ~= 0 and tostring(v.device_type) == "urn:schemas-micasaverde-com:device:HumiditySensor:1" then 1468 fullId = "HS/" .. lsID 1469 if bitw.band(lnSensorType,RFXConstants.sensorTypeHumidity) ~= 0 1470 and tostring(v.device_type) == "urn:schemas-micasaverde-com:device:HumiditySensor:1" 1471 and v.id == fullId then 1155 1472 for lsKey,lsValue in string.gmatch(lsCmd, "(%w+)=([%w%.%-_]+)") do 1156 luup.log("Key=" .. lsKey .. ";Value=" .. lsValue .. ";")1473 -- luup.log("Key=" .. lsKey .. ";Value=" .. lsValue .. ";") 1157 1474 if lsKey == "humidity" then 1158 1475 luup.log("SET CURRENTLEVEL from " .. lsID .. " with value " .. lsValue) 1159 1476 luup.variable_set("urn:micasaverde-com:serviceId:HumiditySensor1", "CurrentLevel", 1160 1477 lsValue, device) 1478 elseif lsKey == "Batterie" then 1479 luup.log("SET BATTERIE from " .. lsID .. " with value " .. lsValue) 1480 luup.variable_set("urn:micasaverde-com:serviceId:HaDevice1", "BatteryLevel", lsValue, device) 1161 1481 end 1162 1482 end 1163 end 1483 end 1484 1485 -- Execution for pressure sensor 1486 -- Set pressure to command 1487 fullId = "BS/" .. lsID 1488 if bitw.band(lnSensorType,RFXConstants.sensorTypeBarometer) ~= 0 1489 and tostring(v.device_type) == "urn:schemas-micasaverde-com:device:BarometerSensor:1" 1490 and v.id == fullId then 1491 for lsKey,lsValue in string.gmatch(lsCmd, "(%w+)=([%w%.%-_]+)") do 1492 -- luup.log("Key=" .. lsKey .. ";Value=" .. lsValue .. ";") 1493 if lsKey == "pressure" then 1494 luup.log("SET CURRENTPRESSURE from " .. lsID .. " with value " .. lsValue) 1495 luup.variable_set("urn:upnp-org:serviceId:BarometerSensor1", "CurrentPressure", 1496 lsValue, device) 1497 elseif lsKey == "Batterie" then 1498 luup.log("SET BATTERIE from " .. lsID .. " with value " .. lsValue) 1499 luup.variable_set("urn:micasaverde-com:serviceId:HaDevice1", "BatteryLevel", lsValue, device) 1500 end 1501 end 1502 end 1503 fullId = "RS/" .. lsID 1504 if bitw.band(lnSensorType,RFXConstants.sensorTypeRain) ~= 0 1505 and tostring(v.device_type) == "urn:schemas-micasaverde-com:device:RainSensor:1" 1506 and v.id == fullId then 1507 for lsKey,lsValue in string.gmatch(lsCmd, "(%w+)=([%w%.%-_]+)") do 1508 -- luup.log("Key=" .. lsKey .. ";Value=" .. lsValue .. ";") 1509 if lsKey == "rain" then 1510 luup.log("SET CURRENTRAIN from " .. lsID .. " with value " .. lsValue) 1511 luup.variable_set("urn:upnp-org:serviceId:RainSensor1", "CurrentRain", lsValue, device) 1512 elseif lsKey == "train" then 1513 luup.log("SET CURRENTTRAIN from " .. lsID .. " with value " .. lsValue) 1514 luup.variable_set("urn:upnp-org:serviceId:RainSensor1", "CurrentTRain", lsValue, device) 1515 elseif lsKey == "Batterie" then 1516 luup.log("SET BATTERIE from " .. lsID .. " with value " .. lsValue) 1517 luup.variable_set("urn:micasaverde-com:serviceId:HaDevice1", "BatteryLevel", lsValue, device) 1518 end 1519 end 1520 end 1521 fullId = "AS/" .. lsID 1522 if bitw.band(lnSensorType,RFXConstants.sensorTypeWindDirection) ~= 0 1523 and tostring(v.device_type) == "urn:schemas-upnp-org:device:EZAnemoSensor:1" 1524 and v.id == fullId then 1525 for lsKey,lsValue in string.gmatch(lsCmd, "(%w+)=([%w%.%-_]+)") do 1526 -- luup.log("Key=" .. lsKey .. ";Value=" .. lsValue .. ";") 1527 if lsKey == "direction" then 1528 luup.log("SET DIRECTION from " .. lsID .. " with value " .. lsValue) 1529 luup.variable_set("urn:upnp-org:serviceId:EZAnemoSensor1", "Direction", lsValue, device) 1530 end 1531 if lsKey == "vitesse" then 1532 luup.log("SET SPEED from " .. lsID .. " with value " .. lsValue) 1533 luup.variable_set("urn:upnp-org:serviceId:EZAnemoSensor1", "Vitesse", lsValue, device) 1534 end 1535 if lsKey == "vitesseMoy" then 1536 luup.log("SET SPEEDAV from " .. lsID .. " with value " .. lsValue) 1537 luup.variable_set("urn:upnp-org:serviceId:EZAnemoSensor1", "VitesseMoy", lsValue, device) 1538 end 1539 if lsKey == "Batterie" then 1540 luup.log("SET BATTERIE from " .. lsID .. " with value " .. lsValue) 1541 luup.variable_set("urn:micasaverde-com:serviceId:HaDevice1", "BatteryLevel", lsValue, device) 1542 end 1543 end 1544 end 1164 1545 end 1165 1546 … … 1185 1566 end 1186 1567 if lsCmd == RFXConstants.cmdArmAway then newTrippedValue = "0" end 1187 luup.log("urn:ActiveRFID:serviceId:RFIDTransmitter1 Action::SetArmed:" .. newArmedValue) 1188 1568 luup.log("urn:ActiveRFID:serviceId:RFIDTransmitter1 Action::SetArmed:" .. newArmedValue .. "device:" .. RFXDevicesKF[1]) 1569 luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Armed",newArmedValue, 41) 1570 luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Armed",newArmedValue, 42) 1571 luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Armed",newArmedValue, 43) 1572 luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Armed",newArmedValue, 44) 1573 1189 1574 -- Iterate all door sensors and set armed value 1190 for teller = 1, RFXCountDS do1191 local lsOtherDevices = findChild(THIS_DEVICE, RFXDevicesDS[teller] )1192 1193 luup.log("Action::SetArmed: " .. newArmedValue .. " for door sensor device " .. RFXDevicesDS[teller] .. "/" .. lsOtherDevices)1194 luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Armed",newArmedValue,lsOtherDevices)1195 end1575 -- for teller = 1, RFXCountDS do 1576 -- local lsOtherDevices = findChild(THIS_DEVICE, RFXDevicesDS[teller] ) 1577 1578 -- luup.log("Action::SetArmed: " .. newArmedValue .. " for door sensor device " .. RFXDevicesDS[teller] .. "/" .. lsOtherDevices) 1579 -- luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Armed",newArmedValue,lsOtherDevices) 1580 -- end 1196 1581 1197 1582 -- Iterate all motion sensors and set armed value 1198 for teller = 1, RFXCountMS do1199 local lsOtherDevices = findChild(THIS_DEVICE, RFXDevicesMS[teller] )1200 1201 luup.log("Action::SetArmed: " .. newArmedValue .. " for motion sensor device " .. RFXDevicesMS[teller] .. "/" .. lsOtherDevices)1202 luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Armed",newArmedValue,lsOtherDevices)1203 1204 end1583 -- for teller = 1, RFXCountMS do 1584 -- local lsOtherDevices = findChild(THIS_DEVICE, RFXDevicesMS[teller] ) 1585 -- 1586 -- luup.log("Action::SetArmed: " .. newArmedValue .. " for motion sensor device " .. RFXDevicesMS[teller] .. "/" .. lsOtherDevices) 1587 -- luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Armed",newArmedValue,lsOtherDevices) 1588 1589 -- end 1205 1590 1206 1591 -- Iterate all keyfobs and set armed value and 1207 1592 -- set tripped value based on armed-home (1) or armed-away (0) 1208 for teller = 1, RFXCountKF do1209 local lsOtherDevices = findChild(THIS_DEVICE, RFXDevicesKF[teller] )1210 1211 luup.log("Action::SetArmed: " .. newArmedValue .. "for KeyFob device " .. RFXDevicesKF[teller] .. "/" .. lsOtherDevices)1212 luup.log("Action::SetTripped: " .. newTrippedValue .. "for KeyFob device " .. RFXDevicesKF[teller] .. "/" .. lsOtherDevices)1213 1214 luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Armed",newArmedValue,lsOtherDevices)1215 luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Tripped",newTrippedValue,lsOtherDevices)1216 end1593 -- for teller = 1, RFXCountKF do 1594 -- local lsOtherDevices = findChild(THIS_DEVICE, RFXDevicesKF[teller] ) 1595 -- 1596 -- luup.log("Action::SetArmed: " .. newArmedValue .. "for KeyFob device " .. RFXDevicesKF[teller] .. "/" .. lsOtherDevices) 1597 -- luup.log("Action::SetTripped: " .. newTrippedValue .. "for KeyFob device " .. RFXDevicesKF[teller] .. "/" .. lsOtherDevices) 1598 -- 1599 -- luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Armed",newArmedValue,lsOtherDevices) 1600 -- luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Tripped",newTrippedValue,lsOtherDevices) 1601 --end 1217 1602 end 1603 1218 1604 1219 1605 … … 1221 1607 function findChild(parentDevice, label) 1222 1608 for k, v in pairs(luup.devices) do 1223 if (v.device_num_parent == parentDevice and v.id == label) then1224 return k1609 if (v.device_num_parent == parentDevice and string.find(v.id, label .. "$", 4) == 4) then 1610 return k 1225 1611 end 1226 1612 end 1227 1613 1228 1614 -- Dump a copy of the Global Module list for debugging purposes. 1229 luup.log("findChild cannot find parentDevice: " .. tostring(parentDevice) .. " label: " .. label)1230 for k, v in pairs(luup.devices) do1231 luup.log("Device Number: " .. k ..1232 " v.device_type: " .. tostring(v.device_type) ..1233 " v.device_num_parent: " .. tostring(v.device_num_parent) ..1234 " v.id: " .. tostring(v.id)1235 )1236 end1615 -- luup.log("findChild cannot find parentDevice: " .. tostring(parentDevice) .. " label: " .. label) 1616 -- for k, v in pairs(luup.devices) do 1617 -- luup.log("Device Number: " .. k .. 1618 -- " v.device_type: " .. tostring(v.device_type) .. 1619 -- " v.device_num_parent: " .. tostring(v.device_num_parent) .. 1620 -- " v.id: " .. tostring(v.id) 1621 -- ) 1622 -- end 1237 1623 end 1238 1624
Note: See TracChangeset
for help on using the changeset viewer.