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/08/11 20:51] – 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. | ||
| ===== Virtual On/Off Devices ===== | ===== Virtual On/Off Devices ===== | ||
| + | |||
| One of the things that we often see are people who want to create a device that can be turned ON and OFF, but don't have the knowledge or expertise to build a full-on plugin. And sometimes a full plugin would be overkill, particularly if the device is so custom that it really wouldn' | One of the things that we often see are people who want to create a device that can be turned ON and OFF, but don't have the knowledge or expertise to build a full-on plugin. And sometimes a full plugin would be overkill, particularly if the device is so custom that it really wouldn' | ||
| Line 56: | 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 70: | 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 77: | Line 78: | ||
| == 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 99: | Line 101: | ||
| ===== Virtual Sensors ===== | ===== Virtual Sensors ===== | ||
| - | New to Indigo 2024.1 are Virtual Sensors. These plugin devices are controlled by external Python scripts that send instructions to the Virtual Device so it can track a desired status. For example, you could use an external script to send a value to the Virtual Device and then fire a trigger on the result. | ||
| - | {{: | + | 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. | ||
| + | |||
| + | {{: | ||
| == Supported States == | == Supported States == | ||
| - | Virtual Devices support | + | |
| + | Virtual Devices support | ||
| * 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. | ||
| - | * Status Request - your device will respond to status requests. | ||
| == Script Locations == | == Script Locations == | ||
| - | You can add scripts directly to the //''/ | + | |
| + | You can add scripts directly to the //''/ | ||
| == Controlling Scripts == | == Controlling Scripts == | ||
| - | You control the state of Virtual Devices with Python scripts (the Virtual Device | + | |
| + | You control the state of Virtual | ||
| < | < | ||
| - | def virtual_sensor_status(): | + | # If you want to pass something to the Indigo Event Log, you will need to import the |
| + | # logging module and access the parent plugin' | ||
| + | import logging | ||
| + | logger = logging.getLogger(" | ||
| - | | + | def virtual_sensor_status(device: |
| + | """ | ||
| + | This is the only method that the virtual sensor will call, unless you make calls to | ||
| + | other parts of your script from here. | ||
| + | |||
| + | :device: a copy of the virtual sensor device object [indigo.Device] | ||
| + | : | ||
| + | :returns: updated sensor values [dict] | ||
| + | """ | ||
| + | | ||
| payload[' | payload[' | ||
| - | payload[' | + | payload[' |
| - | payload[' | + | payload[' |
| - | payload[' | + | payload[' |
| - | payload[' | + | payload[' |
| - | payload[' | + | |
| - | | + | |
| - | | + | |
| return payload | return payload | ||
| </ | </ | ||
| + | ''// | ||
| + | ''// | ||
| - | The Virtual | + | The Virtual |
| == 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 ''// | ||
| + | < | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | </ | ||