FlyingDiver / Indigo-miniUniFi

Minimalistic UniFi plugin for Indigo
MIT License
0 stars 0 forks source link

Better displaying of times / states #6

Closed jstewart99 closed 3 years ago

jstewart99 commented 3 years ago

I notice all of the time-related custom states are formatted poorly (and/or are unusable, eg "last seen = 1603487575"??). If there's a way to parse and display these in a more usable date/time format it would be nice for Control Pages and things like that. Any of the "last seen" states, "uptime" etc.

FlyingDiver commented 3 years ago

That's the way the controller returns them. They're usable for doing data calculations. And right now, I'm just dumping the data returned from the controller directly into states using the same keys. I don't have any code that looks at specific states, except for the is_wired and essid fields to determine if the device is online.

Have you looked at using the Device Extensions plugin (http://www.indigodomo.com/pluginstore/126/) to format the data strings for your control pages?

jstewart99 commented 3 years ago

I will check out that plugin, thanks for the tip. I can't really decipher the times, though. For example "c_last_seen" is showing something like 1603488906. Do you have any guidance on how to interpret that? I don't know how to tell the Device Extensions plugin how to convert that into a Timestamp format. I know the other Unifi plugin shows that data in a straightforward date/time format, and since it doesn't seem intuitively interpretable, it might be nice to parse that for the user in a future version.

FlyingDiver commented 3 years ago

It's almost certainly a POSIX timestamp:

https://en.wikipedia.org/wiki/Unix_time

jstewart99 commented 3 years ago

Yeah that looks correct. So it's displaying an integer count of seconds I guess. Any idea how to convert that using the Device Extensions plugin?

FlyingDiver commented 3 years ago

I do not. I've never used it, I'm just going by the description on the plugin store page.

https://github.com/Colorado4Wheeler/Device-Extensions/wiki/Conversion-Devices#convert-between-date-formats