Can I execute an integration outside of home assistant in an IDE?

Hey all,

Extremely new to writing/working with any sort of integrations with home assistant. My background with Python is mostly just writing small/odd python jobs and executing them directly.

I am working on updating an integration that a previous developer stopped supporting. I am trying to see if I can run this locally in my PyCharm.

This integration reads username/password from a configured sensor along with a few other parameters, and then creates a new sensor with attributes.

I would really like to be able to throw in a few print statements and execute to figure out where this thing is breaking within my IDE but I cant figure out how I could load in this sensor information or properly execute the python script.

Would I basically just need to deconstruct the various parts and manually feed the data in or is there a more elegant way?

Thanks for bearing with me…

There are various ways you could explore and a good starting point is this: Starting with Development | Home Assistant Developer Docs
In this case I’d suggest:

  • Write unit tests that mock whatever object/sensor/integration you want and execute tests locally.
  • Set up a development environment to run Home Assistant and your integration on your machine.

Thanks Ill give that a go!

Hey @ideal2545! I know this is a bit old, but I’m wondering if you’ve had success using PyCharm for development?

I’m using it as well (technically Intellij Ultimate, but same thing), but I’ve run into some issues running HA itself (via hass) and tests from inside Intellij. Particularly running into issues caused by the test/ file.

Sorry to dig up this old topic, but I’m finding it really difficult to find information on developing for HA core on Intellij. Any help would be appreciated, thanks!