Module homey.homey

Classes

class Homey

The Homey instance holds all the Managers, System Events and generic properties. You can access the Homey instance through self.homey on App, Driver and Device, and it is also passed into your api handlers.

By reading Homey.platform and Homey.platform_version, your app can determine which product your app is running on.

Product platform platform_version
Homey Cloud cloud 1
Homey Pro (Early 2023) local 2

Ancestors

Instance variables

var api : Final[ManagerApi]
var apps : Final[ManagerApps]
var arp : Final[ManagerArp]
var ble : Final[ManagerBLE]
var clock : Final[ManagerClock]
var cloud : Final[ManagerCloud]
var dashboards : Final[ManagerDashboards]
var discovery : Final[ManagerDiscovery]
var drivers : Final[ManagerDrivers]
var flow : Final[ManagerFlow]
var geolocation : Final[ManagerGeolocation]
var i18n : Final[ManagerI18n]
var images : Final[ManagerImages]
var insights : Final[ManagerInsights]
var notifications : Final[ManagerNotifications]
var rf : Final[ManagerRF]
var settings : Final[ManagerSettings]
var videos : Final[ManagerVideos]
var zigbee : Final[ManagerZigbee]
var zwave : Final[ManagerZWave]
var app : Final[App]

This app.

var manifest : Final[Any]

The app manifest from app.json.

var platform : Final[Literal['local', 'cloud']]

The platform that the Homey is running on.

var platform_version : Final[Literal[1, 2]]

The platform version the Homey is running on.

var version : Final[str]

The type of the None singleton.

var env : Final[dict]

The environment variables from env.json.

Methods

async def ready(self) ‑> None

Get an awaitable that is resolved when the Homey is ready, meaning App.on_init() has been run.

def translate(self, key: str, **tags: str) ‑> str | None

Translate a string, as defined in the app's /locales/<language>.json file.

Example:

/locales/en.json

{ "welcome": "Welcome, __name__!" }

/app.py

welcome_message = self.homey.translate("welcome", name="Dave")
self.log(welcome_message)

Args

key
The key in the <language.json> file, with dots separating nesting. For example "errors.missing".
tags
A keyword mapping of tags in the string to replace. For example, for Hello, __name__! you could pass name="Dave".

Returns

The translated string, or None if the key was not found.

def set_interval(self, callback: Callable, ms: int, *args, **kwargs) ‑> int

Set an interval that calls the given callback every ms milliseconds, with any given arguments. This interval is automatically cleared when the Homey instance gets destroyed.

Returns

The ID of the created interval.

def clear_interval(self, id: int | None) ‑> None

Clear the interval with the given ID.

def set_timeout(self, callback: Callable, ms: int, *args, **kwargs) ‑> int

Set a timeout that calls the given callback after ms milliseconds, with any given arguments. This timeout is automatically cleared when the Homey instance gets destroyed.

Returns

The ID of the created timout.

def clear_timeout(self, id: int | None) ‑> None

Clear the timeout with the given ID.

def has_permission(self, permission: str) ‑> bool

Get whether the app has the given permission.

def on_cpuwarn(self, f: Callable[[int, int], None]) ‑> Self

This event is fired when the app is using too much CPU. If the app does not behave within a reasonable amount of time, the app is killed.

Args

f
Callback that receives the number of warnings already sent and the maximum number of warnings until the app is killed.
def on_memwarn(self, f: Callable[[int, int], None]) ‑> Self

This event is fired when the app is using too much memory. If the app does not behave within a reasonable amount of time, the app is killed.

Args

f
Callback that receives the number of warnings already sent and the maximum number of warnings until the app is killed.
def on_unload(self, f: Callable[[], None]) ‑> Self

This event is fired when the app is stopped.

Args

f
Callback that receives no arguments.

Inherited members