Get local UV radiation -- prevent sunburn and skin cancer

,

Thomas-

I am using openhab 2.2 on a Raspberry pi 3 - installed with apt-get. When I type the curl command noted above the system returns the expected data, so I think the api key is correct.

Many thanks,

-Mark

A little suggestion and caveat regarding the DateTime items (if look closely in @rtvb’s example, you can see, that he solved this also). The API gives back the time in UTC, so in order to match the Datetime items to your timezone, you could change the code like this:

String	    openUV_UV_Time		"UV-Wert Messung (UTC) [%s]"		        { http="<[openUV:60000:JSONPATH($.result.uv_time)]" }
DateTime	openUV_UV_Time_MEZ		"UV-Wert Messung [%1$tH:%1$tM]" (gUV)
String	    openUV_UV_MaxTime	"Max. UV-Wert Zeit (UTC) [%s]"	            { http="<[openUV:60000:JSONPATH($.result.uv_max_time)]" }
DateTime	openUV_UV_MaxTime_MEZ	"Max. UV-Wert Zeit [%1$tH:%1$tM]" (gUV) 

and add a rule:

rule "UV Index DateTimeItem"
when
    Item openUV_UV_Time changed or
    Item openUV_UV_MaxTime changed
then
    val DateTime uv_time = new DateTime(openUV_UV_Time.state.toString)
    val DateTime uv_time_max = new DateTime(openUV_UV_MaxTime.state.toString)
    openUV_UV_Time_MEZ.postUpdate(uv_time.toString)
    openUV_UV_MaxTime_MEZ.postUpdate(uv_time_max.toString)
end
3 Likes

thank you @Syn

my output is “2018-04-22T11:23:17.000+0200” … how can I transform, to have a more readable output? like “22-04-2018 at 11:23:17” …?

thanks
Andrea

I use only open_UV_Time_MEZ in my sitemap. As you can see, there is already an transformation in the item definition ([%1$tH:%1$tM]), which results in e.g. 12:13.
Have a look in the docs, there you can find all possible formatters for Date/Time Conversions.

1 Like

I believe I have followed the example , yet ive hit the 500 a day requests, yet I had my cron set to 30minutes

I am using your script , where item is days defined ?