View Full Version : Some notes about the DeviceManager
Promixis
November 26th, 2006, 03:27 PM
The DeviceManager is one of the core new features of G5. It provides a common schema to represent devices and their controls. The goal is too simplify working with devices in Girder.
Features/Notes... (in no particular order)
1. A hardware or software plugin/component interfaces to the DeviceManager via its Provider. Ie. The Insteon plugin uses a provider to add/remove and update devices in the DM.
2. Each device MUST have a unique PATH. The path is created by a plugins provider. Typically, a path will identify the machine the device originates from ,the plugin and then an ID. Eg, for X10, we would have a path of MyPC\X10\A1 or for Insteon MyPC\Insteon\XX.XX.XX. The path is critical as make scripts and actions immune to changes in device naming
3. Device Loc/Name. Each device is given a location and name (user controlled). The location and name are stored in the Local Device Manager. Therefore, we have a centralized place to manager devices. As well, this means many plugin will no longer have to provider their own DUI pages for managing device naming. As well, devices are giving a Display Name that is users of the Device Manager get when building an interface of devices.
4. Each device can 1 or more controls. Controls follow a predefined schema that makes it easy for NetRemote or the G5 Webserver to build pages. It also makes it easy to script actions. For instance, regardless of the underlying hardware or protocols, you can always turn a light device off using the same lua code.
There is much more, so fire away with quesitons.
harleydude
December 10th, 2006, 04:36 PM
Will the DM track when a device changes state and will that information be able to be extracted?
Promixis
December 10th, 2006, 09:12 PM
DM tracks when devices are changed and the events are published. That is how NR and the WebServer stay up to date.
mhwlng
December 30th, 2006, 01:16 PM
(maybe this needs to go into the NR forum :-) )
I want to see the current state of an X10 motion detector in Netremote
in NRD 'netremote variables', I see a bunch of DM stuff
like
SERVER\X10\A9\Condition Ready
but If I do :
NetRemote.GetVariable("SERVER\X10\A9\Condition")
then I get an empty string ?
what am I doing wrong ?
Marcel
Rob H
December 30th, 2006, 01:18 PM
You're going to kick yourself!
Double up the backslashes or use [[ ]] to enclose the string.
mhwlng
December 30th, 2006, 01:20 PM
ooops (back to reading the lua manual again)....
(quick reply by the way, 2 minutes)
Marcel
mhwlng
December 30th, 2006, 01:45 PM
works ok now,
see (resized) picture :
* it's a fully interactive svg file (shown in a web browser) ,
this means :
it's a vector drawing, so will resize to fit any resolution ccf file !
the colour scheme/line thickness etc. can be adjusted easily
it uses the same techniques as discussed here (svgsample2) :
http://www.promixis.com/forums/showthread.php?t=9550
the lights/motion detectors/radiators/heater, now light up correctly in response to DM data (updated every 500 ms)...
example javascript :
var svgElement = svgDoc.getElementById("id12");
if (ax.GetVariable("SERVER\\X10\\A12\\Condition")=="Not Ready")
svgElement.setAttribute("style","fill:red;");
else
svgElement.setAttribute("style","fill:lightgreen;");
and the room background changes, if girder thinks there is somebody in the room. (the motion detectors can't be used for this directly, because if you sit in the sofa watching tv, they don't detect motion ) I'm still tinkering with this (the goal is to automatically switch off the lights if the room isn't occupied)...
I could still add dim level display (for example as a tooltip), room temperature etc. and the ability to click on a light to switch it on/off or even animation for the light/motion detector symbols
Marcel
Rob H
December 30th, 2006, 04:51 PM
Very nice!
mhwlng
January 1st, 2007, 04:35 AM
I'm trying to change the lights from the svg file (by clicking on the lightbulb)
I do this by calling :
DM.SetValue("SERVER\\X10\\A7", "Switch", "Off")
but that doesn't work :-)
do I have the wrong function or syntax ?
(I do see DM SetValue in the girder log)
(note that I don't have require 'DMSupport' in my lua file !!)
Marcel
mhwlng
January 1st, 2007, 04:44 AM
never mind...
I confused an NR function with a girder function
this works ok :
ax.GenerateAction(-1,0,1,'SERVER\\X10\\A7\\Switch(Off)');
Rob H
January 1st, 2007, 09:37 AM
You could also try using
require 'DMCore'
Then you could use DM.SetValue, and also the DM.Auto, DM.AutoRepeat and DM.Cycle functions in Lua event actions (on a normal NR button of course).
mhwlng
January 1st, 2007, 09:40 AM
Then you could use DM.SetValue.....
I'm calling this from javascript from an .lhtml file served by the built-in web server in NR :
function LampControl(event, gen)
{
var ax = new ActiveXObject('NetRemote.App');
var svgElement = svgDoc.getElementById(gen);
if(svgElement.getAttribute("style")=="fill:yellow;")
{
ax.GenerateAction(-1,0,1,'SERVER\\X10\\'+gen+'\\Switch(Off)');
}
else
{
ax.GenerateAction(-1,0,1,'SERVER\\X10\\'+gen+'\\Switch(On)');
}
}
I'm not sure if I can call a NR lua function via the NR com object?
Marcel
Rob H
January 1st, 2007, 09:52 AM
Hmm.. I don't know - that's one for Ben I guess.
mhwlng
January 1st, 2007, 10:11 AM
I added
require 'DMCore'
which, unlike require 'DMSupport', doesn't kill NR :-)
this action should call lua code (normally from a button) :
ax.GenerateAction(-999,7,1,'DM.SetValue(\"SERVER\\X10\\'+gen+'\", \"Switch\", \"Off\")');
but in dbgview I see :
[49552] DM: No DMhost!
[49552]
[49552] 17:06:14.828] Lua (Unknown)] Error running lua chunk
[49552] ...rogram Files\Promixis\NetRemote/luascript/DMCore.lua:120: attempt to concatenate global `host' (a nil value)
[49552] 17:06:14.828] Lua (Unknown)] DM.SetValue("SERVER\X10\A2", "Switch", "On")
I also tried
-999,7,2 (which is described as lua event in NRD)
then I see
[50764] DM: No DMhost!
[50764]
[50764] DM: No DMhost!
[50764]
[50764] 17:07:22.718] Lua] Error running lua chunk
[50764] attempt to call a string value
Marcel
Rob H
January 1st, 2007, 11:01 AM
Hmm... do you have your own OnCCFLoad(), I'm guessing you do.
You need to cache and call the old OnCCFLoad function from your OnCCFLoad.
mhwlng
January 1st, 2007, 11:07 AM
I don't use onccfload anymore...
I only have a bunch of these :
NetRemote.RegisterEvent(Events.CCFLoaded,
function()
....
...
end)
note that I don't have require 'DMSupport' defined !
Marcel
Rob H
January 1st, 2007, 11:28 AM
That should be fine in theory. DMCore contains the base DM functions, while DMSupport is intended for use with the Flatstyle DM CCF.
It sounds as though DMInit isn't being called. Do you see an event in Girder called DM.Query - it should appear around the time that NR connects to Girder.
mhwlng
January 1st, 2007, 11:35 AM
Do you see an event in Girder called DM.Query
yes....
and removing require 'DMCore' again, stops that message, as expected...
Marcel
Rob H
January 1st, 2007, 12:04 PM
When you start NR do you see something like
[2148] DM: Devices updated
[2148]
[2148] DM: Got a DM host cordelia
[2148]
[2148] DM: Adding device cordelia\TestHarness\Light Dimmer 3.1
[2148]
[2148] DM: Adding device cordelia\TestHarness\Security Area 3
mhwlng
January 1st, 2007, 12:09 PM
the problem related to the host variable is because there is NO global host variable in your code
I see a function parameter :
function DM.DeviceUpdate(devices, host, transaction)
...
end
I see a local variable :
local function GetGirderInstance()
...
local host = NetRemote.GetVariable('DMHost')
...
end
here, is the error : it requires a non-existing global variable :
function DM.Func(devPath, control, value)
...
DM.Log(6, "Couldn't find instance for "..host)
....
end
removing the 'host' part from DM.Log still doesn't fix the problem,though :-)
the problem is here :
function DM.DeviceUpdate(devices, host, transaction)
...
local girder = NetRemote.GetPlugin('Girder')
DM.Instance = girder:GetInstance(host)
...
host has the correct value 'SERVER' but DM.Instance = nil....
in the NR girder plugin, the value was 'server'.
I changed it to upper case and that fixed that problem...
the last problem was, that I had to quadruple up the slashes
as a wise man said earlier in this thread :
You're going to kick yourself!
this works now :
ax.GenerateAction(-999,7,1,'DM.SetValue(\"SERVER\\\\X10\\\\'+gen+'\", \"Switch\", \"Off\")');
Marcel
Rob H
January 1st, 2007, 12:26 PM
Well spotted. I think the DMHost is from an older version of the code.
Looks like it would make sense for the GetInstance method to be case insensitive.
vBulletin® v3.7.4, Copyright ©2000-2008, Jelsoft Enterprises Ltd.