Thomas55555 / husqvarna_automower

Custom component for Home Assistant to monitor and control your Husqvarna Automower
https://github.com/Thomas55555/husqvarna_automower
MIT License
105 stars 28 forks source link

Problem sensor = Unknown when mowing #555

Closed mkmer closed 7 months ago

mkmer commented 10 months ago

Prerequirements [x] I have connected my mower(s) to the Automower Connect App [x] I have connected my Husqvanra developers account to the Authentication API [x] I have connected my Husqvarna developers account to the Automower Connect API

Describe the bug A clear and concise description of what the bug is. When the mower is mowing, the problem sensor is "unknown" - all other states appear to work fine.

Expected behavior A clear and concise description of what you expected to happen. I would think it would be "ok" or "mowing" or something other than unknown when mowing. Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here. from diagnostics: "mower": { "mode": "MAIN_AREA", "activity": "MOWING", "state": "IN_OPERATION", "errorCode": 0, "errorCodeTimestamp": 0 }, I modified sensor.py to add mowing to get_problem() just under ==CHARGING ln 55, add similar line with =="MOWING" - may or may not be "right", but problem sensor is no longer unknown when mowing.

mkmer commented 10 months ago

config_entry-husqvarna_automower-e954a2e877edbdfa0c6ae28563b80c8e.json.txt

Thomas55555 commented 10 months ago

unknown is actually right, because when it's knowing, it has no problem.

mkmer commented 10 months ago

Seems like "OK" or "No Problem" would be more clear :)
Unknown makes a user believe it's not being updated....

mkmer commented 9 months ago

https://community.home-assistant.io/t/difference-between-unknown-unavailable-none-and-null/430966/3

Thomas55555 commented 9 months ago

So according to this none would be the right state, because the mower has no problem, right?

mkmer commented 9 months ago

When you set the entity state to none, it's state is unknown. You could set it to "none" (a string). This entity does say other "things" like "charging" and "week schedule" which are also not problems. The only time it's actually unknown is when the mower is mowing.
I'm not partial to what it actually says other than showing unknown which is supposed to mean logic is not connected to the entity.

Thomas55555 commented 9 months ago

"none" as a string sounds quiet okay. A saw some other integrations doing this.

mkmer commented 9 months ago

This code is reaching the return None -> thus the state entity shows as unknown

https://github.com/Thomas55555/husqvarna_automower/blob/d9a0c90acf13244cce6f81e97fcdaf27cb70e460/custom_components/husqvarna_automower/sensor.py#L53-L71

I've modified it a bit on line 55 to look like this:

 55     if mower_attributes["mower"]["activity"] in ["CHARGING","MOWING","RETURNING"]:
 56         return mower_attributes["mower"]["activity"].lower()

Now when the mower is mowing and returning to the dock it reports like it does when it's charging.

stale[bot] commented 7 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.