|
Page 1 of 1
|
[ 7 posts ] |
|
NOAA plugin as model: Problem adding "States"
| Author |
Message |
|
BillC
Joined: Mar 09, 2008 Posts: 183
|
 NOAA plugin as model: Problem adding "States"
I've built a plugin to move XML data into Indigo from an energy monitoring system, using the NOAA plugin as a model, and with some invaluable help from Jay have it working well. The problem now is adding "States" which refers to the XML data elements that are imported. I've declared a new state called "propaneHeat" in the devices.xml file without error; the problem comes when I add it and it's paired label to the global declaration "fields" at the top of the plugin.py file. The plugin gives an error at startup of WEL Data Error exception in deviceStartComm(WEL Logger): 'key propaneHeat not found in dict'
Makes no difference whether I reload the plugin, disable and then enable it, or even restart the Indigo Server, I can't get the new data element accepted. What am I missing here? I've checked and rechecked and the spelling is the same in both devices.xml and plugin.py (one of my favorite ways to get hard to find bugs!). Doesn't the devices.xml file create the dictionary?
|
| Sat Dec 17, 2011 5:30 pm |
|
 |
|
jay (support)
Site Admin
Joined: Mar 19, 2008 Posts: 6662 Location: Austin, Texas
|
 Re: NOAA plugin as model: Problem adding "States"
Can't really help without seeing the code - post= the 'fields' dict declaration and the deviceStartComm() method declaration inside a code block (so we can see indentation).
And, no - Devices.xml only declares the states that the device supports at creation time - I created the 'fields' dictionary manually at the top of the plugin.py file. It's purpose is specific to the NOAA plugin and is meant as the map from the NOAA XML feed element names to the state id as specified in the Devices.xml file.
_________________ Jay (Indigo Support)
|
| Sun Dec 18, 2011 12:54 am |
|
 |
|
BillC
Joined: Mar 09, 2008 Posts: 183
|
 Re: NOAA plugin as model: Problem adding "States"
Hi, Jay, and thanks for your help (and patience!) I just tried again, and did not get the error, so I'm really confused. I have to assume that I made a syntax error somehow in my earlier attempts. I have some more fields to add as I add sensors to the system, so I'll see if I have further trouble.
I'm doing pretty much the same thing as you did in the NOAA plugin...pulling XML data from a web site to use within Indigo for control page displays, triggers, etc, so much of the code is unchanged from your plugin.
|
| Sun Dec 18, 2011 6:12 am |
|
 |
|
BillC
Joined: Mar 09, 2008 Posts: 183
|
 Re: NOAA plugin as model: Problem adding "States"
It's happening again, and all I did was edit the field declaration to change the names of a couple of items in the XML source (the second name in the pairs) (and NOT propaneHeat). Would appreciate any insights as to what's going on. Dec 18, 2011 13:10:47 Reloading plugin "WEL Data 1.0.0" Stopping plugin "WEL Data 1.0.0" (pid 10484) Plugin "WEL Data" disconnected Starting plugin "WEL Data 1.0.0" (pid 10487) Plugin "WEL Data" connected Plugin "WEL Data 1.0.0" started WEL Data Error exception in deviceStartComm(WEL Logger): 'key propaneHeat not found in dict'
Global fields declaration, based on NOAA plugin: - Code: Select all
fields = {"propaneHeat":'PropaneHeating',"dataDate":'Date',"dataTime":'Time',"heating":'HP_Heat1S',"cooling":'HP_Cool1S',"defrost":'HP_Defrost',"stage2":'HP_ComprHi',"vaporTemp":'HP_VaporT',"liquidTemp":'HP_LiquidT'}
Following block is unchanged from the NOAA plugin: - Code: Select all
def deviceStartComm(self, device): self.debugLog("Starting device: " + device.name) if device.id not in self.deviceList: self.update(device) self.deviceList.append(device.id)
|
| Sun Dec 18, 2011 12:22 pm |
|
 |
|
jay (support)
Site Admin
Joined: Mar 19, 2008 Posts: 6662 Location: Austin, Texas
|
 Re: NOAA plugin as model: Problem adding "States"
Turn on debugging - that might give some more information though I don't know what you've changed.
Since it started working then stopped after a change I suspect that you've got some error somewhere. I'd be kinda suspicious of how you were looping through the XML and the 'fields' element as I posted above. Unfortunately, I can't tell because I don't see all the relevant code. If you can't figure it out, email the entire plugin to indigo DASH support AT perceptiveautomation DOT com and I'll have a look at it tomorrow.
_________________ Jay (Indigo Support)
|
| Sun Dec 18, 2011 12:52 pm |
|
 |
|
BillC
Joined: Mar 09, 2008 Posts: 183
|
 Re: NOAA plugin as model: Problem adding "States"
I think I've fixed the issue (can now add items to the fields declaration). All I did was, in essence, delete and then recreate the Indigo Device that used the plugin.
After playing with the code for several hours, I made a copy of the plugin, deleted the Indigo Device that used it, and installed a new device using the copy. I could add items without getting errors. I then disabled the new plugin, deleted the new device, enabled the original, and recreated the device. Adding items again gave no errors. With no code changes (other than amending the plist to differentiate between plugins), the only change had to be deleting and recreating the Indigo Device. (As noted above, I'd tried both reloading and disabling/enabling the plugin, and restarting the Indigo server, without success.)
It still bugs me not to know why deleting the device changed the behavior, but the bottom line is that it's now apparently working. If someone else runs into the behavior described in this thread, perhaps these notes will help.
|
| Mon Dec 19, 2011 12:40 pm |
|
 |
|
jay (support)
Site Admin
Joined: Mar 19, 2008 Posts: 6662 Location: Austin, Texas
|
 Re: NOAA plugin as model: Problem adding "States"
AH - when a device is created, it's created with the states that are defined at the time of creation - changing the Device.xml won't automatically change the states in previously created devices so they need to be recreated. In the vast majority of cases, states are static once the device is created. You can add states to a previously created device if you need to but I wouldn't bother unless over the lifetime of a device the states will be changing.
_________________ Jay (Indigo Support)
|
| Mon Dec 19, 2011 1:51 pm |
|
|
|
Page 1 of 1
|
[ 7 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 1 guest |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|