Page 3 of 3 FirstFirst 123
Results 21 to 28 of 28

Thread: custom DM devices?

  1. #21
    Join Date
    Mar 2005
    Posts
    724

    Default

    thanks and great on the XP as I plan to start messing with the QML stuff soon

    Thanks,
    Yonu

  2. #22
    Join Date
    Mar 2005
    Posts
    724

    Default

    ok quick question on the example plugin and I am sorry to ask this but is there a way to have all the devices created in Lua without using the compnent manager I am trying to port the plugin code I wrote for my TCP lighting gateway and I am slightly lost the DM stuff just has me totally confused.

    Thanks,
    Yonu

  3. #23
    Join Date
    May 2005
    Location
    Nuremberg - Germany
    Posts
    28

    Default

    I was also wondering when the G5 DM structure gets reintroduced to G6. I also have a couple of devices in DM G5 (mostly X10 and Transport devices) and at the moment it seems like there is no convenient way...

  4. #24
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,553

    Default

    Girder 5's DM structure is not coming back. Girder 6 has a new DM structure. Sorry we had to break compatibility there.
    Ron
    No support through PM

  5. #25
    Join Date
    May 2005
    Location
    Nuremberg - Germany
    Posts
    28

    Default

    But are you going to integrate X10 and the Transport Plugins again so I could have an entry per device in the G6 DM?

  6. #26
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,553

    Default

    Yes we will.
    Ron
    No support through PM

  7. #27
    Join Date
    Mar 2005
    Posts
    724

    Default

    I hate to be a pita but I haven't had much time work with the example plugin you provided but after looking at it I am still lost. I am attaching the dm create code I am using from my g5 plugin I just can't seem to figure out how to import the same data to create the devices in g6.
    Code:
    --[[
    start dm create
    --]]
    function dmcreate()
    local base = {
    
        -- subclass
        New = function (self, o)
            assert (type (o) == 'table')
            setmetatable (o,self)
            self.__index = self
            return o
        end,
    
    
        -- instance
        Create = function (self,instance)
            assert (type (instance) == 'table')
    
            assert (instance.DMClass) -- dm class used to create the dm device
    
            assert (instance.Name)
            assert (instance.Location)
            assert (instance.ID)
            assert (instance.Description)
    
            setmetatable (instance,self)
            self.__index = self
    
            --assert (instance.Type) -- type of container, used for naming in some instances
    
            return instance:Initialize () and instance or false
        end,
    
    
        Initialize = function (self)
            local device = self:CreateDMDevice ()
    
            self:AddDMDevice (device)
    
            self:UpdateStatus ('Ok')
    
            return true
        end,
    
    
        GetName = function (self)
            return self.Name
        end,
    
    
        SetName = function (self,name)
            self.Name = name
            self.DMDevice:SetProperties ({Name = name},true)
        end,
    
    
        GetLocation = function (self)
            return self.Location
        end,
    
    
        SetLocation = function (self,location)
            self.Location = location
            self.DMDevice:SetProperties ({Location = location},true)
        end,
    
    
        GetType = function (self)
            return self.Type
        end,
    
    
        GetDescription = function (self)
            return self.Description
        end,
        
        
        GetID = function (self)
            return self.ID
        end,
    
    
        Print = function (self)
            print ('        Device: ',self:GetID (), self:GetName (), self:GetLocation ())
        end,
    
    
        GetProvider = function (self)
            return {
    
                GetName = function (self)
                    return 'TCPLighting'
                end,
    
    
                GetPath = function (self)
                    return DeviceManager.Local:GetPath()..DeviceManager.Constants.PathSeperator..'TCPLighting'
                end,
    
    
                GetType = function (self)
                    return 'TCPLighting'
                end,
    
    
                DeviceCommand = function (provider,Command,Device,...)
                    --print ('device command',Command,Device,unpack (arg))
    
                    if Command == DeviceManager.Devices.Commands.Action then
                        local control = arg [1]:GetID ()
                        local value = arg [2]
                        self:DMAction (control,value)
                    elseif Command == DeviceManager.Devices.Commands.Property then
                        self:DMProperty ()
                    end
                end,
    
            }
        end,
    
    
        -- create device id for the provider/dm, subclasses override as needed
        GetDMDeviceID = function (self)
            return self.ID
        end,
    
    
        CreateDMDevice = function (self)
            local deviceproperties = {
                ID = self:GetDMDeviceID (),
                Location = self:GetLocation (),
                Name = self:GetName (),
                Provider = self:GetProvider (),
                Description = self:GetDescription (),
                DoNotUseSavedDeviceInfo = false,
            }
    
            local device = assert (self.DMClass:New  (deviceproperties))
    
            return device
        end,
    
    
        AddDMDevice = function (self,device)
            self.DMDevice = assert (device)
            DeviceManager.Local:AddDevice (device)
        end,
    
    
        RemoveDMDevice = function (self)
            DeviceManager.Local:RemoveDevice (self.DMDevice)
            self.DMDevice:Close ()
            self.DMDevice = nil
        end,
    
    
        DMAction = function (self,control,value)
            --print (self.Name,control,value)
            gir.TriggerEvent ('Execute ' .. self.DMDevice:GetLocationName () .. ' ' .. control .. ' = ' .. value,18)
    	--[[	to test execute
    	print (control)
    	print ('value '.. value)
    	--]]
            self.DMDevice:UpdateControl (control,value)
    	--print ('id '.. self.ID) --to test self ID
     --[[
     Start Adjust Bulb settings
     --]]
    	if value == 0 then
    		local bulb = socket.http.request('http://'.. tcpip..'/gwr/gop.php?cmd=DeviceSendCommand&data=<gip><version>1</version><token>1234567890</token><did>'.. self.ID.. '</did><value>0</value><type>level</type></gip>&fmt=xml')
    		local bulboff = socket.http.request('http://'.. tcpip..'/gwr/gop.php?cmd=DeviceSendCommand&data=<gip><version>1</version><token>1234567890</token><did>'.. self.ID.. '</did><value>0</value></gip>&fmt=xml')
    	else
    		local bulb = socket.http.request('http://'.. tcpip..'/gwr/gop.php?cmd=DeviceSendCommand&data=<gip><version>1</version><token>1234567890</token><did>'.. self.ID.. '</did><value>'.. value.. '</value><type>level</type></gip>&fmt=xml')
    		local bulbon = socket.http.request('http://'.. tcpip..'/gwr/gop.php?cmd=DeviceSendCommand&data=<gip><version>1</version><token>1234567890</token><did>'.. self.ID.. '</did><value>1</value></gip>&fmt=xml')
    	end
    --[[
    End Adjust bulb settings
    --]]
       end,
    
    
        DMProperty = function (self)
            self.Location = self.DMDevice:GetLocation ()
    		self.Name = self.DMDevice:GetName ()
    
    		self.InsteonDevice:SetLocation (self.Location)
    		self.InsteonDevice:SetName (self.Name)
    	end,
    
    
    	UpdateStatus = function (self,status)
    		self.DMDevice:SetStatus (status)
    	end,
    
    	
    	Close = function (self)
    		self:RemoveDMDevice ()
    	end,
    
    }
    
    BasicDeviceContainer = base
    
    --[[
    end dm create
    --]]
    end
    	end
    creates each device
    Code:
    require 'DeviceManager.Devices.Lighting'
        if devices.type == 'multilevel' then
        --local dclass = "DeviceManager.Devices.Classes.LightDimmer"
        end   
        
        --[[
        if to check if device exists
        --]]
    --print ("path local ".. path)
    local device = DeviceManager:GetDeviceUsingPath (path)
        if device then
        --device:Print ()
        --[[
        update values if they exist
        --]]
        
        if devices.state == '1' then  
            --print (devices.name.. ' state '.. devices.state) -- to test state of devices
            if devices.type == 'multilevel' then
            local controlid = 'Level'
            local control = device:GetControl (controlid)
                if control then         
                local val = tonumber(devices.level)
                --print (val) --test string to number
                control:UpdateValue (val)
                end
            end  
        else
           local controlid = 'Level'
           local control = device:GetControl (controlid)
           if control then
                local val = tonumber(devices.state)
                --print (val) --test string to number
                control:UpdateValue (val)
           end
        end
    else
       --print ('Creating '.. devices.name)
    tcp = BasicDeviceContainer:Create ( {
        ID = devices.did,   
        DMClass = DeviceManager.Devices.Classes.LightDimmer,
        Name = devices.name,
        Location = devices.room.name,
        Description = devices.name,
        } )
    end
    I am hoping someone can help me out
    thanks,
    yonu
    Last edited by yonu; June 9th, 2014 at 09:21 PM.

  8. #28
    Join Date
    Mar 2005
    Posts
    724

    Default

    Ok quick question I have had some time free to work on converting plugins from G5 to G6. However I am a little confused on the DM structure changes I am using the the DMexabmple plugin which after I simply looked at it for a while it started to make sense. What has me confused is the whole internal ID stuff. What I am trying to figure out is how to have it parse the gateway devices as before(I have that code working) but have to compare the data based on the names I give the device in the DM so that I can poll there states and update the DM every 30sec or so.

Page 3 of 3 FirstFirst 123

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •