Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add surepetcare component #24426

Merged
merged 30 commits into from
Jan 6, 2020
Merged

Add surepetcare component #24426

merged 30 commits into from
Jan 6, 2020

Conversation

benleb
Copy link
Contributor

@benleb benleb commented Jun 8, 2019

Description:

Second edition of #22155. Adds a basic component for the Sure Petcare cat and pet flaps. Most important things like lock state of a flap and location of pets is implemented, will eventually be enhanced if component gets accepted.

Related issue (if applicable): https://community.home-assistant.io/t/sureflap-connect-pet-door/41488/54

Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#9590

Example entry for configuration.yaml (if applicable):

surepetcare:
  username: x@y.com
  password: v3rys3cr3t!
  household_id: 1337
  flaps: [{id: 2337, name: Flap}]
  pets: [{id: 3337, name: Pet}]

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.

If user exposed functionality or configuration variables are added/changed:

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

  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New or updated dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

@benleb
Copy link
Contributor Author

benleb commented Jun 9, 2019

Maybe wait until 1. Aug., this code is not Python 3.5 compatible.

@bohtho
Copy link

bohtho commented Jun 9, 2019

Very eager to try this integration. Possible to pull it out to as a custom component ?

@benleb
Copy link
Contributor Author

benleb commented Jun 9, 2019

Sure, just copy the components/surepetcare folder to custom_components/surepetcare

@asifma
Copy link

asifma commented Jun 9, 2019

I tried this config:

surepetcare:
username: xxxxx
password: xxxxx
household_id: 29838
flaps: [{id: xxxxx, name: Balkongen}]
pets: [{id: xxxxx, name: Jenna}]
scan_interval: 00:00:100:

However its not updating at all. I see that you are using:
from surepy import SurePetcare

But it feels like surepy is very slow at updating, or even updating at all?
At least I would like the component to update every minute or so.

Am I doing something wrong here @benleb ?

@benleb
Copy link
Contributor Author

benleb commented Jun 9, 2019

Visit https://surepetcare.io while your browsers dev/js console is open. The household ID will be visible there multiple times, searching for "household" gets you to your ID 👍

image

@asifma
Copy link

asifma commented Jun 9, 2019

Visit https://surepetcare.io while your browsers dev/js console is open. The household ID will be visible there multiple times, searching for "household" gets you to your ID 👍

image

The component is working, and I get all the sensors in Hass.io but they are not updating...

@benleb
Copy link
Contributor Author

benleb commented Jun 9, 2019

Did you wait a little? The scan_interval defaults to 3 minutes as Sure Petcare explicitly does not like/want that their API is used this way. I have talk to them a few times and it was really disappointing... So, you can change the update interval via the scan_interval config option, but please be aware that nobody knows what will happen if you pull to often...

edit ah sorry, my fault... will fix this today or tomorrow :D

@benleb
Copy link
Contributor Author

benleb commented Jun 10, 2019

fixed, sorry! ✌️

@antilope2
Copy link

Thanks for the great work @benleb !

Would be great to have this integrated once Python 3.5 support is dropped later this year.

@benleb benleb changed the title Add surepetcare component [WIP] Add surepetcare component Jun 27, 2019
@benleb benleb changed the title [WIP] Add surepetcare component Add surepetcare component Jun 27, 2019
@kaosmagix
Copy link

Great work! Got it to work using your instruction. Thanks!

@MartinHjelmare MartinHjelmare added this to Needs review in Dev Jul 23, 2019
homeassistant/components/surepetcare/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/binary_sensor.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/const.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/sensor.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/sensor.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/sensor.py Outdated Show resolved Hide resolved
Dev automation moved this from Needs review to Review in progress Aug 10, 2019
@MartinHjelmare
Copy link
Member

Please rebase on latest dev branch too.

@MartinHjelmare
Copy link
Member

@benleb are you planning to continue here?

@nikotime
Copy link

When I upgrade from 98.4 to 98.5 this breaks for me. Has anyone else encountered the same issue?

@Groodles
Copy link

Groodles commented Oct 6, 2019

@nikotime I'm running 0.99.3 (Home Assistant) in docker and it's working fine.

@benleb This is a really great component for HA. Do you know if it would be possible to make the interface Read/Write instead of Read-Only?

@nikotime
Copy link

nikotime commented Oct 7, 2019

@nikotime I'm running 0.99.3 (Home Assistant) in docker and it's working fine.

@benleb This is a really great component for HA. Do you know if it would be possible to make the interface Read/Write instead of Read-Only?

Thanks - I think my problem was that I wasn't patient enough. My pet entity in HA only seems to appear after 10-15 minutes following boot - I think sometimes it struggles on first boot.

@benleb
Copy link
Contributor Author

benleb commented Oct 7, 2019

@benleb are you planning to continue here?

@MartinHjelmare yes, gimme some days ;)

@Groodles I did not implement any writing as this is an undocumented API which we have no permission to use ;) So to prevent any crazy surprises for us or our cats, just reading for now ;)

@henrik242
Copy link

@MartinHjelmare yes, gimme some days ;)

How many days are "some"? 😸 🤔

@benleb
Copy link
Contributor Author

benleb commented Oct 30, 2019

Ten more ;) my masters thesis is in its final phase now and has precedence :)

homeassistant/components/surepetcare/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/binary_sensor.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/binary_sensor.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/sensor.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/sensor.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/binary_sensor.py Outdated Show resolved Hide resolved
Copy link
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

We're getting close. It's mostly clean up left but two things about the library should change. See below.

homeassistant/components/surepetcare/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/binary_sensor.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/binary_sensor.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/const.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/sensor.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/sensor.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/binary_sensor.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/sensor.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/sensor.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/sensor.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/sensor.py Outdated Show resolved Hide resolved
Copy link
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

When you're ready, please remove the commented code.

homeassistant/components/surepetcare/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/surepetcare/__init__.py Outdated Show resolved Hide resolved
@MartinHjelmare
Copy link
Member

Remember to update .coveragerc and exclude the new integration package from coverage calculation. Use a star.

Copy link
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Great job!

Dev automation moved this from Review in progress to Reviewer approved Jan 5, 2020
@benleb
Copy link
Contributor Author

benleb commented Jan 5, 2020

Great job from you @MartinHjelmare! Thanks for your awesome work and reviews here on github! 👍

@cgarwood cgarwood merged commit 1fffa21 into home-assistant:dev Jan 6, 2020
Dev automation moved this from Reviewer approved to Done Jan 6, 2020
@benleb benleb deleted the surepetcare branch January 6, 2020 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Dev
  
Done
Development

Successfully merging this pull request may close these issues.

None yet