Tobus
(Tobus)
January 6, 2019, 9:18am
1
Hi,
i have a temperature like -5.25 °C and want to convert it to -5 °C. What can I do?
The item is:
{{itemValue('OpenWeatherMapWeatherAndForecast_ForecastTomorrow_MinimumTemperature')
From OpenWeather Binding I get a date for the weather forecasts like
06.01.2019
I want to convert this date to eg. Sunday.
Can anybody help?
Thanks
Tobias
vzorglub
(Vincent Regaud)
January 6, 2019, 9:22am
2
Please post your items file
Tobus
(Tobus)
January 6, 2019, 9:29am
3
I edited my first post, cause the first problem is solved.
The item of the observation time is:
OpenWeatherMapWeatherAndForecast_Current_ObservationTime
DateTime
eg: 08.01.2019
CDriver
(CDriver)
January 6, 2019, 9:30am
4
I believe its this way round
{{itemValue('OpenWeatherMapWeatherAndForecast_ForecastTomorrow_MinimumTemperature') | '%.0f °C' }}
Untested though
Tobus
(Tobus)
January 6, 2019, 9:31am
5
Hi Cris,
this works for me:
{{itemValue('OpenWeatherMapWeatherAndForecast_ForecastTomorrow_MinimumTemperature').split('.')[0] }} °C
CDriver
(CDriver)
January 6, 2019, 9:31am
6
Please don’t. Others might have your problem. Rather post the solution you had.
Alison it makes follow up answer like mine look silly.
1 Like
Tobus
(Tobus)
January 6, 2019, 12:27pm
7
You are right, sorry.
For my second question i have currently no solution. Do you have any idea?
Thanks
Tobias
vzorglub
(Vincent Regaud)
January 6, 2019, 12:35pm
8
Use the formating:
DateTime OWB_Forecast_Date "Date of forecast [%1$tEEEE]"
Tobus
(Tobus)
January 6, 2019, 12:49pm
9
In this case I have to create a new item, right? Do you know a way where I can convert the existing OWB item and convert it in my HABPanel widget?
vzorglub
(Vincent Regaud)
January 6, 2019, 12:52pm
10
No
Just put it in an items file
Remove the link in the paperUI
Create an items file
Put the item as show above:
DateTime OWB_Forecast_Date "Date of forecast [%1$tEEEE]" { channel="OWBchannel" }
Replace the channel with the correct channel in the paperUI
Tobus
(Tobus)
January 6, 2019, 12:57pm
11
Ahh ok sorry, clear.
The value if the new item is:
2019-01-07T12:00:00.000+0100
What i need is: Monday.
Do you know what I have to do?
vzorglub
(Vincent Regaud)
January 6, 2019, 2:30pm
12
You need another item (a String item)
And a rule
Tobus
(Tobus)
January 7, 2019, 5:46pm
13
Sorry for asking again …
I added a rule to convert the iso Date to a string.
rule "test"
when
Item Test_Switch changed
then
var dateToString = OWB_Forecast_Date.state.toString.split("T").get(0)
OWB_Forecast_DateString.postUpdate(dateToString )
end
The date “dateToString” is now in format:
2019-01-08
The items are:
DateTime OWB_Forecast_Date "Date of forecast [%1$tEEEE]" { channel="openweathermap:weather-and-forecast:1254777:local:forecastTomorrow#time-stamp" }
String OWB_Forecast_DateString "Date of forecast string"
What is the next step?
memphiz
(Oliver)
January 7, 2019, 6:10pm
14
Hello,
OWB_Forecast_Date.getDayOfWeek
should return the day of the week(1-7).
Just translate it in a rule:
if (OWB_Forecast_Date.getDayOfWeek==1) {
OWB_Forecast_Weekday = "monday"
}
else if (OWB_Forecast_Date.getDayOfWeek==2) {
OWB_Forecast_Weekday = "tuesday"
}
else if (OWB_Forecast_Date.getDayOfWeek==3) {
OWB_Forecast_Weekday = "wednesday"
}....
Best,
Olli
Tobus
(Tobus)
January 7, 2019, 6:17pm
15
memphiz:
getDayOfWeek
Ahh I think I have a solution.
I created a template widget with:
{{itemValue('OWB_Forecast_Date') | date:'EEEE'}}
Now it works fine
Thanks all
I guess this is HABPanel stuff? If yes, please change the category to Apps & Services -> HABPanel
vzorglub
(Vincent Regaud)
January 8, 2019, 10:10am
17
The rules way is:
rule "test"
when
Item Test_Switch changed
then
OWB_Forecast_DateString.postUpdate(OWB_Forecast_Date.state.toString("EEEE"))
end
1 Like
Tobus
(Tobus)
January 8, 2019, 7:00pm
18
Ah ok, make sense. Thanks a lot!!