Vaskivskyi / ha-asusrouter

Monitor and control your AsusWRT-powered router from Home Assistant
https://asusrouter.vaskivskyi.com
Apache License 2.0
183 stars 17 forks source link

[Feature] The X_boot_time entity is a looong fat "string" and not a TimeStamp or similar, so you cant even use it with "last_updated/change". #804

Closed boheme61 closed 7 months ago

boheme61 commented 7 months ago

The problem

Can the state be changed to a timestamp , which one can template easily, instead of this predefined long String

Specific device(s)?

None

Firmware type

None

Vaskivskyi commented 7 months ago

Hello. I will check this possibility and get back to you

mdisabato commented 7 months ago

If this helps: What the integration supplies: 2024-03-01T09:33:27+00:00 What a "last updated" attribute looks like, which is supposed to be the right format: 2024-03-01 23:00:00.141389+00:00

I get there is no "tzdata" in the string.

Thank you.

Michael

boheme61 commented 7 months ago

Actually this is the string i see in my UI " February 29, 2024 at 01:49 "

And i would prefer a much shorter. I understand Vaskivskyi argument in regards to to the "uptime status" which many previous(and still use) i.e ( 5 days, 11 hours, 37min "ago")( and counting ) has a bad/not desired impact on the system/hardware.

I.E I could/would "interpret" a "string" without the Year at all or in 2 digits ... I mean if it i.e says October ( I know it was 2023 ) , i would know that even it it just said " Oct " or Even if it said "Mar" ( As there are a few days until Marsh 29 )

And how many of peoples Router does actually Not need a "reboot" once or twice a year ? , So the risk that people ends up in a confused state is quite small

So maybe the sensor could provide 2 strings, or 2 sensors ( i know ! i can make my 0wn template-sensor ) But maybe a short and the long version could be an alternative

February 29, 2024 at 01:49 Feb. 29 at 01:49

I would prefer the latest/shortest

Ahh Michael, now i get it, sorry i actually never looked in Dev-Tools#State, before posting this FR ( Not sure where the native entity card, get the Format from, it's not from my "profile-settings" , as i have Year-Month-Day ( Never seen any Countries with the Year in the Middle ) Even naive sensor-card shows the same Looong format , And Entities-card shows "Yesterday", compared to entity-card ( Loong format )

So it seems this put me in the "state" to make my own sensor, from the time-stamp provided ! , convert it to a short "string"

mdisabato commented 7 months ago

I have this in a Mushroom Template Chip card as the Content field:

{% set date = states('sensor.zenwifi_ax_boot_time')[:10] %} {% set (h,m,s) = states('sensor.zenwifi_ax_boot_time')[11:19].split(':') | map('int', 0) %} {% set time = utcnow().replace(hour=h, minute=m, second=s) | as_timestamp | timestamp_custom('%H:%M:%S') %} Last Boot: {{date}} {{time}}

As the last line indicates, I get the date and time of the last boot. A workaround until/if this is changed. For me, this also puts the issue into a "non-hurry" state. :)

boheme61 commented 7 months ago

For me, this also puts the issue into a "non-hurry" state. :)

I ended up with this

      {% set date = states('sensor.asusr_boot_time')[:10] | as_timestamp |
      timestamp_custom('%b-%d') %} {% set (h,m,s) =
      states('sensor.asusr_boot_time')[10:19].split(':') | map('int', 0) %}  {%
      set time = utcnow().replace(hour=h, minute=m, second=s) | as_timestamp |
      timestamp_custom('%H:%M') %} {{date}} at {{time}}

But as i needed it in an custom:multi-entity-row , inside the "header" of custom:fold-entity-row ( Which is filled with "device_trackers" in custom:mushroom-entity-cards, provided by custom:auto-entities ) btw. LOL For this, i had to create a template-sensor ( anyways ) ... only haven't figured out howto remove " " EDIT: i had wrapped my template-sensor in those " " hehe ... solved

Before: 03 03 2024_11 55 25_REC After: 03 03 2024_12 29 24_REC 03 03 2024_12 31 00_REC

So for me, i'll close this FR, as i obviously always need "something else" hmmmm :)