MTrab / landroid_cloud

Landroid Cloud component for Home Assistant
GNU General Public License v3.0
266 stars 33 forks source link

[FR]: Add entity for worktime in minutes #536

Closed sithmein closed 5 months ago

sithmein commented 5 months ago

Describe the feature you wish to make a request for

Currently worktime_total is the work time in hours. It's derived from the work time in minutes which is provided by pyworxcloud. The work time in HA should be provided in minutes instead (or at least additionally) since you can always derive the hours from the minutes but not vice-versa due to rounding.

Describe alternatives you've considered

No response

Additional context

No response

MTrab commented 5 months ago

Rather than adding a new sensor, showing the same info as already available, wouldn't it be better to convert all the hour sensors to minutes?

And yes - that would be a breaking change

sithmein commented 5 months ago

I agree that it would be better to have the current sensors report minutes. Personally I don't mind the breaking change since I only started using the integration recently. Not sure about the other users.

Menama83 commented 5 months ago

Hello all, to begin thank you @MTrab for this great integration. Like @sithmein, I'm interested to have this information to know exactly how many time the robot worked and to manage it precisely each day. Maybe I'm wrong but the others sensors are less important in minutes. However, To have a synthesis like using landroid card, it's interesting in hours. Is it possible to keep in hours and adding an attribute in minutes?

KHV8 commented 5 months ago

Not sure what you try to obtain. If you look in the Landroid app, it is in hours, no decimals.

If you need a "daily total" or "last 7 days total", then use a simple sensor in HA, providing hours with a lot of decimals

sensor

Menama83 commented 5 months ago

I want to know the worktime of the day in live. I keep the worktime of the day before that I compare with the current. Then, I manage the worktime of the day depending of the temperature. In hours, it's not enough precise. I hope I'm clear.

sithmein commented 5 months ago

The mower reports all timespans in minutes. The integration currently rounds them to hours. There are use cases for having it in minutes precision [1]. From my point of view there are three possibilities:

  1. Change the existing entities from hours to minutes. This is a breaking change as @MTrab already pointed out.
  2. Introduce additional entities for minutes. Creates some redundancy.
  3. Add an attribute for minutes to the existing entity. Less redundant but will require additional template entities in some cases (e.g. for creating stats based on the attribute).

[1] I want to maintain a constant mowing time per week. If it rains on one day the mower should do more on the next day.

MTrab commented 5 months ago

As it looks right now, I'll be most into adding minutes as an attribute, and if some users need it as a sensor, it's pretty trivial to make a template sensor for that

But haven't fully decided yet

KHV8 commented 5 months ago

I want to know the worktime of the day in live. I keep the worktime of the day before that I compare with the current. Then, I manage the worktime of the day depending of the temperature. In hours, it's not enough precise. I hope I'm clear.

It is live and super precise, with multible decimals. Just done by HA, making it super flexible if you whant others timeperiods, like since 12.00 or alike.

Menama83 commented 5 months ago

@KHV8 , can you explain how do you obtain the value of worktime with decimals? Thank you

KHV8 commented 5 months ago

The sensor from HA is in hours with 2 decimals. This is precise to the minute.

As a lot of other sensors in HA, it updates once every minute.

Here is the docs https://www.home-assistant.io/integrations/history_stats/

What is the usecase?

Menama83 commented 5 months ago

I'm a noob, I tried this

  - platform: history_stats
    name: tempstonte
    entity_id: lawn_mower.l800_wr148e
    state: "mowing"
    type: time
    start: "{{ today_at() }}"
    end: "{{ now() }}"

but I have this message in logs

Enregistreur: homeassistant.config Source: config.py:609 S'est produit pour la première fois: 14:54:25 (6 occurrences) Dernier enregistrement: 15:03:13

Invalid config for 'template' at template_sensors.yaml, line 60: 'platform' is an invalid option for 'template', check: sensor->4->platform Invalid config for 'template' at template_sensors.yaml, line 62: 'entity_id' is an invalid option for 'template', check: sensor->4->entity_id Invalid config for 'template' at template_sensors.yaml, line 64: 'type' is an invalid option for 'template', check: sensor->4->type Invalid config for 'template' at template_sensors.yaml, line 65: 'start' is an invalid option for 'template', check: sensor->4->start Invalid config for 'template' at template_sensors.yaml, line 66: 'end' is an invalid option for 'template', check: sensor->4->end

KHV8 commented 5 months ago

EDIT: I think you miss the "sensor:" in the configuration, before the -platform, or if you have multible sensors already defined, some spacing is wrong

but I have this message in logs

Your sensor is the same as mine, except for one thing, the start. I use. start: "{{ now().replace(hour=0, minute=0, second=0) }}"

My full sensor looks like this, I do a "today" and a 7day. `

One question, how do you make it look nice. When I paste it looks like this, even I choose the "code" when pasting

Menama83 commented 5 months ago

Yes, I have a file template_sensors.yaml with some sensors. So I don't understand my problem.

For your problem, Paste your text, then selct the text and click on code button.

Menama83 commented 5 months ago

Blades Total On Time in minutes should be interesting too

KHV8 commented 5 months ago

Yes, I have a file template_sensors.yaml with some sensors

The history stats are a sensor and not a template. Hence, should go in the sensor part of the configuration and not templates. If it is all in configuration.yaml, it should look like this

sensor:
  - platform: history_stats
    name: Roberto runtime 7d
    entity_id: lawn_mower.roberto
    state: "mowing"
    type: time
    end: "{{ now() }}"
    duration:
      days: 7

  - platform: history_stats
    name: Roberto runtime today
    entity_id: lawn_mower.roberto
    state: "mowing"
    type: time
    end: "{{ now() }}"
    start: "{{ now().replace(hour=0, minute=0, second=0) }}"

If you have a sensor.yaml file, then the sensor: should be there

KHV8 commented 5 months ago

Blades Total On Time in minutes should be interesting too

This can only come from the integration.