[ANSWERED]: Device State defaultValue for String type?

Posted on
Wed May 06, 2015 1:08 pm
SpencerJRoberts offline
User avatar
Posts: 256
Joined: Dec 09, 2012
Location: Mountain View, CA

[ANSWERED]: Device State defaultValue for String type?

I'm trying to initialize a state of type String in my Devices.xml and it doesn't seem to be working. Is this possible or the right way to do it?

Code: Select all
<State id='scheduled_days' defaultValue='0000000'>
    <ValueType>String</ValueType>
    <TriggerLabel>Scheduled Days</TriggerLabel>
    <ControlPageLabel>Scheduled Days</ControlPageLabel>
</State>
Last edited by SpencerJRoberts on Wed May 06, 2015 7:04 pm, edited 1 time in total.

Posted on
Wed May 06, 2015 4:01 pm
DaveL17 offline
User avatar
Posts: 6781
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Device State defaultValue for String type?

The <valueType> element looks fine, what I'm not sure about is the defaultValue attribute of the device state. That attribute's not listed in the Wiki and I've only ever set defaultValues for PluginProps. That said, the defaultValue attribute could've been added later and somehow missed on the Wiki.

My advice is to try deleting the defaultValue attribute and see what that gets you.

http://wiki.indigodomo.com/doku.php?id= ... devicesxml

Good luck,
Dave

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

[My Plugins] - [My Forums]

Posted on
Wed May 06, 2015 4:39 pm
SpencerJRoberts offline
User avatar
Posts: 256
Joined: Dec 09, 2012
Location: Mountain View, CA

Re: Device State defaultValue for String type?

It's a device state, and the state works if I "manually" set it to the same value somewhere later in the code. What does not seem to work is having that default state value set when a new device is created. I don't want to use deviceStartComm() because I never want the device state to return to the default value after device creation. I think I can implement this in another way (I'm BRAND new to plugin development) but just want to see if this will work before I go that route. Thanks!

Posted on
Wed May 06, 2015 10:44 pm
RogueProeliator offline
User avatar
Posts: 2501
Joined: Nov 13, 2012
Location: Baton Rouge, LA

Re: [ANSWERED]: Device State defaultValue for String type?

It's a device state, and the state works if I "manually" set it to the same value somewhere later in the code. What does not seem to work is having that default state value set when a new device is created. I don't want to use deviceStartComm() because I never want the device state to return to the default value after device creation.

I'm pretty sure that you are going to have to just initialize the states on the very first run -- there is no particular reason to avoid deviceStartComm that I know of, you just need to check a state that you know should have some value and, if empty/blank, setup all the default values. It accomplishes the same result as if the XML supported a defaultValue.

Adam

Posted on
Thu May 07, 2015 8:25 am
matt (support) offline
Site Admin
User avatar
Posts: 21424
Joined: Jan 27, 2003
Location: Texas

Re: [ANSWERED]: Device State defaultValue for String type?

Correct, the defaultValue attribute only applies to the properties, not states. I'd suggest initializing the states in deviceStartComm and just checking to see if it is blank to override overwriting a non-default value.

Image

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 5 guests