Display Time ago

Hi there,

I have a working Display (Angular 5 App) with informations and some smart home components made by myself that i want to change to habpanel.

There is one pretty basic feature that i am missing: Display a string with a pretty format values when the value was updated. Like: 5 minutes ago or 2 days ago

On my board i use moment.js / angular-moment to display this.

How can i do this with openhab?

My research at this point:

  1. In the roles:
  • Its possible to do this with java (prettytime) but its not possible to insert custom java into rules
  1. In Javascript:
  • There is no way to load moment js easily and change a epoch timestamp to a pretty outputformat
  • You can lazyload files, but this seems over the top for such a simple feature

Can anybody point me to the right direction?

You could use a javascript transformation

I think that’s the only way. But I could be wrong. Just what I picked up reading the forum. I don’t use the UIs that much

Thanks vzorglub for your quick reply

PrettyPrint is Java, so i need a Exec Transformation… but momentjs would work with a js transformation

i will give it a try.

I don’t know it you can load js libraries from js transformations scripts
Please let me know if it is possible, I’ll be interested.
Thanks

If you have NodeRed you could use this:

The author just made changes to do this that should be published soon. You could also look at his code if you don’t want to utilized NodeRed.

Thanks for the info. I don’t use NodeRed myself, but other may find it helpful.