benleb / surepy

🐾 Library & CLI to monitor and control the Pet Door & Cat Flap Connect 🚪 the Pet Feeder Connect 🍽 and the Felaqua 💦 sold by Sure Petcare
https://pypi.org/project/surepy/
MIT License
76 stars 36 forks source link

Fix to always use json when sending a PUT/POST #201

Closed ashleigh-hopkins closed 8 months ago

ashleigh-hopkins commented 8 months ago

Disclaimer, I've never written any python before... and I didn't test that any command and control actions work 😅

Should fix #199

benleb commented 8 months ago

oh hey :D thanks you! looks good on first view, will check it tomorrow and merge :)

great to get a contribution from you! 🙌 😄

dieriver commented 8 months ago

I have tested this fix, and it seems it works. At least the PUT queries now work (specifically, u tried using the client._set_lock_state function, and the server can handle it correctly.

jdrews commented 8 months ago

I have also tested this branch and can confirm that it restores API connectivity. On the v0.9.0a0 release I get a "[415 Unsupported Media Type]" and DENY back from surehub.io. With this PR I am able to perform queries to the surehub.io API again.

ivo-toby commented 8 months ago

I replaced the lib in my Home-assistant install and it works like a charm! Just in time for new-years so I can keep the cats indoors while I'm abroad.. Thanks a lot!

blair287 commented 8 months ago

I replaced the lib in my Home-assistant install and it works like a charm! Just in time for new-years so I can keep the cats indoors while I'm abroad.. Thanks a lot!

How do you do that please?

ivo-toby commented 8 months ago

I replaced the lib in my Home-assistant install and it works like a charm! Just in time for new-years so I can keep the cats indoors while I'm abroad.. Thanks a lot!

How do you do that please?

Depends on your setup, ymmv. I am running HassOS (in proxmox) with the advanced SSH plugin. I don't upgrade Home-assistant that often, so I am not on the latest version!

So what I did:

That should do the trick. I do recommend backing up the original surepy folder in /usr/local/lib/python3.11/site-package/. Also; if you update Home-assistant and the fixes has not been merged you will need to do this again.