albaintor / homeassistant_electrolux_status

Get the status from your Electrolux Care devices
MIT License
90 stars 23 forks source link

Timestamp unit for time to end #71

Open steuerlexi opened 1 month ago

steuerlexi commented 1 month ago

Is it possible to have a timestamp entity for the time_to_end entity?

I would need it for this timer bar to work: https://github.com/rianadon/timer-bar-card

kingy444 commented 1 month ago

The api isnt super consistent across device types - i think the easiest path forward would be to look at creating an automation that fills a timer entity for your needs

This is not super useful for my fridge, as all the timers return in minutes. This resukts in every refresh restarting the timer and it goes up and down over and overuntil the full minute passed

something like the below

timer:
  fridge_fast_mode:
    duration: "00:00:00"
automation:
  - alias: Set fridge fast mode timer
    trigger:
      - platform: state
        entity_id: sensor.electrolux_kitchen_fridge_fridge_fastmodetimetoend
    condition:
      - condition: template
        value_template: "{{ states('sensor.electrolux_kitchen_fridge_fridge_fastmodetimetoend') | int > 0 }}"
    action:
      - service: timer.start
        target:
          entity_id: timer.fridge_fast_mode
        data:
          duration: >
            {% set minutes = states('sensor.electrolux_kitchen_fridge_fridge_fastmodetimetoend') | int %}
            {% set hours = (minutes // 60) %}
            {% set remaining_minutes = minutes % 60 %}
            {{ '%02d:%02d:00' | format(hours, remaining_minutes) }}
Sascha-L commented 1 month ago

Before the last update the Time To End entity returns e.g.: 50. Which means 50 min. Now with the latest release the time is returned as "50.0". Please fix this. Your entity also ignores the unit format setting, because it is set to 50 instead of 50.0 but still returns 50.0, so I had to manually remove the ".0" in my dashboards. As said, with all previous versions the value was correct.

kingy444 commented 1 month ago

Precision like that does sound strange as I would expect it to be 50:00. You could just have updated the precision on each entry directly rather than in your dashboard (and may still prefer to)

Previously time was converted to minutes in integration code and stored that way meaning it was less accurate. Time is stored in seconds now to allow conversion in the UI (as per HA standard) and using the HA UI to convert to minutes.

Note that even if we adjust the precision in the code, your entities likely won't auto update without a remove and readd. It is not loaded on every restart

I do actually think that the current 50.0 is more accurate as it includes the information on seconds and would display 40:30 for instance rather than just 40

It's only 3 clicks to change the precision of an entity after all.

You could submit a device specific catalog that would force this too

Sascha-L commented 1 month ago

Where can I change the precision? As said, the precision settings on that entity has no effect, what ever I set up, your entity always returns "50.0" instead of e.g. "50". That's why I had to fix it in my dashboards. Also my devices never shows seconds, it always full minutes.

image image
steuerlexi commented 3 weeks ago

The api isnt super consistent across device types - i think the easiest path forward would be to look at creating an automation that fills a timer entity for your needs

This is not super useful for my fridge, as all the timers return in minutes. This resukts in every refresh restarting the timer and it goes up and down over and overuntil the full minute passed

something like the below

timer:
  fridge_fast_mode:
    duration: "00:00:00"
automation:
  - alias: Set fridge fast mode timer
    trigger:
      - platform: state
        entity_id: sensor.electrolux_kitchen_fridge_fridge_fastmodetimetoend
    condition:
      - condition: template
        value_template: "{{ states('sensor.electrolux_kitchen_fridge_fridge_fastmodetimetoend') | int > 0 }}"
    action:
      - service: timer.start
        target:
          entity_id: timer.fridge_fast_mode
        data:
          duration: >
            {% set minutes = states('sensor.electrolux_kitchen_fridge_fridge_fastmodetimetoend') | int %}
            {% set hours = (minutes // 60) %}
            {% set remaining_minutes = minutes % 60 %}
            {{ '%02d:%02d:00' | format(hours, remaining_minutes) }}

Somehow I can´t get this to work. How can I set up this automation step by step? Thank you