I am trying to plot the location (of the ISS) on a map for a mapview.
I have the latitude and longitude that I get as a string and I dfined the actual location as a Location item, like so:
String iss_lat "ISS latitude [%s]" <marker> {http="<[iss:6000:JSONPATH($.iss_position.latitude)]"}
String iss_long "ISS longtitude [%s]" <marker> {http="<[iss:6000:JSONPATH($.iss_position.longitude)]"}
Location iss_loc
those two string items show valid outcome in my UI
Subsequently I am trying to convert the latitude and longitude to a location with the following rule:
rule iss
when
Item iss_lat changed
then
var PointType iss = new PointType("iss_lat,iss_long")
iss_loc.postUpdate(iss)
end
When I use defined numbers rather than variables, like so:
var PointType iss = new PointType("52, 4.5")
then the mapview works perfectly.
So somewhere I guess there is a problem with my type conversion but I cant figure it out.
I tried PointType("iss_lat.state, iss_long.state") which has no effect, also result ânullâ
Make sure your incoming numeric lat, long values donât have blanks or other whitespace which could trip up number parsing.
Also, I mentored a group of kids a few months ago and we wrote a program that ran on the ISS, and in the course of things I found this way of calculating the position of the ISS over the earth, and you could feed this directly into openHAB without needing to scrape it off a website:
Thanks @rossko57, but I already tried that, but you might have overlooked that in my reply.
I think the problem is that the PointType function expects two integers, while I feed it strings, but iss_lat.state.intValue gave an error.
@watou Thanks that crossed my mind, but as far as I can see there are no leading or trailing spaces.
I tried iss_long.state.trim but that generated the error: 'trim' is not a member of 'org.eclipse.smarthome.core.library.types.StringType'; I will definitely have a look at your code appreciate it, however my attempt was more for âpracticeâ within OH so I still will try to get this to work
Thanks could be very right in that, then I donât have to linger on string conversion anymoreâŠâŠâŠ but then I really am at the end of my wits why it doesnât work.
Wait⊠you might be on to something
var PointType iss=new PointType(iss_lat.state + " , " + iss_long.state)
seems to work
Edit
For completeness sake let me give the full code: http.cfg:
iss.url=http://api.open-notify.org/iss-now.json
irl.updateInterval=6000