Beginner Question: First integration: Do i need a own PyPI package?

Hey all,
i plan to write a own integration. I expect that the integration will be very simple and try to follow the best practice guide as good as possible.

The integration will provide some sensor entities. All of this entities should be generated by simple http api calls

I used python3 -m script.scaffold integration to create the skeleton.

In a next step i would like to edit the file. I would like to create a basic check if the target host is available. (technically i just want to check if i get a http.response code 200 for my request to confirm that the http endpoint is reachable)

In the example and also in other integrations i see that they use at this point mainly code from their own PyPi-Package and methods/functions provided by this own package. However, i do not have a specific package. I would like to use simple http requests with the help of the requests library in python.

Thats why i would like to ask you:
Is this the right place to store my code? Do i need in every case an own pypi package providing the different methods or can i place my code direct in regarding the config checks (and later in if it comes to the different api calls) ?

Every integration specific code should be placed in a pypi package, if you want your integration to become core installation. More info here: Building a Python library for an API | Home Assistant Developer Docs

Otherwise, you can have a custom component (integration) and don’t need to follow these requirements.

Thanks @anon63427907 . Makes it very clear for me.

As i would like to become core with the integration i will create a specific pypi package. The link you pasted seems like a perfect starting point for me

1 Like

I’d recommend using asyncio - aiohttp since it sounds like a http interface.