[ANSWERED]: Create states dynamically

Posted on
Fri Nov 06, 2015 11:10 am
jblackburn offline
Posts: 77
Joined: Dec 11, 2013
Location: Quebec, Canada

[ANSWERED]: Create states dynamically

Hi,

Within a custom plugin, is it possible to add (or remove) device state(s) dynamically? I’ve search across the board without success! States are created in the Device.xml but the definition (not the content) are static (name and qty). I’ve created a plugin pulling events from the iCloud Calendar. In the device, I’ve states (e.g. Event01, Event02, …) sorted by date. According to the device configuration, I want to adjust the number of states according to the user preferences. Is it possible or I stick with a predefined number of events? Maybe my strategy is not correct…

Joël
Last edited by jblackburn on Mon Nov 09, 2015 8:41 am, edited 1 time in total.

Posted on
Fri Nov 06, 2015 11:40 am
RogueProeliator offline
User avatar
Posts: 2506
Joined: Nov 13, 2012
Location: Baton Rouge, LA

Re: Create states dynamically

According to the device configuration, I want to adjust the number of states according to the user preferences

You likely will want to override the plugin's getDeviceStateList to return your own list of states; by default this going to just return the list of states from the Devices.xml file, but you can do whatever you would like to do in the function - either completely handle it dynamically or only add to the existing list or whatever.

Have a look at the Plugin Developer Documenter if you want to follow the lifecycle of calls and see some documentation on the functions. There are a couple of plugins, I believe, that use this scenario so you may be able to use them as an example as well (hopefully the authors will chime in because, as I know we have discussed this before, I am not sure which particular ones I am remembering doing that.)

Adam

Posted on
Mon Nov 09, 2015 8:42 am
jblackburn offline
Posts: 77
Joined: Dec 11, 2013
Location: Quebec, Canada

Re: [ANSWERED]: Create states dynamically

Thanks for your response!

Joël

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 4 guests

cron