Janne_1
(Janne )
April 17, 2019, 8:09am
1
Hi, is there a way to get the current time to an item?
I have the following item:
DateTime Temp_update <time> { channel = "mqtt:topic:fceb####:Temp_update"}
Now I need a rule that puts the current time in this item.
Something like this:
when something changed
then
Item Temp_update = currentTime
Is that possible?
Thanks for your help!
opus
(Jürgen Baginski)
April 17, 2019, 8:13am
2
have you tried postUpdate?
Temp_update.postUpdate(currentTime)
1 Like
Janne_1
(Janne )
April 17, 2019, 8:18am
3
Hey, I tried that, but when I go in the habpanel the dummy were I linked the “Temp_update” says “UNDEF” and it says the following in the logviewer
Rule 'Temperature': The name 'currentTime' cannot be resolved to an item or type; line 38, column 28, length 11
try this
Temp_update.postUpdate(new DateTimeType())
EDIT:
But what’s about your linked channel ? You should leave it away, or ?
1 Like
Janne_1
(Janne )
April 17, 2019, 8:31am
5
Hi thanks for your fast reply!
What do you mean with leave it away?
fibu-freak:
try this
This one worked but is shows very much information: 2019-04-17T10:26:01.038+0200
Is it possible just to show the time? (10:26:01)
As you will overwrite the channel-info, you don’t need it from the binding. I think this can end in an invite loop. (Not really , as you’re using "postUpdate). But if you want to have the channel-information too, better use a Dummy-Item.
To show specific information you have to use Formatting in the Label. Either in your .items.file or in your SiteMap/HABPanel.
Here an example out of my Item-Set:
DateTime localLastMeasurement "Datum letzte Messung [%1$ta, %1$ty-%1$tm-%1$td %1$tH:%1$tM]" <time> (gOWM,gOWMOutlook) { channel="openweathermap:weather-and-forecast:api:local:current#time-stamp" }
Cheers,
Peter
2 Likes
Janne_1
(Janne )
April 17, 2019, 8:53am
7
Hey, the following question might sound “stupid” but
how can I create a item without adding it to a thing?
For now I added my Temp_update item to the Temp. sensor, but I can’t configure the item as I want to…
You must have in mind that I’m very new to all this.
What is this line doing?
Thanks in advance!
Just create a new item like this:
DateTime lastRuleRefresh "Regel ausgeführt um [%1$tH:%1$tM:%1$tS]" <time> // Value calculated via Rule
As you see the first formatter looks a bit different from this one.
The results can look like:
1 Like
Janne_1
(Janne )
April 17, 2019, 9:44am
10
Hi, you really helped me a lot today and it is finally working!
Thank you!!
Fine to hear. If everything’s ok now, pls. mark your post as solved at the post which helps you.
Cheers,
Peter
EDIT: here and here you can read something about Formatters
1 Like