While developing Home Assistant you will see a variable that is everywhere:
hass. This is the Home Assistant instance that will give you access to all the various parts of the system.
The Home Assistant instance contains four objects to help you interact with the system.
|This is the instance of Home Assistant. Allows starting, stopping and enqueuing new jobs. See available methods.|
|This is the core configuration of Home Assistant exposing location, temperature preferences and config directory path. See available methods.|
|This is the StateMachine. It allows you to set states and track when they are changed. See available methods.|
|This is the EventBus. It allows you to trigger and listen for events. See available methods.|
|This is the ServiceRegistry. It allows you to register services. See available methods.|
Where to find
Depending on what you're writing, there are different ways the
hass object is made available.
setup(hass, config) or
setup_platform(hass, config, add_devices, discovery_info=None) or
async_setup_platform(hass, config, async_add_devices, discovery_info=None).
self.hass once the entity has been added via the
add_devices callback inside a platform.