Ekman / home-assistant-pure-i9

Electrolux Pure i9 robot vacuum integration for Home Assistant.
MIT License
26 stars 5 forks source link

Add cleaning start, end and duration attributes #10

Closed Ekman closed 1 year ago

Ekman commented 3 years ago

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 commented 3 years ago

Adding attributes:

Phype commented 2 years ago

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

Ekman commented 2 years ago

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

Ekman commented 2 years ago

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

Phype commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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
    }
]
Ekman commented 2 years ago

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. 😅

GitPetri commented 2 years ago
  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. ;)

Ekman commented 1 year ago

Finally! 🎉

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

GitPetri commented 1 year ago

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?

Ekman commented 1 year ago

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
GitPetri commented 1 year ago

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 commented 1 year ago

Yup, that was it. I had old

vacuum:

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
Ekman commented 1 year ago

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