Homey

homey.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

  • SimpleClass
  • homey.util.event_emitter.EventEmitter
  • typing.Generic

Instance variables

api

var api : Final[ManagerApi]

apps

var apps : Final[ManagerApps]

arp

var arp : Final[ManagerArp]

ble

var ble : Final[ManagerBLE]

clock

var clock : Final[ManagerClock]

cloud

var cloud : Final[ManagerCloud]

dashboards

var dashboards : Final[ManagerDashboards]

discovery

var discovery : Final[ManagerDiscovery]

drivers

var drivers : Final[ManagerDrivers]

flow

var flow : Final[ManagerFlow]

geolocation

var geolocation : Final[ManagerGeolocation]

i18n

var i18n : Final[ManagerI18n]

images

var images : Final[ManagerImages]

insights

var insights : Final[ManagerInsights]

notifications

var notifications : Final[ManagerNotifications]

rf

var rf : Final[ManagerRF]

settings

var settings : Final[ManagerSettings]

videos

var videos : Final[ManagerVideos]

zigbee

var zigbee : Final[ManagerZigbee]

zwave

var zwave : Final[ManagerZWave]

app

var app : Final[App]

This app.

manifest

var manifest : Final[Any]

The app manifest from app.json.

platform

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

The platform that the Homey is running on.

platform_version

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

The platform version the Homey is running on.

version

var version : Final[str]

The type of the None singleton.

env

var env : Final[dict]

The environment variables from env.json.

Methods

ready

async def ready(self) ‑> None

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

translate

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

NameTypeDescription
key str The key in the <language.json> file, with dots separating nesting. For example "errors.missing".
tags str 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.

set_interval

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.

clear_interval

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

Clear the interval with the given ID.

set_timeout

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.

clear_timeout

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

Clear the timeout with the given ID.

has_permission

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

Get whether the app has the given permission.

on_cpuwarn

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

NameTypeDescription
f Callable[[int, int], None] Callback that receives the number of warnings already sent and the maximum number of warnings until the app is killed.

on_memwarn

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

NameTypeDescription
f Callable[[int, int], None] Callback that receives the number of warnings already sent and the maximum number of warnings until the app is killed.

on_unload

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

This event is fired when the app is stopped.

Args

NameTypeDescription
f Callable[[], None] Callback that receives no arguments.

Inherited members