Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
indigo_2023.2_documentation:device_class [2024/06/27 00:08] – external edit 127.0.0.1indigo_2023.2_documentation:device_class [2025/02/18 20:36] (current) – external edit 127.0.0.1
Line 271: Line 271:
 |//''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'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|
Line 303: Line 303:
 ^  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|
Line 392: Line 392:
 |//''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 ===
-Certain device properties are writeable for all Indigo devices, including a device's name, description, enabled/disabled state and remote display. You can't do this directly because device instances are read only. You must first get a copy of the device, make changes to the copy, and then send the copy back to the server. For example, +Certain device properties are writeable for all Indigo devices, including a device's name, description, enabled/disabled state and remote display. You can't do this directly because device instances are read only. You must first get a copy of the device, make changes to the copy, and then send the copy back to the server. For example,
  
 <code> <code>
Line 416: Line 416:
 indigo.device.displayInRemoteUI(987654321, False) indigo.device.displayInRemoteUI(987654321, False)
 </code> </code>
-=== Updating Plugin Device Properties Examples ===  +=== Updating Plugin Device Properties Examples === 
-Some device base class properties need to be updated differently than the examples above because they can only be updated by the plugin that owns them. Properties like //''address''// and //''version''// can be updated by their own plugins. For example, +Some device base class properties need to be updated differently than the examples above because they can only be updated by the plugin that owns them. Properties like //''address''// and //''version''// can be updated by their own plugins. For example,
  
 <code> <code>
Line 431: Line 431:
 ==== 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'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:
Line 622: Line 622:
 |<code>indigo.device.create(protocol=indigo.kProtocol.Plugin, |<code>indigo.device.create(protocol=indigo.kProtocol.Plugin,
     address='F8',     address='F8',
-    name='Device Name Here',  +    name='Device Name Here', 
-    description='Description Here', +    description='Description Here',
     pluginId='com.mycompany.pluginId',     pluginId='com.mycompany.pluginId',
     deviceTypeId='myDeviceTypeId',     deviceTypeId='myDeviceTypeId',
Line 754: Line 754:
 === Remove Delayed Actions === === Remove Delayed Actions ===
  
-This command will remove delayed actions for the specified device. +This command will remove delayed actions for the specified device.
  
 ^  Command Syntax Examples  ^ ^  Command Syntax Examples  ^
Line 877: Line 877:
     address="F7",     address="F7",
     deviceTypeId="LampLinc Plus Plug-In Dimmer")</code>     deviceTypeId="LampLinc Plus Plug-In Dimmer")</code>
-    +
 <code># Getting a device <code># Getting a device
 myDevice = indigo.devices[123]</code> myDevice = indigo.devices[123]</code>
Line 886: Line 886:
 <code># Logging a message if it’s an X10 device <code># Logging a message if it’s an X10 device
 if (myDevice.protocol == indigo.kProtocol.X10): if (myDevice.protocol == indigo.kProtocol.X10):
-    indigo.server.log("device is an X10 device"  +    indigo.server.log("device is an X10 device")
 </code> </code>
  
Line 958: Line 958:
 === Brighten === === Brighten ===
  
-Changes the brightness of the specified light relative to the current brightness. +Changes the brightness of the specified light relative to the current brightness.
  
 ^  Command Syntax Examples  ^ ^  Command Syntax Examples  ^
Line 1053: Line 1053:
 <code> <code>
 # RGB value / 255 * 100 # RGB value / 255 * 100
-redLevel = 128 +redLevel = 128
 newRedLevel = redLevel / 255 * 100 newRedLevel = redLevel / 255 * 100
 </code> </code>
Line 1071: Line 1071:
 # less than that, but only if it’s turned on # less than that, but only if it’s turned on
 myDevice = indigo.devices[123] myDevice = indigo.devices[123]
-if ((myDevice.brightness < 75) and +if ((myDevice.brightness < 75) and
     (myDevice.onState)):     (myDevice.onState)):
  indigo.dimmer.setBrightness(myDevice, 75)</code>  indigo.dimmer.setBrightness(myDevice, 75)</code>
- +
 <code># Brighten a light by 25% after 10 minutes <code># Brighten a light by 25% after 10 minutes
 indigo.dimmer.brighten(123, by=25, delay=600) indigo.dimmer.brighten(123, by=25, delay=600)
Line 1080: Line 1080:
  
 <code># Logging a message if it’s showing in Indigo Touch <code># Logging a message if it’s showing in Indigo Touch
-myDevice = indigo.devices[123] +myDevice = indigo.devices[123]
 if (myDevice.remoteDisplay): if (myDevice.remoteDisplay):
  indigo.server.log("device is showing in Indigo Touch")</code>  indigo.server.log("device is showing in Indigo Touch")</code>
Line 1094: Line 1094:
 <code># Set a device’s brightness to 75 if it’s currently <code># Set a device’s brightness to 75 if it’s currently
 # less than that, but only if it’s turned on # less than that, but only if it’s turned on
-myDevice = indigo.devices[123]  +myDevice = indigo.devices[123] 
-if ((indigo.devices[123].brightness < 75) and +if ((indigo.devices[123].brightness < 75) and
     (indigo.devices[123].onState)):     (indigo.devices[123].onState)):
  indigo.dimmer.setBrightness(indigo.devices[123], 75)</code>  indigo.dimmer.setBrightness(indigo.devices[123], 75)</code>
Line 1154: Line 1154:
 myIODevice = indigo.devices[123] myIODevice = indigo.devices[123]
 if (!myIODevice.binaryInputs[2]): if (!myIODevice.binaryInputs[2]):
- indigo.iodevice.setBinaryOutput(myIODevice, + indigo.iodevice.setBinaryOutput(myIODevice,
  index=1,  index=1,
  value=False)</code>  value=False)</code>
- +
 ===== SensorDevice ===== ===== SensorDevice =====
  
Line 1397: Line 1397:
  
 ^  Command Syntax Examples  ^ ^  Command Syntax Examples  ^
-|<code>indigo.sprinkler.run(123, schedule=[10,15,8, 0, 0, 0, 0, 0])</code>|+|<code>indigo.sprinkler.run(123, schedule=[10, 15, 8, 0, 0, 0, 0, 0])</code>|
  
 ^  Parameters  ^^^^ ^  Parameters  ^^^^
Line 1430: Line 1430:
  
 <code># run schedule <code># run schedule
-indigo.sprinkler.run(123, +indigo.sprinkler.run(123,
     schedule=[10,15,8, 0, 0, 0, 0, 0])     schedule=[10,15,8, 0, 0, 0, 0, 0])
 </code> </code>
Line 1644: Line 1644:
  
 # set the thermostat mode to auto # set the thermostat mode to auto
-indigo.thermostat.setHvacMode(123, +indigo.thermostat.setHvacMode(123,
     value=indigo.kHvacMode.HeatCool)     value=indigo.kHvacMode.HeatCool)
  
  • /www/perceptive/wiki/data/attic/indigo_2023.2_documentation/device_class.1719446928.txt.gz
  • Last modified: 2024/06/27 00:08
  • by 127.0.0.1