Transforming String for Hab Panel Image Use

I’m trying to make a Hab-Panel that will display the image of the moon in it’s current Phase. This is really just an exercise to use the Image and URL Widgets correctly.

I’ve got the astro binding working fine, and can collect a string which is the MoonPhase. What I want to do is transform this into a URL of a picture of the Moon and display it.

I have set up the MAP Transformation Service and have gotten that to work fine for display purposes, in fact the item:

String MoonImage “MoonImage [MAP(]” { channel=“astro:moon:home:phase#name” }

outputs perfectly, given the file containing:


The problem is that if I feed this into the URL Widget I get the Error

“404 /habpanel/WANING_GIBBOUS”, despite the fact that I did send it the item with the specified transformation. So what I know is that the Widget is being fed the item before it’s transformed, rather that the after transformed URL (the documentation did say somthing about “on the fly”)

So I figure it’s time to use a rule instead of an item transformation? This will store the URL in the string rather than incoming string from the binding right? Well after quite some time, the best I can figure is that such a rule would look something like this:

var trans = transform(“MAP”, “”, MoonPhase)

Given that “MoonPhase” and “MoonImage” are both in the items file, with “MoonPhase” hooked to the astro binding. I’ve also tried

var trans = transform(“MAP”, “”, MoonPhase)

Both throw two errors ("Cannot referance MoonPhase before it is defined / EOF)… I have no idea what I’m doing trying to construct this rule

But I don’t have a switch with a state property I’m trying to transform, I have a string item I’m trying to transform.

So how do I use the string value as the input? “MoonPhase” is the name of the string item from the astro binding. If I do:

var trans = transform(“MAP”, “”, MoonPhase.state.tostring)

I get the errors:

“Multiple Errors on this line: -Cannot referance Moonphase before it is defined, -the method or field tostring is undefined for this type of state”

Hello Aaron,

I also want to design a Habpanel where the moon phase is displayed as a graphic with the different states. Your solution approaches did not seem to work, did you find a solution in the end?

Nope. Unfortunately I gave up on this a long time ago…

okay, I have not found a solution.

rule "Moon Face Image"
	Item MoonPercent changed


1 Like

hi av_homeauto,
I just saw that you posted me a solution. Thank you very much first and I will try it soon.

1 Like