Indigo server path INSIDE a file path or URL?

Posted on
Mon Sep 05, 2022 12:12 pm
Different Computers offline
User avatar
Posts: 2552
Joined: Jan 02, 2016
Location: East Coast

Indigo server path INSIDE a file path or URL?

Hi all,

I have a ton of scripts with lines like this
Code: Select all
original = Image.open("/Library/Application Support/Perceptive Automation/Indigo 2022.1/Web Assets/public/alert.jpg")

or control page images located at (for example)
Code: Select all
file:///Library/Application Support/Perceptive Automation/Indigo 2022.1/Web Assets/public/frontporch.jpg

and every time there's an indigo update, I have to manually change these file locations. I know there's a function (wrong term?) that gives the correct, current Indigo folder path, but I wonder if it's possible to include it as part of these file paths.

I think in the first case it might just be turning the target of Image.open into a declared variable, but I also don't know the syntax to do something like

Code: Select all
targetImage="/Library/Application Support/Perceptive Automation/Indigo 2022.1/Web Assets/public/alert.jpg"
original = Image.open(targetImage)

or if I'm even on the right track there. I'm not even clear what terms I would search for to look up how to do this in a python how-to. And that approach for sure won't work when I try to specify a control page file location, as far as I know.

Thanks much for any help!

SmartThings refugee, so happy to be on Indigo. Monterey on a base M1 Mini w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKitLink, Grafana, Plex, uniFAP, Fantastic Weather, Nanoleaf, LED Simple Effects, Bond Home, Camect.

Posted on
Mon Sep 05, 2022 1:06 pm
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Indigo server path INSIDE a file path or URL?

Yes, the server function you want is indigo.server.getInstallFolderPath, and use it in your script like this (assumes Indigo 2022.1 or later):

Code: Select all
 original = Image.open(f"{indigo.server.getInstallFolderPath()}/Web Assets/public/alert.jpg")


I'm less clear on your control page images: where are you using those file URLs?

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Sep 05, 2022 1:51 pm
DaveL17 offline
User avatar
Posts: 6756
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Indigo server path INSIDE a file path or URL?

If you're using this URL

Code: Select all
file:///Library/Application Support/Perceptive Automation/Indigo 2022.1/Web Assets/public/frontporch.jpg
as a Refreshing Image URL (for example), you can not use an Indigo method as a part of the URL.

If you're not taking advantage of using dropdowns to locate images (like with variables or devices) it may be best to put those images in a location outside the Indigo folder tree. That way the URL won't break when you update Indigo versions.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Mon Sep 05, 2022 3:37 pm
Different Computers offline
User avatar
Posts: 2552
Joined: Jan 02, 2016
Location: East Coast

Re: Indigo server path INSIDE a file path or URL?

DaveL17 wrote:
If you're using this URL

Code: Select all
file:///Library/Application Support/Perceptive Automation/Indigo 2022.1/Web Assets/public/frontporch.jpg
as a Refreshing Image URL (for example), you can not use an Indigo method as a part of the URL.

If you're not taking advantage of using dropdowns to locate images (like with variables or devices) it may be best to put those images in a location outside the Indigo folder tree. That way the URL won't break when you update Indigo versions.


Dropdowns?

SmartThings refugee, so happy to be on Indigo. Monterey on a base M1 Mini w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKitLink, Grafana, Plex, uniFAP, Fantastic Weather, Nanoleaf, LED Simple Effects, Bond Home, Camect.

Posted on
Mon Sep 05, 2022 3:41 pm
Different Computers offline
User avatar
Posts: 2552
Joined: Jan 02, 2016
Location: East Coast

Re: Indigo server path INSIDE a file path or URL?

jay (support) wrote:
I'm less clear on your control page images: where are you using those file URLs?


Those file urls are images that are on a web page, and they're refreshing URLs. Since I feel like I'm just repeating myself and probably don't understand what you're asking, here's a screen shot of a control page.
Attachments
Screen Shot 2022-09-05 at 5.39.46 PM.png
Screen Shot 2022-09-05 at 5.39.46 PM.png (31.55 KiB) Viewed 1285 times

SmartThings refugee, so happy to be on Indigo. Monterey on a base M1 Mini w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKitLink, Grafana, Plex, uniFAP, Fantastic Weather, Nanoleaf, LED Simple Effects, Bond Home, Camect.

Posted on
Mon Sep 05, 2022 5:14 pm
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Indigo server path INSIDE a file path or URL?

Help me understand the use-case here: do you regenerate those images based on some change? What exactly changes that would cause you to edit them?

I'm wondering why using device states or image value heuristics with static custom images wouldn't work.

Also, given the file path, it looks like you are making that image available through the Indigo Web Server. So, instead of referring to it as a file URL, you can access it through IWS instead:

http://localhost:8176/public/alert.jpg

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Sep 05, 2022 5:33 pm
DaveL17 offline
User avatar
Posts: 6756
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Indigo server path INSIDE a file path or URL?

By dropdowns, I mean where you select Display Device State and then select a Device and a State (or a variable value or a static image). Most importantly As Image.

Screen Shot 2022-09-05 at 6.29.17 PM.png
Screen Shot 2022-09-05 at 6.29.17 PM.png (30.29 KiB) Viewed 1266 times

The options listed in those dropdowns are stored in:

Code: Select all
.../Web Assets/images/controls/devices/
.../Web Assets/images/controls/static/
.../Web Assets/images/controls/variables/
Images in these folders show up in Indigo's UI. Otherwise, I feel it's better to store images outside the folder tree so those "Refreshing Image URL" links stay the same between Indigo versions.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Tue Sep 06, 2022 7:45 am
Different Computers offline
User avatar
Posts: 2552
Joined: Jan 02, 2016
Location: East Coast

Re: Indigo server path INSIDE a file path or URL?

jay (support) wrote:
Help me understand the use-case here: do you regenerate those images based on some change? What exactly changes that would cause you to edit them?


Yes, based on motion alerts from cameras. Camect notices motion, takes a pic, saves those pics into web assests/public, tells domopad to display the page with that pic. I need to edit them because when a new Indigo version comes out, the path changes.

To clarify further: the "alert.jpg" is a camera snapshot that is created based on a camera motion trigger.

jay (support) wrote:
I'm wondering why using device states or image value heuristics with static custom images wouldn't work.


I don't have any idea what you have in mind here. The device state of the camera (alert) is the trigger. The image saves when the alert happens. So it's not a static image, and in any case the path to static images changes with each version of Indigo, doesn't it? Please explain how you imagine this would work because if I'm doing it the hard way, I want to know :) Maybe you're thinking I just want a big "sticker" that says "ALERT"? What I want is the snapshot from Camect OF the alert.

jay (support) wrote:
Also, given the file path, it looks like you are making that image available through the Indigo Web Server. So, instead of referring to it as a file URL, you can access it through IWS instead:

http://localhost:8176/public/alert.jpg
Now this I may be able to use immediately. No wait--see, the problem is that URL would then try to direct to the localhost of each client, wouldn't it? I think I'd need http://[IPADDRESS:8176/public/alert.jpg but that would break if I was away from home.
Last edited by Different Computers on Tue Sep 06, 2022 7:51 am, edited 1 time in total.

SmartThings refugee, so happy to be on Indigo. Monterey on a base M1 Mini w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKitLink, Grafana, Plex, uniFAP, Fantastic Weather, Nanoleaf, LED Simple Effects, Bond Home, Camect.

Posted on
Tue Sep 06, 2022 7:49 am
Different Computers offline
User avatar
Posts: 2552
Joined: Jan 02, 2016
Location: East Coast

Re: Indigo server path INSIDE a file path or URL?

DaveL17 wrote:
By dropdowns, I mean where you select Display Device State and then select a Device and a State (or a variable value or a static image). Most importantly As Image.

Screen Shot 2022-09-05 at 6.29.17 PM.png

The options listed in those dropdowns are stored in:

Code: Select all
.../Web Assets/images/controls/devices/
.../Web Assets/images/controls/static/
.../Web Assets/images/controls/variables/
Images in these folders show up in Indigo's UI.
Ah those. yeah, those are entirely unlike what I'm trying to display.

DaveL17 wrote:
Otherwise, I feel it's better to store images outside the folder tree so those "Refreshing Image URL" links stay the same between Indigo versions.
this is probably where I'm going wrong. But /web assets/public is also where Camect puts the images by default--which I don't think is a design flaw for camect. But maybe I should investigate changing that.

SmartThings refugee, so happy to be on Indigo. Monterey on a base M1 Mini w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKitLink, Grafana, Plex, uniFAP, Fantastic Weather, Nanoleaf, LED Simple Effects, Bond Home, Camect.

Posted on
Tue Sep 06, 2022 9:54 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Indigo server path INSIDE a file path or URL?

Different Computers wrote:
Now this I may be able to use immediately. No wait--see, the problem is that URL would then try to direct to the localhost of each client, wouldn't it? I think I'd need http://[IPADDRESS:8176/public/alert.jpg but that would break if I was away from home.


Then use your reflector instead - that'll work from anywhere.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Sep 06, 2022 11:11 am
Different Computers offline
User avatar
Posts: 2552
Joined: Jan 02, 2016
Location: East Coast

Re: Indigo server path INSIDE a file path or URL?

I guess I'm still in the habit of avoiding anything that might route outside my network, which I think reflector connections do. Have I got that right?

this dates back to my sad old days of having ~8Mb down ~1Mb upload DSL but... now thanks to the electrical co-op, I have symmetrical gigabit fiber :D

SmartThings refugee, so happy to be on Indigo. Monterey on a base M1 Mini w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKitLink, Grafana, Plex, uniFAP, Fantastic Weather, Nanoleaf, LED Simple Effects, Bond Home, Camect.

Posted on
Tue Sep 06, 2022 1:04 pm
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Indigo server path INSIDE a file path or URL?

So, the only other option you have is to put the image outside the Indigo install folder hierarchy so that the file URL never has to change.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Sep 06, 2022 5:29 pm
Different Computers offline
User avatar
Posts: 2552
Joined: Jan 02, 2016
Location: East Coast

Re: Indigo server path INSIDE a file path or URL?

I think the combination of my big internet upgrade (now a year old) and Camect’s default behavior point me to your other idea. But thanks!

SmartThings refugee, so happy to be on Indigo. Monterey on a base M1 Mini w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKitLink, Grafana, Plex, uniFAP, Fantastic Weather, Nanoleaf, LED Simple Effects, Bond Home, Camect.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 10 guests