| Both sides previous revision Previous revision | |
| indigo_2024.1_documentation:device_class [2024/11/16 12:37] – [Set Color Levels] davel17 | indigo_2024.1_documentation:device_class [2025/02/18 20:36] (current) – external edit 127.0.0.1 |
|---|
| |//''errorState''//| string | No | 1.0 |the string that represents the current error for the device, empty string if there is no error| | |//''errorState''//| string | No | 1.0 |the string that represents the current error for the device, empty string if there is no error| |
| |//''folderId''//| integer | No | 1.0 |the unique ID of the folder this device is in (0 if it's not in a folder) - use //''moveToFolder()''// method to change| | |//''folderId''//| integer | No | 1.0 |the unique ID of the folder this device is in (0 if it's not in a folder) - use //''moveToFolder()''// method to change| |
| |//''globalProps''//| dictionary | No | 1.0 |an //''indigo.Dict()''// representing all name/value pairs associated with this device - each plugin will have it's own dictionary (//''globalProps[pluginId]''//) - see [[#about_plugin_properties|About Plugin Properties]] below for details| | |//''globalProps''//| dictionary | No | 1.0 |an //''indigo.Dict()''// representing all name/value pairs associated with this device - each plugin will have its own dictionary (//''globalProps[pluginId]''//) - see [[#about_plugin_properties|About Plugin Properties]] below for details| |
| |//''id''//| integer | No | 1.0 |id or instance of the device, assigned on creation by IndigoServer| | |//''id''//| integer | No | 1.0 |id or instance of the device, assigned on creation by IndigoServer| |
| |//''lastChanged''//| datetime | No | 1.0 |the last date/time that the device was changed - populated by IndigoServer| | |//''lastChanged''//| datetime | No | 1.0 |the last date/time that the device was changed - populated by IndigoServer| |
| ^ indigo.kStateImageSel ^^ | ^ indigo.kStateImageSel ^^ |
| ^//''Value''// ^Description ^ | ^//''Value''// ^Description ^ |
| |//''Auto''// |specifies Indigo Server to pick a device image icon that best represents this device class and/or state<html><br></html> value (default for all devices)| | |//''Auto''// |specifies Indigo Server to pick a device image icon that best represents this device class and/or state value (default for all devices)| |
| |//''AvPaused''// |overrides to show a A/V paused icon| | |//''AvPaused''// |overrides to show a A/V paused icon| |
| |//''AvPlaying''// |overrides to show a A/V playing icon| | |//''AvPlaying''// |overrides to show a A/V playing icon| |
| |//''setErrorStateOnServer('error string')''//| Yes | 1.0 |The supplied string will show in the state column and turn it red. Passing ''//None//'' will clear it. | | |//''setErrorStateOnServer('error string')''//| Yes | 1.0 |The supplied string will show in the state column and turn it red. Passing ''//None//'' will clear it. | |
| |//''updateStateOnServer(key='keyName', value='Value', clearErrorState=True)''//| Yes | 1.0 |Use this method to update the value of one of your device's states on the server. The server will propagate the change out to any connected clients and fire any triggers that are defined on that state. Pass "true" (default) or "false" on the clearErrorState parameter (not required) to have the error state of the device (set with //''setErrorStateOnServer''// above) cleared. | | |//''updateStateOnServer(key='keyName', value='Value', clearErrorState=True)''//| Yes | 1.0 |Use this method to update the value of one of your device's states on the server. The server will propagate the change out to any connected clients and fire any triggers that are defined on that state. Pass "true" (default) or "false" on the clearErrorState parameter (not required) to have the error state of the device (set with //''setErrorStateOnServer''// above) cleared. | |
| |//''updateStateImageOnServer(stateImageSel)''//| Yes | 1.18 |Use this method to override which [[#state_image_sel_enumeration|device state image icon]] is shown for this device on Indigo Touch and the Indgo client UI. The default behavior is for Indigo Server to automatically determine which icon should be shown based on the device class and state value. Only call this method if overriding the default behavior is needed. | | |//''updateStateImageOnServer(stateImageSel)''//| Yes | 1.18 |Use this method to override which [[#state_image_sel_enumeration|device state image icon]] is shown for this device on Indigo Touch and the Indigo client UI. The default behavior is for Indigo Server to automatically determine which icon should be shown based on the device class and state value. Only call this method if overriding the default behavior is needed. | |
| |
| === Updating Device Properties Examples === | === Updating Device Properties Examples === |
| ==== About Plugin Properties ==== | ==== About Plugin Properties ==== |
| |
| Devices have properties - some are class properties, defined by the class itself. One of the biggest requests we've gotten in the past is some way to add arbitrary properties to a device - so that you could store your own data with the device in the database. And with plugin defined devices, we needed a place to store the properties that you need to operate the device. That's what the //''pluginProps''// and //''globalProps''// represent - the additional properties that are not defined by the class. //''globalProps''// is a dictionary of every additional property defined for the device - each plugin has it's own dictionary of props in here which are readable by anyone. //''pluginProps''// is a shortcut to get to your plugin's props and are only writable by your plugin once the plugin has been created - a script can create a device supplied by your plugin along with the necessary properties, which are passed in on the //''create()''// method. You should publish the properties necessary to make your device work so that scripters can create your devices. | Devices have properties - some are class properties, defined by the class itself. One of the biggest requests we've gotten in the past is some way to add arbitrary properties to a device - so that you could store your own data with the device in the database. And with plugin defined devices, we needed a place to store the properties that you need to operate the device. That's what the //''pluginProps''// and //''globalProps''// represent - the additional properties that are not defined by the class. //''globalProps''// is a dictionary of every additional property defined for the device - each plugin has its own dictionary of props in here which are readable by anyone. //''pluginProps''// is a shortcut to get to your plugin's props and are only writable by your plugin once the plugin has been created - a script can create a device supplied by your plugin along with the necessary properties, which are passed in on the //''create()''// method. You should publish the properties necessary to make your device work so that scripters can create your devices. |
| |
| We mentioned before that devices were read-only, and that's true, and that you'd need to use commands in a different command name space. That's //**mostly**// true. Here's one exception to that rule: to change a device's pluginProps (it must be "owned" by your plugin - that is, the pluginId must be set to your id), you use a method that's in the device's class: replacePluginPropsOnServer(). Here's an example: | We mentioned before that devices were read-only, and that's true, and that you'd need to use commands in a different command name space. That's //**mostly**// true. Here's one exception to that rule: to change a device's pluginProps (it must be "owned" by your plugin - that is, the pluginId must be set to your id), you use a method that's in the device's class: replacePluginPropsOnServer(). Here's an example: |