- Disable all your chart devices (not required, but this will keep log messages to a minimum.)
- Make the location of where your images are saved in the main plugin preferences to reflect your version of Indigo:
- Code: Select all
/Library/Application Support/Perceptive Automation/Indigo 7.5/IndigoWebServer/images/controls/
- Change the figure save names of your existing charts to account for the new path. For example, if your save path was (like mine) saving images to the .../static/ images folder, change the save name of your exiting chart(s) from 'save_name.png' to '/static/save_name.png'. Of course, use your image names in place of 'save_name'.
- Repeat this process for all your chart devices.
- Re-enable your chart devices.
Now on to the "replaceable" image bit. For the purposes of this example, we'll start fresh, but you could refactor existing images to do the same thing. Say you have two items with similar charts that you want to display on one control page and cycle through them rather than displaying them individually--for example, a weather chart at home and at the lake house.
- Create your first chart as desired, and make the figure save name to be something like my_chart+.png. Make sure to include the '+'. That's important.
- Create a duplicate of your first chart, change the save name to follow the same scheme--in this case, my_chart+1.png and change the source to your second source.
- Repeat this process for the remaining charts. Since we only have two, we're done.
- Create an Indigo variable called image_switcher (or whatever), and set its value to zero.
- On your control page, add a new control page item linked to the image_switcher variable, select the "as image" option and select my_chart+.png. You are actually displaying the variable on the control page, but you're displaying its value as an image.
- Still with the same image selected, select 'Server Actions', 'Script and File Actions', 'Execute Script'.
- In the embedded script window, add the following Python Code (you'll need to adjust it to reflect the number of charts you're cycling through):
- Code: Select all
val = int(indigo.variables['image_switcher'].value)
if val == 1:
val = 0
else:
val +=1
indigo.variable.updateValue('image_switcher', str(val))
You may not have to take all of these steps depending on how your installation was configured. Also, for the curious, there are variations that you can use--like using button images to cycle the charts (to provide a visual cue that the image can be cycled), or use a timer to change the 'image_switcher' variable every few seconds and skip the embedded code all together. There may be a slight delay when changing the image_switcher value externally, but the tap method works instantly.
Note: you may get a warning message when you restart the plugin that your image save path may not match the current Indigo version. If your images are appearing where you want them to, you can ignore this warning.