Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| indigo_2024.1_documentation:virtual_devices_interface [2024/09/12 11:06] – [Controlling Scripts] davel17 | indigo_2024.1_documentation:virtual_devices_interface [2025/04/14 20:10] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 20: | Line 20: | ||
| To create a device group, you just create a new device, select '' | To create a device group, you just create a new device, select '' | ||
| - | {{device_group_config.png? | + | {{device_group_config.png? |
| - | Select the devices you want to be in the group (only dimmer devices, relay (on/off) devices, and sensor devices that support an on/off state are available). To select multiple, hold down the command key and click the device in the list. Notice that the devices all have something in parenthesis | + | Select the devices you want to be in the group (only dimmer devices, relay (on/off) devices, and sensor devices that support an on/off state are available). To select multiple, hold down the command key and click the device in the list. Notice that the devices all have something in parentheses |
| Next, you specify how the plugin will manage the ON state of the device group. The two choices are: | Next, you specify how the plugin will manage the ON state of the device group. The two choices are: | ||
| Line 45: | Line 45: | ||
| We've regularly heard that users have multiple sprinkler controllers and would like to treat them as a single controller. This Virtual Device does just that. You can specify up to 4 different physical sprinkler devices: | We've regularly heard that users have multiple sprinkler controllers and would like to treat them as a single controller. This Virtual Device does just that. You can specify up to 4 different physical sprinkler devices: | ||
| - | {{sprinkler_group_config.png? | + | {{sprinkler_group_config.png? |
| Indigo will treat the resulting group as a single sprinkler. You can create standard sprinkler schedules for it and never have to worry that there might be multiple sprinkler controllers running at the same time. | Indigo will treat the resulting group as a single sprinkler. You can create standard sprinkler schedules for it and never have to worry that there might be multiple sprinkler controllers running at the same time. | ||
| Line 57: | Line 57: | ||
| To create a virtual device, you just create a new device, select '' | To create a virtual device, you just create a new device, select '' | ||
| - | {{pseudo_onoff_config.png? | + | {{pseudo_onoff_config.png? |
| === Execution Models === | === Execution Models === | ||
| Line 71: | Line 71: | ||
| In order to make virtual devices simple enough for non-technical users to use them, we started with the Action Groups execution model. This means that you specify an action group to execute for each of the major tasks that a ON/OFF Device can perform: turn on, turn off, toggle, and get status. Here's the config dialog for Action Groups: | In order to make virtual devices simple enough for non-technical users to use them, we started with the Action Groups execution model. This means that you specify an action group to execute for each of the major tasks that a ON/OFF Device can perform: turn on, turn off, toggle, and get status. Here's the config dialog for Action Groups: | ||
| - | {{pseudo_onoff_config.png? | + | {{pseudo_onoff_config.png? |
| The first thing you'll select are the action groups to execute when the device is turned on and off. So if you click the '' | The first thing you'll select are the action groups to execute when the device is turned on and off. So if you click the '' | ||
| Line 79: | Line 79: | ||
| == Automatic State Maintenance == | == Automatic State Maintenance == | ||
| - | Finally, your virtual device can maintain a state if you like. But, Action Groups can't directly manipulate state you say, right? Well, that's true. However, Action Groups can modify a variable. So, we've allowed you to select a variable and we'll monitor that variable for any change. If the value of the variable becomes " | + | Finally, your virtual device can maintain a state if you like. But, Action Groups can't directly manipulate state you say, right? Well, that's true. However, Action Groups can modify a variable. So, we've allowed you to select a variable and we'll monitor that variable for any change. If the value of the variable becomes " |
| If you set the value of the variable to anything else, we'll set the state of the device to whatever you entered for the variable value AND we'll mark it as having an error. This will cause the device to turn red in the device list to help show you that there' | If you set the value of the variable to anything else, we'll set the state of the device to whatever you entered for the variable value AND we'll mark it as having an error. This will cause the device to turn red in the device list to help show you that there' | ||
| Line 102: | Line 102: | ||
| ===== Virtual Sensors ===== | ===== Virtual Sensors ===== | ||
| - | New to Indigo 2024.1 are Virtual Sensors. These plugin devices are linked to external Python scripts that send instructions to the Virtual Device so it can be used to track a desired status. The device also sends information back to the external script for further processing if needed. | + | New to Indigo 2024.1 are Virtual Sensors. These plugin devices are linked to external Python scripts that send instructions to the Virtual Device so it can be used to track a desired status. The device also sends information back to the external script for further processing if needed. |
| Say you want to use an external script to send a value to the Virtual Device based on some logic in your script and then fire an Indigo Trigger based on the result. You would create a Virtual Sensor, link it to your external script, and set up an update Action to tell the Virtual Sensor to request a status update from your script. | Say you want to use an external script to send a value to the Virtual Device based on some logic in your script and then fire an Indigo Trigger based on the result. You would create a Virtual Sensor, link it to your external script, and set up an update Action to tell the Virtual Sensor to request a status update from your script. | ||
| - | {{: | + | {{: |
| == Supported States == | == Supported States == | ||
| - | Virtual Devices support two states and **must** support at least one of the following: | + | Virtual Devices support two states and **must** support at least one of the following: |
| * On State - your device will have an on/off state. | * On State - your device will have an on/off state. | ||
| * Sensor Value - your device will have a sensor value. | * Sensor Value - your device will have a sensor value. | ||
| Line 123: | Line 123: | ||
| < | < | ||
| - | # If you want to pass something to the Indigo | + | # If you want to pass something to the Indigo |
| # logging module and access the parent plugin' | # logging module and access the parent plugin' | ||
| import logging | import logging | ||
| logger = logging.getLogger(" | logger = logging.getLogger(" | ||
| - | def virtual_sensor_status(device, | + | def virtual_sensor_status(device: indigo.Device, action_props: dict) -> dict: |
| - | """ | + | """ |
| - | This is the only method that the virtual sensor will call, unless you make calls to | + | This is the only method that the virtual sensor will call, unless you make calls to |
| other parts of your script from here. | other parts of your script from here. | ||
| - | | + | |
| :device: a copy of the virtual sensor device object [indigo.Device] | :device: a copy of the virtual sensor device object [indigo.Device] | ||
| - | : | + | : |
| + | :returns: updated sensor values [dict] | ||
| """ | """ | ||
| - | + | | |
| - | | + | |
| payload[' | payload[' | ||
| payload[' | payload[' | ||
| Line 143: | Line 143: | ||
| payload[' | payload[' | ||
| payload[' | payload[' | ||
| - | } | ||
| logger.info(" | logger.info(" | ||
| return payload | return payload | ||
| </ | </ | ||
| - | ''// | + | ''// |
| - | ''// | + | ''// |
| The Virtual Sensor will adjust its states based on the values returned from the //'' | The Virtual Sensor will adjust its states based on the values returned from the //'' | ||
| Line 155: | Line 154: | ||
| == Triggers and Actions == | == Triggers and Actions == | ||
| - | Virtual Devices will respond to an Indigo Action call. When the Update Virtual Sensor Action is called, the Virtual Device will reach out to your script and update its states accordingly. | + | Virtual Devices will respond to an Indigo Action call. When the Update Virtual Sensor Action is called, the Virtual Device will reach out to your script and update its states accordingly. |
| + | |||
| + | The ''// | ||
| + | |||
| + | < | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | The ''// | ||
| + | < | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | </ | ||