Skip to content

Fix: surepetcare sensor error#143286

Merged
joostlek merged 14 commits intohome-assistant:devfrom
PineappleEmperor:dev
Apr 25, 2025
Merged

Fix: surepetcare sensor error#143286
joostlek merged 14 commits intohome-assistant:devfrom
PineappleEmperor:dev

Conversation

@PineappleEmperor
Copy link
Contributor

@PineappleEmperor PineappleEmperor commented Apr 19, 2025

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the [development checklist][dev-checklist]
  • I have followed the [perfect PR recommendations][perfect-pr]
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If the code communicates with devices, web services, or third-party tools:

To help with the load of incoming pull requests:

Copy link

@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @PineappleEmperor

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@home-assistant home-assistant bot marked this pull request as draft April 19, 2025 21:12
@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant
Copy link

Hey there @benleb, @Danielhiversen, mind taking a look at this pull request as it has been labeled with an integration (surepetcare) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of surepetcare can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign surepetcare Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@PineappleEmperor PineappleEmperor marked this pull request as ready for review April 20, 2025 08:07
@PineappleEmperor PineappleEmperor marked this pull request as draft April 20, 2025 08:46
@PineappleEmperor PineappleEmperor marked this pull request as ready for review April 20, 2025 08:51
@daernsinstantfortress
Copy link

Tested on my own sureflap and this PR restores the integration to fully working again 👍

Copy link

@sdjmchattie sdjmchattie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix looks good to me. Shame all the try blocks make it look messy. Only other alternative is using .get() on dictionary retrievals, but with the float formatting going on, you still end up with if else so actually more complicated to understand.

I think there's a spurious change which I've added a comment to.

benleb added a commit to benleb/sureha that referenced this pull request Apr 22, 2025
Fix for home-assistant/core#143149

Thanks to @PineappleEmperor for the quick fix of the official surepetcare integration! 🙌 (home-assistant/core#143286)
Copy link

@daernsinstantfortress daernsinstantfortress left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now 👍

@PineappleEmperor
Copy link
Contributor Author

lgtm :) thanks for the quick fix!

If you & @Danielhiversen are happy, it comes down to one of you approving the last workflow I think :)
Hopefully the most recent changes worked for @daernsinstantfortress and @timsprawe. Thanks for all the help!

@benleb
Copy link
Contributor

benleb commented Apr 22, 2025

lgtm :) thanks for the quick fix!

If you & @Danielhiversen are happy, it comes down to one of you approving the last workflow I think :) Hopefully the most recent changes worked for @daernsinstantfortress and @timsprawe. Thanks for all the help!

I lack the required permissions, sorry :/ But I am sure @Danielhiversen will do it asap 👍

@Housefrau90
Copy link

lgtm :) thanks for the quick fix!

If you & @Danielhiversen are happy, it comes down to one of you approving the last workflow I think :) Hopefully the most recent changes worked for @daernsinstantfortress and @timsprawe. Thanks for all the help!

Works like a charm! Thanks to all devs :)

@daernsinstantfortress
Copy link

lgtm :) thanks for the quick fix!

If you & @Danielhiversen are happy, it comes down to one of you approving the last workflow I think :) Hopefully the most recent changes worked for @daernsinstantfortress and @timsprawe. Thanks for all the help!

Works like a charm! Thanks to all devs :)

All good here too. Nice one and thanks for the rapid intervention here.

@MadMonkey87
Copy link
Contributor

Does NOT look good to me, it worked before the update, now it's broken, i.e the status of the pets and the connectivity entity are not available anymore although the battery state and locking unlocking the flap still work

@Housefrau90
Copy link

Housefrau90 commented Apr 23, 2025

Does NOT look good to me, it worked before the update, now it's broken, i.e the status of the pets and the connectivity entity are not available anymore although the battery state and locking unlocking the flap still work

Please provide your logs.

@PineappleEmperor
Copy link
Contributor Author

@MadMonkey87 are you referring to the sureHA version? If so, as the others have said, your logs would be very useful.

If you're talking about the latest version of HA, this fix hasn't been incorporated yet so it will be broken in the HA integration.

@MadMonkey87
Copy link
Contributor

@MadMonkey87 are you referring to the sureHA version? If so, as the others have said, your logs would be very useful.

If you're talking about the latest version of HA, this fix hasn't been incorporated yet so it will be broken in the HA integration.

Then it might be the later, I'am sorry🤐 Looking into the code here this indeed seems to be the case:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in _async_setup_platform await asyncio.shield(awaitable) File "/usr/src/homeassistant/homeassistant/components/surepetcare/binary_sensor.py", line 44, in async_setup_entry entities.append(DeviceConnectivity(surepy_entity.id, coordinator)) ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/surepetcare/binary_sensor.py", line 130, in init super().init(surepetcare_id, coordinator) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/surepetcare/binary_sensor.py", line 62, in init super().init(surepetcare_id, coordinator) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/surepetcare/entity.py", line 45, in init self._update_attr(coordinator.data[surepetcare_id]) ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/surepetcare/binary_sensor.py", line 141, in _update_attr "hub_rssi": f"{state['signal']['hub_rssi']:.2f}", ~~~~~~~~~~~~~~~^^^^^^^^^^^^ KeyError: 'hub_rssi'

@sdjmchattie
Copy link

Yeah that's the original error that this PR fixes. We'll have to wait for this to trickle through unfortunately.

@daernsinstantfortress
Copy link

After all of the hard work, it's slightly frustrating that this didn't get included in today's 2025.4.4 update as it would have been a perfect opportunity for it.

@frenck Sorry to prod you directly, but this integration is down for all users right now, the fix is submitted and tested and ready to go - it just needs accepting and merging, but there's noone active here with access rights to do it. Is this something you could help with? At least then it can get into the 2025.5.0 release.

Copy link
Member

@joostlek joostlek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are failing, can you take a look?

@home-assistant home-assistant bot marked this pull request as draft April 25, 2025 15:26
Copy link

@Housefrau90 Housefrau90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still working with this change.
Just fyi, I‘m not a dev.

@PineappleEmperor
Copy link
Contributor Author

Tests are failing, can you take a look?

@joostlek so I'm not entirely certain what the tests are doing in all honesty. The test failing seems to be checking that unique ids are being generated (which they are) but failing on a check for the actual value of the state - I believe this is because the mock feeder is missing the 'online' status, which I believe is in error.

@joostlek
Copy link
Member

I am assuming this bugfix was needed because the API changed, so then the tests should be updated to reflect what the API does I guess

@PineappleEmperor
Copy link
Contributor Author

I think this was an old error to be honest, but in fixing the actual API change we also used a slightly different way to set the state (based off an actual 'online' status, not just the existence of data), which wasn't reflected in the original tests.

@joostlek
Copy link
Member

If it's ready for review, please use the button :)

@PineappleEmperor PineappleEmperor marked this pull request as ready for review April 25, 2025 17:25
@PineappleEmperor
Copy link
Contributor Author

Woops! Sorry 😅

@joostlek joostlek merged commit 94b0800 into home-assistant:dev Apr 25, 2025
34 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Apr 26, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sure Petcare: Integration broken due to possible API change

9 participants