Changeset c9395f4


Ignore:
Timestamp:
2014-07-24 20:35:53 (11 years ago)
Author:
purdueguy <purdueguy@…>
Branches:
master
Children:
2d69e31
Parents:
56b5988
git-author:
purdueguy <purdueguy@…> (2014-07-24 20:35:53)
git-committer:
purdueguy <purdueguy@…> (2014-07-24 20:35:53)
Message:

Added Insteon motion sensor support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified Main/L_ISYController1.lua

    r6fa25bb rc9395f4  
    168168        ['8'] = true 
    169169    }, 
     170    motionSensor = { 
     171        ['33'] = true 
     172    }, 
    170173} 
    171174 
     
    917920        end 
    918921 
     922    -- Motion Sensor 
     923    elseif (zwaveDeviceCategory4.motionSensor[subCat]) then 
     924        debugLog("MotionSensor: node " .. node .. " action: " .. action) 
     925        local deviceId = getChild(nodeParent) 
     926        local result = nil 
     927          
     928        -- We only care about status changes 
     929        if (command == "ST") then   
     930            -- secure (not tripped) 
     931            if (action == "0") then 
     932                result = setIfChanged(SENSOR_SERVICEID, 'Tripped', 0, deviceId) 
     933           
     934            -- tripped 
     935            else 
     936                result = setIfChanged(SENSOR_SERVICEID, 'Tripped', 1, deviceId) 
     937           
     938            end 
     939             
     940            if (result) then 
     941                setIfChanged(HADEVICE_SID, 'LastUpdate', time, deviceId) 
     942            end 
     943        end 
     944           
    919945    -- Thermostat 
    920946    elseif (zwaveDeviceCategory4.thermostat[subCat]) then 
    921         debugLog("Z-Wave Thermostat: node " .. node .. " action: " .. action) 
     947        debugLog("Z-Wave Thermostat: node " .. node .. " action: " .. action .. " command: " .. command) 
    922948        local deviceId = getChild(nodeParent) 
    923949         
     
    927953          -- current temperature -- 
    928954          result = setIfChanged(TEMPSENSOR_SID, 'CurrentTemperature', action, deviceId) 
     955 
     956        elseif (command == "DON") then 
     957          -- Normal mode -- 
     958          result = setIfChanged(HVAC_MODE_SID, "EnergyModeStatus", "Normal", deviceId) 
     959 
     960        elseif (command == "DOF") then 
     961          -- ESM -- 
     962          result = setIfChanged(HVAC_MODE_SID, "EnergyModeStatus", "EnergySavingsMode", deviceId) 
    929963 
    930964        elseif (command == "CLISPH") then 
     
    11021136                    -- RemoteLinc 
    11031137                    if (insteonDeviceCategory0.remoteLinc[subCat]) then 
    1104                         debugLog("Updating RemoteLinc name for: node " .. node) 
     1138                        debugLog("Updating RemoteLinc name for: node " .. node .. " to: " .. name .. " for deviceid: " .. insteonToChildMap[insteonId]) 
    11051139                         
    11061140                        -- Scene Controller 
     
    11131147                    -- KeypadLinc Dimmer 
    11141148                    if (insteonDeviceCategory1.dimmerKPL[subCat]) then 
    1115                         debugLog("Updating KeypadLinc Dimmer name for: node " .. node) 
     1149                        debugLog("Updating KeypadLinc Dimmer name for: node " .. node .. " to: " .. name .. " for deviceid: " .. insteonToChildMap[parent]) 
    11161150                         
    11171151                        -- Dimmable light 
     
    11231157                    -- FanLinc 
    11241158                    elseif (insteonDeviceCategory1.fanLinc[subCat]) then 
    1125                         debugLog("Updating FanLinc name for: node " .. node) 
     1159                        debugLog("Updating FanLinc name for: node " .. node .. " to: " .. name .. " for deviceid: " .. insteonToChildMap[parent]) 
    11261160                         
    11271161                        -- Dimmable light 
     
    11331167                    -- Dimmer 
    11341168                    elseif (insteonDeviceCategory1.dimmer[subCat]) then 
    1135                         debugLog("Updating Dimmer name for: node " .. node) 
     1169                        debugLog("Updating Dimmer name for: node " .. node .. " to: " .. name .. " for deviceid: " .. insteonToChildMap[parent]) 
    11361170                         
    11371171                        luup.attr_set("name", string.format("%s", name), insteonToChildMap[parent]) 
     
    11441178                    -- KeypadLinc Relay 
    11451179                    if (insteonDeviceCategory2.relayKPL[subCat]) then 
    1146                         debugLog("Updating KeypadLinc Relay name for: node " .. node) 
     1180                        debugLog("Updating KeypadLinc Relay name for: node " .. node .. " to: " .. name .. " for deviceid: " .. insteonToChildMap[parent]) 
    11471181                         
    11481182                        -- Binary light 
     
    11541188                    -- Relay / Switch 
    11551189                    elseif (insteonDeviceCategory2.relay[subCat]) then 
    1156                         debugLog("Updating Relay name for: node " .. node) 
     1190                        debugLog("Updating Relay name for: node " .. node .. " to: " .. name .. " for deviceid: " .. insteonToChildMap[parent]) 
    11571191                         
    11581192                        luup.attr_set("name", string.format("%s", name), insteonToChildMap[parent]) 
     
    11641198                    -- IOLinc 
    11651199                    if (insteonDeviceCategory7.iolinc[subCat]) then 
    1166                         debugLog("Updating IOLinc name for: node " .. node) 
     1200                        debugLog("Updating IOLinc name for: node " .. node .. " to: " .. name .. " for deviceid: " .. insteonToChildMap[parent]) 
    11671201                         
    11681202                        -- Security Sensor 
    1169                         luup.attr_set("name", string.format("%s", name), insteonToChildMap[parent]) 
     1203                        --luup.attr_set("name", string.format("%s", name), insteonToChildMap[parent]) 
    11701204                               
    11711205                        -- Relay 
    1172                         luup.attr_set("name", string.format("%s", name), insteonToChildMap[insteonId] .. " 2") 
     1206                        --luup.attr_set("name", string.format("%s", name), insteonToChildMap[insteonId] .. " 2") 
    11731207                    end              
    11741208                    
     
    11781212                    -- Motion Sensor 
    11791213                    if (insteonDeviceCategory16.motionSensor[subCat]) then 
    1180                         debugLog("Updating Motion Sensor name for: node " .. node) 
     1214                        debugLog("Updating Motion Sensor name for: node " .. node .. " to: " .. name .. " for deviceid: " .. insteonToChildMap[parent]) 
    11811215                         
    11821216                        luup.attr_set("name", string.format("%s", name), insteonToChildMap[parent]) 
     
    11911225                    -- Relay 
    11921226                    if (zwaveDeviceCategory4.relay[subCat]) then 
    1193                         debugLog("Updating Z-Wave Relay name for: node " .. node) 
     1227                        debugLog("Updating Z-Wave Relay name for: node " .. node .. " to: " .. name .. " for deviceid: " .. insteonToChildMap[parent]) 
    11941228                         
    11951229                        -- Binary light 
     
    11981232                    -- Dimmer 
    11991233                    elseif (zwaveDeviceCategory4.dimmer[subCat]) then 
    1200                         debugLog("Updating Z-Wave dimmer name for: node " .. node) 
     1234                        debugLog("Updating Z-Wave dimmer name for: node " .. node .. " to: " .. name .. " for deviceid: " .. insteonToChildMap[parent]) 
    12011235                         
    12021236                        luup.attr_set("name", string.format("%s", name), insteonToChildMap[parent]) 
     
    12041238                    -- Lock 
    12051239                    elseif (zwaveDeviceCategory4.lock[subCat]) then 
    1206                         debugLog("Updating Z-Wave lock name for: node " .. node) 
     1240                        debugLog("Updating Z-Wave lock name for: node " .. node .. " to: " .. name .. " for deviceid: " .. insteonToChildMap[parent]) 
    12071241                         
    12081242                        luup.attr_set("name", string.format("%s", name), insteonToChildMap[parent]) 
     1243 
     1244                    -- Thermostat 
     1245                    elseif (zwaveDeviceCategory4.thermostat[subCat]) then 
     1246                        debugLog("Updating Z-Wave thermostat name for: node " .. node .. " to: " .. name .. " for deviceid: " .. insteonToChildMap[parent]) 
     1247                         
     1248                        luup.attr_set("name", string.format("%s", name), insteonToChildMap[parent]) 
     1249 
     1250                    -- Motion Sensor 
     1251                    elseif (zwaveDeviceCategory4.motionSensor[subCat]) then 
     1252                        debugLog("Updating Z-Wave motionSensor name for: node " .. node .. " to: " .. name .. " for deviceid: " .. insteonToChildMap[parent]) 
     1253                         
     1254                        luup.attr_set("name", string.format("%s", name), insteonToChildMap[parent]) 
     1255 
    12091256                    end 
    12101257                end 
     
    16251672                            "urn:schemas-upnp-org:device:HVAC_ZoneThermostat:1", "D_HVAC_ZoneThermostat1.xml", 
    16261673                            "", "urn:upnp-org:serviceId:TemperatureSensor1,CurrentTemperature="..newStatus, false) 
     1674 
     1675                    -- Motion Sensor 
     1676                    elseif (zwaveDeviceCategory4.motionSensor[subCat]) then 
     1677 
     1678                          local newStatus 
     1679                         
     1680                        debugLog("Creating Z-Wave motion sensor for: node " .. node) 
     1681                         
     1682                        -- tripped 
     1683                        if (status ~= nil and status ~= " " and tonumber(status) == 1) then 
     1684                            newStatus = 1 
     1685                         
     1686                        -- secure (not tripped) 
     1687                        else 
     1688                            newStatus = 0 
     1689                        end 
     1690                         
     1691                        luup.chdev.append(device, children, 
     1692                            string.format("%s", parent), string.format("%s", name), 
     1693                            "urn:schemas-micasaverde-com:device:MotionSensor:1", "D_MotionSensor1.xml", 
     1694                            "", "urn:micasaverde-com:serviceId:SecuritySensor1,Tripped=" .. newStatus ..   
     1695                            "\n" .. "urn:micasaverde-com:serviceId:SecuritySensor1,Armed=0" .. 
     1696                            "\nurn:garrettwp-com:serviceId:ISYController1,Family=4", false) 
    16271697                    end 
    16281698                end 
Note: See TracChangeset for help on using the changeset viewer.