Closed IndigoColly closed 4 years ago
You mean a formatted date/time, rather than the timestamp that's currently available? I'll be honest, I think this is something that ought to be done on the control page end of things (formatting data for display) rather than in the plugin. I had hoped that users would be able to use something like the "Device Extensions" plugin to do this, but it doesn't do timestamps as an input type. I need to see if there's some other alternative, or maybe write my own.
Joe,
Yes I mean formatted date/time. I’m happy to do it on control page end, just throwing out options seeing as you’re in development stage.
Rgds
Colin
Sent from my iPhone
On 27 Oct 2020, at 15:39, Joe Keenan notifications@github.com wrote:
You mean a formatted date/time, rather than the timestamp that's currently available? I'll be honest, I think this is something that ought to be done on the control page end of things (formatting data for display) rather than in the plugin. I had hoped that users would be able to use something like the "Device Extensions" plugin to do this, but it doesn't do timestamps as an input type. I need to see if there's some other alternative, or maybe write my own.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
OK, I really don't want to be adding states unless it's absolutely necessary. I added the "offline_seconds" one since I really wanted to display that information in the device status.
Not to belabor the issue but given that you have two early users now asking for this feature, I hope you'll consider it (rather than having to rely on an extra plug-in or making the user write their own scripts). It's an easy conversion in Python:
from datetime import datetime ts = int(last_seen) last_seen_timestamp = datetime.utcfromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
"Offline_seconds" becomes pretty unwieldy on a Control Page for a device that's been offline for hours or days. And knowing at a glance exactly when a device went offline seems helpful. I know you're trying to avoid feature bloat, but I think it falls well under the "presence detection" umbrella.
@IndigoColly - you alluded to a workaround "on the Control Page end"...can you elaborate? The only workaround I've come up with is using the basic script above to update a variable in a Schedule that runs every minute, but baking that into the plug-in would be a lot more elegant (and I'm sure will be appreciated by Joe's adoring fans when this is released). ;-)
Hi Joseph,
I have a very inelegant way of dealing with this by updating a number of variables (insert timestamp into variable) via a trigger on device state change to store the last 4 times a device state becomes "up" or "down" (using the other Unifi plugin).
Colly
The problem is not the actual conversion, I'm quite aware of how to do that.
The problem is feature creep. I do it for this one state, then someone else asks for a conversion for a different state. And it never stops. The right answer is to make this kind of conversion/formatting easily available to control pages, not to modify every plugin to to do it.
Yeah but you don't have to say yes to every request. :-D JUST MINE! lol 95% of the states don't need conversion, it's just the time-related ones (the other Unifi plugin does this, FWIW). I agree it would be nice if that Device Extensions plugin handled the conversion (maybe it does and I'm just not using it right...to be honest I can't get it to display ANY states in ANY format, so I'm clearly doing something wrong...couldn't even get it to just show the last_seen state as a String). I guess I'll hop over to his project and harass HIM to add the capability, lol. Thanks for indulging, Joe! I get where you're coming from... :-)
I haven't seen C4W on the forums in a while. I think he's taking a break from Indigo development. I forked the code for that plugin in case I get motivated to add this conversion, but he's got so much other stuff in there that it sort of breaks my KISS principles.
Hi Joseph, I have a very inelegant way of dealing with this by updating a number of variables (insert timestamp into variable) via a trigger on device state change to store the last 4 times a device state becomes "up" or "down" (using the other Unifi plugin). Colly
How DARE you use another UniFi plugin? Haha. I thought 98% of the point of this plugin was to avoid that ugly mess. The other plugin already shows this info in Timestamp format. However, your comment gave me a fairly good idea for a workaround: Trigger: if device goes offline, run a python script to update a variable with the last_seen info converted into timestamp format. Show that variable on the Control Page. So it's showing "when device went offline" more than when it was last seen, but that's actually all I'm wanting to display anyway. Thanks!
Glad I could help you out (I'm normally the one getting help form everyone else :-) .. I use that way for a number of different devices.
Hi Joe, Request to add custom state to display time that client left the Network. Great work on this plugin. Colly