home-assistant-pure-i9 icon indicating copy to clipboard operation
home-assistant-pure-i9 copied to clipboard

Add cleaning start, end and duration attributes

Open Ekman opened this issue 2 years ago • 9 comments

Add attributes to the vacuum, such as last cleaning. There are some base attributes that are defined in Home Assistant core. Start with them and work from there. Search _ATTR in entity and vacuum.

Originally suggested in https://github.com/Ekman/home-assistant-pure-i9/issues/4.

Ekman avatar Aug 31 '21 12:08 Ekman

Adding attributes:

  • Last cleaning start
  • Last cleaning end
  • Last cleaning duration (seconds)

Ekman avatar Sep 09 '21 19:09 Ekman

Should work pretty easily with CloudRobot.getCleaningSessions() now.

Phype avatar Oct 16 '21 20:10 Phype

Added first attribute in #29 task. I'll look into adding the rest of the attributes with @Phype recommendation.

Ekman avatar Nov 28 '21 17:11 Ekman

Hey @Phype . I'm calling CloudRobot.getCleaningSessions() but I get KeyError: cleaningSession. I've double checked that my robots actually responds with the data using Postman and it does respond with a cleaning session. Do you have any idea what it could be? Here's the code.

image

Ekman avatar Dec 04 '21 11:12 Ekman

Hmm, i'll look into it. item is the object which comes from the cloud API, so probably there is a possibility that one of these JSON objects doesn't have a property because of some weird reason which never happened for me.

Phype avatar Dec 05 '21 13:12 Phype

I've added a workaround, but you have to handle to incomplete data yourself. I guess this will never happen to newly created cleaningsessions from now on, so a simple fix to handle these incomplete objects would be to just ignore them, especially if you only want to display the data for the latest item anyway.

Phype avatar Dec 13 '21 16:12 Phype

BTW, do you want access to the totalLifetimeCleanedArea attribute?

This lists the total area cleaned in m² since the last reset. I can just copy it to the cleaning session object, the only question is if this really makes sense. I'd think this is more a property of the robot, and it's quite unintuitive having to get this property from the last cleaning session instead of sth. like 'CloudRobot.getTotalCleanedArea()' or something.

[
    {
        "id": "obfuscated",
        "sessionId": 1337,
        "timeStamp": "2021-11-20T14:14:39",
        "cleanedArea": 18.87,
        "totalLifetimeCleanedArea": 10318.514
    }
]

Phype avatar Dec 13 '21 16:12 Phype

Thanks for the heads up! Yes, for now I'm only including the latest cleaning session. When/if demands exists I might add more.

If you include the property totalLifetimeCleanedArea in the library then I'll use it. I guess you can look at it from two perspectives:

  1. It's the total area cleaned - Makes more sense to have as a property on the robot and not on the cleaning sessions.
  2. It's the total area cleaned at that point in time - Then it makes sense to have it on the cleaning sessioon. If I'd want to know "what was the total area cleaned before last cleaning.

I don't really know when you'd use the second to be honest. I'll definitely only be displaying one total. 😅

Ekman avatar Dec 13 '21 21:12 Ekman

  1. It's the total area cleaned - Makes more sense to have as a property on the robot and not on the cleaning sessions.
  2. It's the total area cleaned at that point in time - Then it makes sense to have it on the cleaning sessioon. If I'd want to know "what was the total area cleaned before last cleaning.

I don't really know when you'd use the second to be honest. I'll definitely only be displaying one total. 😅

I could think at least one use-case for both options:

  1. I want to know what happened in past
  2. I want to know how the current on-going cleaning is proceeding.

Regardless, as just a dummy integration user, I'd be happy to see either of those. ;)

GitPetri avatar Jan 17 '22 08:01 GitPetri

Finally! 🎉

Better late than never. Just released version 1.4.0 that contains this data.

Ekman avatar Feb 28 '23 21:02 Ekman

Umm, @Ekman little help? I updated the PureI integration via HACS, integration is showing release now as 1.4.0 but I can't see any new entities for my vacuum. Do I need to re-integrate the device?

GitPetri avatar Mar 01 '23 08:03 GitPetri

Weird @GitPetri !

Please add this to your configuration.yaml and then send me your logs Settings -> System -> Logs:

logger:
  default: warn
  logs:
    custom_components.purei9: debug
    purei9: debug
    homeassistant.components.purei9: debug

Ekman avatar Mar 03 '23 17:03 Ekman

Weird @GitPetri !

Please add this to your configuration.yaml and then send me your logs Settings -> System -> Logs:

logger:
  default: warn
  logs:
    custom_components.purei9: debug
    purei9: debug
    homeassistant.components.purei9: debug

Hmm, probably this: 2023-03-04 13:32:45.460 WARNING (SyncWorker_5) [custom_components.purei9.vacuum] DEPRECATED: Setup the integration using integration UI instead of configuration.yml.

GitPetri avatar Mar 04 '23 11:03 GitPetri

Yup, that was it. I had old

vacuum:

  • platform: purei9 email: !secret electrolux_user password: !secret electrolux_password

in my configuration.yaml. Commented those out, re-integrated the vacuum via integration UI and now it works S.U.E. - Stupid User Error. image

GitPetri avatar Mar 04 '23 11:03 GitPetri

I'm glad to hear that! Just let me know if you have any more questions. 🙂

Ekman avatar Mar 06 '23 19:03 Ekman