Skip to main content

Homey ESPHomeDriver

PyPI version PyPI downloads Python CI License: MIT Ruff Status Homey

This module can be used to make the development of ESPHome apps for Homey easier.

It is essentially a map-tool from Homey-capabilities to ESPHome entities.

This module requires Homey Apps SDK v3.

Installation

$ pip install homey-esphomedriver

Homey apps declare it next to aioesphomeapi in app.json / .homeycompose/app.json:

"pythonPackages": ["aioesphomeapi", "homey-esphomedriver"]

Also checkout [aioesphomeapi](https://github.com/esphome/aioesphomeapi) if you want to talk to the ESPHome Native API directly, without homey-esphomedriver.

$ pip install aioesphomeapi

Changelog

See CHANGELOG.md.

Requirements

This module requires Homey Apps SDK v3 (Python 3.14 runtime).

Usage

Your device should extend EspHomeDevice. This is the class you most likely want to extend from. Your driver should extend EspHomeDriver.

Like Z-Wave and Zigbee drivers, a driver declares its capabilities in driver.compose.json, and the device binds each one to an ESPHome entity in on_esphome_init. The library knows how to read and set Homey's system capabilities on each ESPHome domain; anything else is your own code.

Driver compose

{
  "name": { "en": "AQ-1" },
  "class": "sensor",
  "capabilities": ["measure_temperature", "measure_co2", "onoff.led", "dim.led", "button.calibrate"],
  "capabilitiesOptions": {
    "onoff.led": { "title": { "en": "Status LED" } },
    "dim.led": { "title": { "en": "Status LED brightness" } },
    "button.calibrate": {
      "maintenanceAction": true,
      "title": { "en": "Calibrate CO₂" },
      "desc": { "en": "Place the sensor outside for 10 minutes first" }
    }
  },
  "$extends": ["esphome-defaults"],
  "esphome": {
    "clientInfo": "Homey EverythingSmart",
    "projects": ["EverythingSmart.AQ-1"]
  }
}
esphome key Purpose
projects ESPHome project.name this driver accepts; Brand.* matches by prefix
clientInfo Name shown on the node for this Homey client
nativeApps Suggest a dedicated Homey app for a project (io.esphome only)

Omit projects to accept every project (io.esphome). Only a trailing * matches by prefix; anywhere else it is part of the name. Any other key is logged and ignored.

A button for a rare or risky task, such as a calibration, goes in the device's Maintenance menu with Homey's own maintenanceAction capability option, as above.

Device

# drivers/aq-1/device.py
from homey_esphomedriver import EspHomeDevice


class Aq1Device(EspHomeDevice):
    async def on_esphome_init(self, client):
        self.register_capability("measure_temperature", "sensor", "Temperature")
        self.register_capability("measure_co2", "sensor", "CO2")
        self.register_capability("onoff.led", "light", "Status LED")
        self.register_capability("dim.led", "light", "Status LED")
        self.register_capability("button.calibrate", "button", "Calibrate CO2")


homey_export = Aq1Device

register_capability(capability_id, domain, name, *, device_id=0, set_parser=None, report_parser=None) follows Z-Wave's registerCapability:

  • The capability must already be on the device; registering never adds one. A missing capability raises ValueError.
  • An entity is named by its ESPHome domain and its name, as written in the YAML, plus device_id for a sub-device. object_id is not used: ESPHome plans to remove it.
  • System capabilities supply the parsers, looked up by the full id and then its base, as Z-Wave splits on the dot: dim.led uses dim.
  • sensor, binary_sensor, text_sensor, number, select, switch, text, button and event entities bind to any capability without a parser, including your own. A sensor's reading is converted from the entity's unit to the capability's (°F to °C, kW to W, …).
  • sensor, binary_sensor, text_sensor and event entities only report, so they do not bind to a Homey capability the user can set, such as onoff, locked or target_temperature, without a parser. Homey would show a control that cannot work.
  • On other domains, a capability the library does not know raises ValueError unless you pass a parser.
  • Bindings are made again on every app start and resolved on every connection, before the state dump. An entity the node does not have is logged and its capability left alone; setting it fails with a message.
System capabilities Domain
homealarm_state, alarm_generic alarm_control_panel
any alarm_*, battery_charging_state binary_sensor
onoff, thermostat_mode, measure_temperature, target_temperature, target_temperature_min, target_temperature_max, measure_humidity, target_humidity, fan_mode, swing_mode climate
windowcoverings_state, windowcoverings_set, windowcoverings_tilt_set, windowcoverings_tilt_up, windowcoverings_tilt_down, windowcoverings_closed, garagedoor_closed cover
onoff, fan_speed, oscillating, fan_mode fan
onoff, dim, light_mode, light_hue, light_saturation, light_temperature light
locked, alarm_door_fault lock
onoff, speaker_playing, speaker_stop, volume_set, volume_mute, volume_up, volume_down media_player
onoff, volume_set siren
onoff, valve_position valve
onoff, heater_operation_mode, measure_temperature, target_temperature, target_temperature_min, target_temperature_max water_heater

light_hue and light_saturation are sent together in one command once both are bound to the same light, as ZwaveLightDevice does.

CAPABILITIES.md has how each capability maps, the sensor unit conversions and what is not supported.

Parsers

Pass a parser to change how a value is read or set, or for an app capability on a multi-value domain:

self.register_capability(
    "aq1_air_quality",
    "sensor",
    "VOC Index",
    report_parser=lambda state, entity: "poor" if state.state > 150 else "good",
)
self.register_capability(
    "onoff.led",
    "light",
    "Status LED",
    set_parser=lambda value, opts, entity: {"state": value, "effect": "Pulse"},
)
  • report_parser(state, entity) turns the ESPHome state into the capability value. None leaves the capability as is. A missing reading, NaN or Infinity is written as unknown before the parser runs.
  • set_parser(value, opts, entity) returns the keyword arguments for the domain's command, here light_command. None sends nothing; an exception is shown to the user.
  • entity is the bound entity: entity.info is what the node listed (unit, color temperature range, speed count, …) and entity.capability_value("light_hue") reads a sibling capability.

Everything else

What no capability shows is your own code, like Z-Wave's registerReportListener:

class Aq1Device(EspHomeDevice):
    async def on_esphome_init(self, client):
        self.register_state_listener("event", "Button", self._on_button)

    async def _on_button(self, state, entity):
        card = self.homey.flow.get_device_trigger_card("aq1_button_pressed")
        await card.trigger(self, {"type": state.event_type})

self.entity(domain, name) gives the entity of the current connection, to send it a command yourself through self.client.command("<domain>_command", entity.key, ...). unregister_capability(capability_id) stops reporting and setting a capability you remove at runtime.

Driver

# drivers/aq-1/driver.py
from homey_esphomedriver import EspHomeDriver

homey_export = EspHomeDriver

A new device gets the driver's capabilities. To choose them from what the node has, as the generic ESPHome app does, override on_pair_device(device, device_info, entities) and set capabilities, capabilitiesOptions or class on the payload it returns.

Settings

esphome-defaults brings the device information settings, which the library writes. A driver that declares its own settings replaces that list (Homey Compose does not merge it), so it keeps the group through its setting template and adds its own around it:

"settings": [
  { "type": "group", "label": { "en": "Calibration" }, "children": [ ... ] },
  { "$extends": "esphome-device-information" }
]

A driver that leaves it out fails on init with an error naming the $extends to add.

Settings backed by an entity

A configuration entity, such as a calibration offset, can be shown on the device's settings page instead of the device tile. Link the setting to the entity with an esphome object on the setting, the way Z-Wave drivers use zwave:

"settings": [
  {
    "type": "group",
    "label": { "en": "Calibration" },
    "children": [
      {
        "id": "temp_offset",
        "type": "number",
        "label": { "en": "Temperature offset" },
        "value": 0, "min": -5, "max": 5, "step": 0.1,
        "units": { "en": "°C" },
        "esphome": { "domain": "number", "name": "Temperature offset" }
      }
    ]
  },
  { "$extends": "esphome-device-information" }
]
Setting type ESPHome domain
number number
dropdown select
checkbox switch

domain follows from the setting type and may be left out; add device_id for an entity on a sub-device.

  • The node is the truth for the value: what it reports, including changes from Home Assistant or the web server, is copied into the setting. Pairing never pushes the setting's default.
  • Saving the setting writes the entity. An invalid value, or a node that is offline and not a deep-sleep node, rejects the save. A setting whose entity the node lacks saves in Homey only.
  • A deep-sleep node that is asleep gets the write when it next wakes, and the user sees a message saying so.

To convert values, for example to scale units or to map dropdown ids to select options, register converters per setting from on_esphome_init, the way Z-Wave drivers call registerSetting from onNodeInit:

# drivers/aq-1/device.py
from homey_esphomedriver import EspHomeDevice

MODES = {"0": "eco", "1": "boost"}


class Aq1Device(EspHomeDevice):
    async def on_esphome_init(self, client):
        self.register_setting(
            "mode",
            to_entity=MODES.__getitem__,
            to_setting={option: key for key, option in MODES.items()}.__getitem__,
        )


homey_export = Aq1Device

A setting without converters passes values through. Registering a setting that is not linked raises ValueError. The API session starts after on_esphome_init returns, so the converters also apply to the connect dump and to writes queued while a deep-sleep node slept.

Lifecycle hooks

Core owns on_init and on_uninit on EspHomeDriver and EspHomeDevice. Subclass the hooks below instead — same pattern as homey-oauth2app's onOAuth2Init. Brand app.py exports Homey's App.

Class Override When
EspHomeDriver on_esphome_init / on_esphome_uninit After the manifest check, e.g. to register Flow cards / before teardown
EspHomeDriver on_pair_device(device, device_info, entities) Before Homey creates a paired device
EspHomeDevice on_esphome_init(client) / on_esphome_uninit Before the session starts; client is None when host is unknown
EspHomeDevice on_esphome_connected(client) After each login + set_available; session not READY yet — no cmds
EspHomeDevice on_esphome_ready(client) Once the session accepts commands, after each login

On a paired device, use self.client for the live EspHomeClient (may exist before the API handshake). Commands require a READY session — including from on_esphome_connected.

Debug logging uses env.json DEBUG; there is no separate class flag.

Homey Compose files

Homey Compose runs before Python, so $extends / $template only see files already in the app. When homey-esphomedriver is listed in pythonPackages, Homey CLI copies this package's templates into .homeycompose/ during preprocess (homey app run, build, validate), before compose. That is what makes "$extends": ["esphome-defaults"] and pair "$template": "enter_key" resolve.

Until that CLI is released, or when the package is unpublished, run the same copy by hand:

$ esphome-homey sync

-p / --path selects an app directory other than the current one. sync leaves app.json, app.py, driver.compose.json, and existing driver code alone unless --force.

A brand app is a normal Homey Python app. Add one driver per product with esphome-homey driver:

$ homey app create
$ homey app dependencies add aioesphomeapi homey-esphomedriver
$ esphome-homey driver aq-1 --project EverythingSmart.AQ-1 --name "AQ-1" --class sensor

driver syncs, then writes drivers/aq-1/ with a driver.compose.json that extends esphome-defaults and accepts that project, and a device.py that binds one example capability in on_esphome_init. Replace the example with the product's capabilities, add store images, and publish with Homey CLI. --project defaults to <App name>.<DRIVER-ID>; existing driver files are left alone unless --force.

Documentation

See ARCHITECTURE.md for what devices get from Homey and how a brand listing is an esphome compose block on top of this core.

  • [esphome-homey](https://github.com/Doekse/esphome-homey) — generic Homey app (io.esphome; any ESPHome node)

License

MIT. See LICENSE.

Metadata

Release files for homey-esphomedriver 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for homey-esphomedriver 0.6.0
File Size Uploaded Provenance Actions
homey_esphomedriver-0.6.0.tar.gz 127.9 kB With provenance Details for homey_esphomedriver-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for homey-esphomedriver 0.6.0
File Interpreter ABI Platform Actions
homey_esphomedriver-0.6.0-py3-none-any.whl Python 3 none any Details for homey_esphomedriver-0.6.0-py3-none-any.whl

Total release size: 256.3 kB

Release files / homey_esphomedriver-0.6.0.tar.gz

Download URL homey_esphomedriver-0.6.0.tar.gz
Size 127.9 kB
Tags Source
SHA-256 checksum
How to use checksums
5499edf824254767679e24ffcac8b48113506b0f0bb6a01e0604929139c5433f
BLAKE2b-256 checksum
How to use checksums
e7d98986a6d864848ac3652270053c875b8e4fc4500341d45a0074a09a5f04dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Release files / homey_esphomedriver-0.6.0-py3-none-any.whl

Download URL homey_esphomedriver-0.6.0-py3-none-any.whl
Size 128.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
356648972797c83865684b023779b0001de873f7a00ef0972ded11177c08be43
BLAKE2b-256 checksum
How to use checksums
316cfccdb3858e66ef26074ac18b8afdfac674c62d8ad0fe06a53624cc39f3a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Security for homey-esphomedriver 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for homey_esphomedriver-0.6.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page