Using a variable to display an image file using heuristics

Posted on
Wed Sep 11, 2013 12:23 am
jeremyjjr offline
Posts: 104
Joined: Sep 10, 2013
Location: St Albans, UK

Using a variable to display an image file using heuristics

Hi,

I have created a simple python script that updates an Indigo variable (var_weather_state) and loads it with a string value ('cloudy','sunny', etc). The script is working well and the variable is updated on the hour using a scheduled action.

I have created a control page and added a Variable Value, assigned it to the 'var_weather_state' variable and created a set of basic weather images ('weather.png', 'weather+cloudy.png','weather+sunny.png',etc) placing them in the correct directory. The base image shows correctly in the control page editor.

When running the control page from a browser the image is not loaded. Reviewing the action log, an error is generated saying that the Indigo web server cannot find the file 'weather+true.png'. This suggests that there is an error in the heuristics or variable type?

Has any one seen this behaviour and have advice on how to resolve correctly?

Thanks,

Jeremy.

------

Footnote: Being a developer, I have investigated the underlying web server python scripts. The issue appears to be that the app is calling call 'GetImagePathSimple()' in the indigoutil.py script. The function inspects the variable, determines that it is not a false value (!='no', 'off', '0', etc) and then assigns '+true' as you would expect a boolean to behave.

After taking a copy of the original script, I updated 'GetImagePathSimple()' to have the same functionality as 'GetImagePathWithResolver()' - and the filename was correctly resolved and the image displayed in the browser as expected.

However, whilst I could happily live with the updated function, this script change does not work with the 'Control Pages' function from the iPhone app, and therefore the true cause of the problem really needs some more consideration - that being why the variable type is not identified correctly and thereby the incorrect function is used to resolve the heuristics.

Posted on
Wed Sep 11, 2013 12:39 am
ckeyes888 offline
Posts: 2425
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Using a variable to display an image file using heuristi

I believe the base image needs to be weather+.png.

Carl

Posted on
Wed Sep 11, 2013 5:48 am
jeremyjjr offline
Posts: 104
Joined: Sep 10, 2013
Location: St Albans, UK

Re: Using a variable to display an image file using heuristi

Such a newbie ... and always searching for the complicated reason!

Thanks Carl - this was exactly the cause of the problem.

Jeremy.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 5 guests