Hi, I have a question for those who know how I can share configuration between my init.py and my sensor.py file.
I developed a custom plugin for home assistant, I only used sensor.py file.
This morning, I decided to add to my custom component various services.
So I used the init.py file to initialize my services. And the sensor.py file for my custom sensor.
But now, I want to share my CONFIG_SCHEMA (define in the init) to my sensor.py file.
What exactly are you trying to reuse or accomplish? I can’t think of a reason to use the CONFIG_SCHEMA in your sensor.py, but I might not be understanding what problem you are trying to solve.
The CONFIG_SCHEMA is used only for validating and formatting your configuration parameters. The configuration parameters are then passed as the second argument to your component´s async_setup(hass, config) coroutine from where you have access to them (config is a dictionary).
Usually you can store arbitrary information (and also your parameters) in the hass.data[DOMAIN] dictionary where DOMAIN is usually your component´s name.
The hass object is then available in your sensor.py (passed to async_setup_platform(hass, ...)) from where you again have access to the data attribute and your parameters.
Sorry hit send before I was done. If you want to configure multiple entries for this interegration, you won’t be able to distinguish them using the hass.data approach.