Saving props for main device in DeviceFactory device.

Posted on
Thu Jan 18, 2018 4:03 am
TwitchCaptain offline
User avatar
Posts: 104
Joined: Dec 13, 2016
Location: San Francisco

Saving props for main device in DeviceFactory device.

Hello,

I'm trying to create fields with values from the Sync and Define window for a DeviceFactory device, but the values are never saved. I can access them in validateDeviceFactoryUi() but after that they go poof. Is it possible to have shared device config for a group of DeviceFactory devices? For instance, they all share an IP, but live on different ports. Simple example, but mine's more complex and involves a timeout, interval, username and password as well as an IP. I'd like to set these up in the factory and not per sub-device. Each sub device has its own set of configs; and those do save!

This is a small (incomplete) example that show the problem. `address` is never saved and always displays the default.

Code: Select all
Devices.xml
<?xml version="1.0"?>
<Devices>
   <DeviceFactory>
      <Name>Network Server</Name>
      <ButtonTitle>Save</ButtonTitle>
      <ConfigUI>
         <Field id="address" type="textfield" defaultValue="192.168.1.100">
            <Label>IP Address:</Label>
         </Field>


Thanks for any insight!
-david

Posted on
Thu Jan 18, 2018 9:39 am
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: Saving props for main device in DeviceFactory device.

So you create the device and the default values show in the UI, on validate they also show in valuesDict, but once created they aren't in dev.pluginProps anymore? Have you tried to debug the device by:
Code: Select all
indigo.server.log(unicode(dev.pluginProps))

To see if they are, indeed, gone?

Plus I believe 'address' is reserved for the device address, have you looked at the device address to see if it got that IP address?

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Thu Jan 18, 2018 10:20 am
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Saving props for main device in DeviceFactory device.

The valuesDict passed into validateDeviceFactoryUi() is not stored anywhere automatically. There are only plugin level properties (self.pluginPrefs where self is the plugin instance) and device level properties (dev.pluginProps where dev is a device instance). For the Z-Wave plugin we consider the first device create by the device factory as the main/root device, and store all information that is global to the entire device group there. Somewhat of a pain but it works since there isn't "group level" data currently.

Image

Posted on
Thu Jan 18, 2018 11:27 am
TwitchCaptain offline
User avatar
Posts: 104
Joined: Dec 13, 2016
Location: San Francisco

Re: Saving props for main device in DeviceFactory device.

Hi Matt,
Thanks for the quick response, albeit not the one I was hoping for. :D

I hope you provide an ability to enter, store, and retrieve grouped-devices configuration. I spent a good two hours debugging the form only to find none of it is saved and there's no way to ever re-fill the form with the "current" values. Having group config will save the end-user a lot of time re-entering the same ip/name/password/timeout/interval over and over and over. Since settings are only per-plugin or per-subdevice I'm going to have to just use normal devices and not a factory. I saw another thread about using grouped devices without DeviceFactory, so I suppose that's my next attempt. Perhaps then I can save/use the props on the first device to setup the rest. We shall find out.

Thanks!

Posted on
Thu Jan 18, 2018 3:29 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: Saving props for main device in DeviceFactory device.

you can pre-populate the properties before they are presented to the user from with the plugin with
def getDeviceConfigUiValues( ...)
...
return propsDict

First device created: inert all info
second .. the plugin populates the props with the values form the last one changed.

that is ok if they never change. ... If they will change you would need to go through all devices and update the properties after a new device is saved


Karl

Posted on
Sat Jan 20, 2018 12:29 am
TwitchCaptain offline
User avatar
Posts: 104
Joined: Dec 13, 2016
Location: San Francisco

Re: Saving props for main device in DeviceFactory device.

I totally figured it out. I found this awesome example plugin to work from: https://github.com/RogueProeliator/Indi ... r%20Plugin

My new plugin is here, if you care to see how to did it: https://github.com/davidnewhall/indigo-8channel-relay

I determined I didn't need to save (or even use a) username/password and the port is mostly just hard coded (but easily changed to editable later if needed). I moved the timeout and interval to the plugin settings instead of trying to manage it per device. The way I poll the devices is pretty efficient and using separate timeouts/intervals was not as clear or efficient a solution.

I'm very happy with how this plugin turned out and it's going to aid me in completing my APC power strip plugin.

Can someone point me to the docs on how to make device states show up at the bottom of indigo? Like where you control a thermostat or see a device's last update time; I want to put custom data there, is that possible?

Thanks for the help!!

Posted on
Sat Jan 20, 2018 5:29 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: Saving props for main device in DeviceFactory device.

Device states at the bottom.
It took me some time to figure it out: just move the line up with your mouse then all the device states are visible.
Karl


Sent from my iPhone using Tapatalk

Posted on
Sun Jan 21, 2018 2:34 pm
TwitchCaptain offline
User avatar
Posts: 104
Joined: Dec 13, 2016
Location: San Francisco

Re: Saving props for main device in DeviceFactory device.

Wow that's a really cool trick to see the custom states; had no idea that was hiding there. But the box above that just has "On State" and "Last Update" with plenty of room for my custom states. I suppose there is no simple way to populate that area with custom info. If I "mimic" a thermostat I can put a temp/humidity there, etc, but otherwise it looks rather plain. Thanks!

Posted on
Sun Jan 21, 2018 5:14 pm
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Saving props for main device in DeviceFactory device.

You can't add information to the upper panel, but the notion has been requested in the past. :D

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Mon Jan 22, 2018 10:50 am
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Saving props for main device in DeviceFactory device.

That's a standard "handle" control (indicated by the dot) in Cocoa, so no tricks needed... ;)

The upper "Device Details" tile is actually for device properties and since those can't be expanded like states we control what's displayed there (some device types have a lot of them showing, like energy monitors. The "Custom States" tile is there specifically to display additional states added by plugins, etc.

That behavior isn't likely to change.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests