Hey all,
with OH3 approaching I started migration from good old weather1 binding to DarkSky binding, since I already used the ForecastIO backend in weather1.
In the old binding I used the minMax item which looked like this:
"Min/Max Temp Heute [%s °C]"
<temperature>
(gWeather)
{weather="locationId=home-FIO, type=temperature, property=minMax, forecast=0, scale=0"}
Since the MinMax is not available in DarkSky I want to use a virtual item and update via rule. Items:
Number:Temperature aussen_wetter_forecast_0_mintemp
"Minimum Temperatur Heute [%.0f %unit%]"
<temperature>
(gWeather)
{ channel="darksky:weather-and-forecast:api:local:forecastToday#min-temperature" }
Number:Temperature aussen_wetter_forecast_0_maxtemp
"Maximum Temperatur Heute [%.0f %unit%]"
<temperature>
(gWeather)
{ channel="darksky:weather-and-forecast:api:local:forecastToday#max-temperature" }
// Value needs to be calculated by rule
String aussen_wetter_forecast_0_minmaxtemp
"Min/Max Temperatur Heute [%s °C]"
<temperature>
(gWeather)
I’m not able to round the temperature items to NOT have comma, as well as only having a single “°C”. Here’s the current rule with current output.
rule "calculate weather minmax string"
when
Item aussen_wetter_forecast_0_mintemp received update
then
val String minmax_current = (aussen_wetter_forecast_0_mintemp.state as Number).toString + " / " + (aussen_wetter_forecast_0_maxtemp.state as Number).toString
if (log) logInfo(filename, "MinTemp: " + aussen_wetter_forecast_0_mintemp.state + " MaxTemp: " + aussen_wetter_forecast_0_maxtemp.state)
if (log) logInfo(filename, "MinMaxTemp calculated: " + minmax_current)
aussen_wetter_forecast_0_minmaxtemp.postUpdate(minmax_current)
end
log:
2020-10-15 13:42:33.997 [INFO ] [.script.aussen_wetter_forecast.rules] - MinTemp: 6.97 °C MaxTemp: 11.34 °C
2020-10-15 13:42:33.998 [INFO ] [.script.aussen_wetter_forecast.rules] - MinMaxTemp calculated: 6.97 °C / 11.34 °C
Any recommendation to make it look like “7/11 °C” would be appreciated.
Thanks much