Skip to main content

Python API for interacting with ESPHome devices.

Project description

aioesphomeapi allows you to interact with devices flashed with ESPHome.

Installation

The module is available from the Python Package Index.

$ pip3 install aioesphomeapi

An optional cython extension is available for better performance, and the module will try to build it automatically.

The extension requires a C compiler and Python development headers. The module will fall back to the pure Python implementation if they are unavailable.

Building the extension can be forcefully disabled by setting the environment variable SKIP_CYTHON to 1.

Usage

It’s required that you enable the Native API component for the device.

# Example configuration entry
api:
  password: 'MyPassword'

Check the output to get the local address of the device or use the name:``under ``esphome: from the device configuration.

[17:56:38][C][api:095]: API Server:
[17:56:38][C][api:096]:   Address: api_test.local:6053

The sample code below will connect to the device and retrieve details.

import aioesphomeapi
import asyncio

async def main():
    """Connect to an ESPHome device and get details."""

    # Establish connection
    api = aioesphomeapi.APIClient("api_test.local", 6053, "MyPassword")
    await api.connect(login=True)

    # Get API version of the device's firmware
    print(api.api_version)

    # Show device details
    device_info = await api.device_info()
    print(device_info)

    # List all entities of the device
    entities = await api.list_entities_services()
    print(entities)

 loop = asyncio.get_event_loop()
 loop.run_until_complete(main())

Subscribe to state changes of an ESPHome device.

import aioesphomeapi
import asyncio

async def main():
    """Connect to an ESPHome device and wait for state changes."""
    cli = aioesphomeapi.APIClient("api_test.local", 6053, "MyPassword")

    await cli.connect(login=True)

    def change_callback(state):
        """Print the state changes of the device.."""
        print(state)

    # Subscribe to the state changes
    await cli.subscribe_states(change_callback)

loop = asyncio.get_event_loop()
try:
    asyncio.ensure_future(main())
    loop.run_forever()
except KeyboardInterrupt:
    pass
finally:
    loop.close()

Other examples:

Development

For development is recommended to use a Python virtual environment (venv).

# Setup virtualenv (optional)
$ python3 -m venv .
$ source bin/activate
# Install aioesphomeapi and development depenencies
$ pip3 install -e .
$ pip3 install -r requirements_test.txt

# Run linters & test
$ script/lint
# Update protobuf _pb2.py definitions (requires a protobuf compiler installation)
$ script/gen-protoc

License

aioesphomeapi is licensed under MIT, for more details check LICENSE.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aioesphomeapi-18.2.6.tar.gz (76.1 kB view details)

Uploaded Source

Built Distributions

aioesphomeapi-18.2.6-cp312-cp312-musllinux_1_1_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.12 musllinux: musl 1.1+ x86-64

aioesphomeapi-18.2.6-cp312-cp312-musllinux_1_1_i686.whl (2.1 MB view details)

Uploaded CPython 3.12 musllinux: musl 1.1+ i686

aioesphomeapi-18.2.6-cp312-cp312-musllinux_1_1_aarch64.whl (2.2 MB view details)

Uploaded CPython 3.12 musllinux: musl 1.1+ ARM64

aioesphomeapi-18.2.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

aioesphomeapi-18.2.6-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.2 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

aioesphomeapi-18.2.6-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (2.1 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

aioesphomeapi-18.2.6-cp311-cp311-musllinux_1_1_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

aioesphomeapi-18.2.6-cp311-cp311-musllinux_1_1_i686.whl (2.1 MB view details)

Uploaded CPython 3.11 musllinux: musl 1.1+ i686

aioesphomeapi-18.2.6-cp311-cp311-musllinux_1_1_aarch64.whl (2.2 MB view details)

Uploaded CPython 3.11 musllinux: musl 1.1+ ARM64

aioesphomeapi-18.2.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

aioesphomeapi-18.2.6-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.2 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

aioesphomeapi-18.2.6-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (2.1 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

aioesphomeapi-18.2.6-cp310-cp310-musllinux_1_1_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

aioesphomeapi-18.2.6-cp310-cp310-musllinux_1_1_i686.whl (1.9 MB view details)

Uploaded CPython 3.10 musllinux: musl 1.1+ i686

aioesphomeapi-18.2.6-cp310-cp310-musllinux_1_1_aarch64.whl (2.0 MB view details)

Uploaded CPython 3.10 musllinux: musl 1.1+ ARM64

aioesphomeapi-18.2.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

aioesphomeapi-18.2.6-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.0 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

aioesphomeapi-18.2.6-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (1.9 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

aioesphomeapi-18.2.6-cp39-cp39-musllinux_1_1_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

aioesphomeapi-18.2.6-cp39-cp39-musllinux_1_1_i686.whl (1.9 MB view details)

Uploaded CPython 3.9 musllinux: musl 1.1+ i686

aioesphomeapi-18.2.6-cp39-cp39-musllinux_1_1_aarch64.whl (2.0 MB view details)

Uploaded CPython 3.9 musllinux: musl 1.1+ ARM64

aioesphomeapi-18.2.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

aioesphomeapi-18.2.6-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.0 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

aioesphomeapi-18.2.6-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (1.9 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

File details

Details for the file aioesphomeapi-18.2.6.tar.gz.

File metadata

  • Download URL: aioesphomeapi-18.2.6.tar.gz
  • Upload date:
  • Size: 76.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for aioesphomeapi-18.2.6.tar.gz
Algorithm Hash digest
SHA256 4c36a780adcc7b8d5c959025424e8a7bb44b88074387415bd94489dce255fda5
MD5 be91df67bfcb0f529333a8b5eab825da
BLAKE2b-256 38a7f1d2702cf2e72d22ba0fd14455b1a7bc4a7ab5313e0495abf331fbeef7b4

See more details on using hashes here.

File details

Details for the file aioesphomeapi-18.2.6-cp312-cp312-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for aioesphomeapi-18.2.6-cp312-cp312-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 5c318eac77dc11af53380cf7a8e04e258c009eaf4ad3ecf53e86f477798a35e6
MD5 f1d6fa7c36427eeb1d6c34d0e84b0659
BLAKE2b-256 adba02286102fa49829577e7646fea35e06028577f417331ba0aeb5d6779481a

See more details on using hashes here.

File details

Details for the file aioesphomeapi-18.2.6-cp312-cp312-musllinux_1_1_i686.whl.

File metadata

File hashes

Hashes for aioesphomeapi-18.2.6-cp312-cp312-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 446b0f968b986f9490d77b0d927969b4fe2049fb57441c58bd1eeb5b4d54f93c
MD5 fbeaa4273b688a030d4dcfb0bf867db7
BLAKE2b-256 a2b0b9c5679c6228284984163f8b3e0358c330b3a4ca4e80a575b4c871b32796

See more details on using hashes here.

File details

Details for the file aioesphomeapi-18.2.6-cp312-cp312-musllinux_1_1_aarch64.whl.

File metadata

File hashes

Hashes for aioesphomeapi-18.2.6-cp312-cp312-musllinux_1_1_aarch64.whl
Algorithm Hash digest
SHA256 17b5a4c7c3aa80e329d8f4077ecf18915e87ef0a0557e2682e1a54c3c7eb424d
MD5 d1560a3a4968cb80007bafa1cddeb0a1
BLAKE2b-256 7233bdb0c95a3de28a33e587f6b11f17ab5a8a3324c744afa4e1a932aa5696d1

See more details on using hashes here.

File details

Details for the file aioesphomeapi-18.2.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for aioesphomeapi-18.2.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 948f8ce8573a7a2199ee92baa578fdafe3585fb1a94021a13f226a6de91ffb39
MD5 f281101dcda3985f3c2a258b0d22d1ba
BLAKE2b-256 a08f3452c180b37f6bd29944ff180132bd601669f17fbe637a174f83f5955b2e

See more details on using hashes here.

File details

Details for the file aioesphomeapi-18.2.6-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for aioesphomeapi-18.2.6-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7e0c11981fdd83f2767549ae17bbba07f6951e3f04dc1d4d1e1533f7766b8525
MD5 8343866fd365e0cf9b1a7baacd4afe72
BLAKE2b-256 e425273fa228c0104fd346a62eb145e184cca890db25a796cf7cc9930e8ade82

See more details on using hashes here.

File details

Details for the file aioesphomeapi-18.2.6-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for aioesphomeapi-18.2.6-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 c329f79dfa5d55c6b75d70851097ccb8fdb5c83fcafc3cf33dedce5b6803a082
MD5 03d3d531184a3f448a9a701bc63ab228
BLAKE2b-256 416d49060e721b110f55677694bcc0e1568d668add461b2ff6555756a23ac1d4

See more details on using hashes here.

File details

Details for the file aioesphomeapi-18.2.6-cp311-cp311-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for aioesphomeapi-18.2.6-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 d7c1d0552ff2e4c746fef8eca518f7e5515d5cf1779e7e85ef8b2f543ec1f4b0
MD5 dc49ec28cfd5aeafc4f252b2ab80f187
BLAKE2b-256 225fdc887952df921af629088a1ad457c3c652844496506a19a50d3232e0ae45

See more details on using hashes here.

File details

Details for the file aioesphomeapi-18.2.6-cp311-cp311-musllinux_1_1_i686.whl.

File metadata

File hashes

Hashes for aioesphomeapi-18.2.6-cp311-cp311-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 0a7cb929d8da3f21da30057d65b7a5f7bda950595f6ce0e0e92528e9b42d6238
MD5 eb503edc39b75d5fc97bcb9bee1fbdba
BLAKE2b-256 0d7ca61ad06adc1de5b44178c460dde4f009efbf212c86d6ba810a2280664c46

See more details on using hashes here.

File details

Details for the file aioesphomeapi-18.2.6-cp311-cp311-musllinux_1_1_aarch64.whl.

File metadata

File hashes

Hashes for aioesphomeapi-18.2.6-cp311-cp311-musllinux_1_1_aarch64.whl
Algorithm Hash digest
SHA256 0345f98808053a3db199fafa3eb028d10738a9a72abdcaf8d1fcde18985c3512
MD5 6de1ca1fccb9625b0e46072c0ca1ed0b
BLAKE2b-256 8b83d207e656b97694f1ea91046209524878905876cbdba3be5f25987da64607

See more details on using hashes here.

File details

Details for the file aioesphomeapi-18.2.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for aioesphomeapi-18.2.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a4d7371aa15aed7a3885849e034e53444fe0a2317837ee88510607f5b4cd64fd
MD5 0688dad7ac66046dead34f89ffd2ee9d
BLAKE2b-256 50b0a14d240679ad370efc004abf20e16651e2c07932fc4a77a33c642f70761f

See more details on using hashes here.

File details

Details for the file aioesphomeapi-18.2.6-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for aioesphomeapi-18.2.6-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ccf1b8c358aa61ae088ec2a2ef4e0846140d0328631f426670c72aaae6580c3b
MD5 c6e8cdde279c251bacab2c042c097b56
BLAKE2b-256 f716f6be1c1e65d0a70206ddd0637004ccf2e4a35c7455febc7825ca5c968a7c

See more details on using hashes here.

File details

Details for the file aioesphomeapi-18.2.6-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for aioesphomeapi-18.2.6-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 42a58ebff26ec198e98204956afe1555f02ccd37393d6450f997a2367e642c59
MD5 c77c58c04c438fc991b3a78a514078ed
BLAKE2b-256 49681ce45cf351b9ea7335bb761d995d291be533ce6229bf890e194073ece8db

See more details on using hashes here.

File details

Details for the file aioesphomeapi-18.2.6-cp310-cp310-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for aioesphomeapi-18.2.6-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 0868738bfa4dfdc74afdacfa85fb1abe1db146bf279d16e0ac38da29818fa851
MD5 ea6cff4c0d3e4a76d4ba45e1c2a49d58
BLAKE2b-256 84c0c10ca322d262e3826f02b20c453e319d0ce0bb9bea98f2374328002a1692

See more details on using hashes here.

File details

Details for the file aioesphomeapi-18.2.6-cp310-cp310-musllinux_1_1_i686.whl.

File metadata

File hashes

Hashes for aioesphomeapi-18.2.6-cp310-cp310-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 260287284ed91169d70a041b80f0c379dd7fdd4d2e052cdc105e871c245ca69d
MD5 ca404422df4d223604fdf165b2a786b5
BLAKE2b-256 1fb3c69f6c74f93188e081310bcb284a631f78bd231471e825eed871c38ce656

See more details on using hashes here.

File details

Details for the file aioesphomeapi-18.2.6-cp310-cp310-musllinux_1_1_aarch64.whl.

File metadata

File hashes

Hashes for aioesphomeapi-18.2.6-cp310-cp310-musllinux_1_1_aarch64.whl
Algorithm Hash digest
SHA256 946fb4ef1bd013f946ce17e79bf9bb37bfd287d4aec4de4ce8628728a4897b6c
MD5 30ccc8be870739ffe0ffae424a9edda7
BLAKE2b-256 916357e2a198ed18dbe4a7df4b95f5a1735128ff5114d6e318312fd6015037c2

See more details on using hashes here.

File details

Details for the file aioesphomeapi-18.2.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for aioesphomeapi-18.2.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 25da9b262a87603d8ea4d3b863745628a95455094ec36ad54f9aa6d0c05eaef1
MD5 061b303b580d5fe2138756c81e48e80b
BLAKE2b-256 08831f73d4cc61927c71af6f1f3755cbb1c9c62c55d490bfb85e16d57f179434

See more details on using hashes here.

File details

Details for the file aioesphomeapi-18.2.6-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for aioesphomeapi-18.2.6-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 569458468e48f795293dced5672470721073e04c57b5d6847659a5df18c8342f
MD5 d2ab0da5c52f3f8fc5dbedcc6b97020f
BLAKE2b-256 58bb690e8bb70dc36f099e0b0a742b06b55664ea9f5234ce254a303670a01e37

See more details on using hashes here.

File details

Details for the file aioesphomeapi-18.2.6-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for aioesphomeapi-18.2.6-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 879be727cf4353390874b8eeceab9bd91b7cca38bdc2fb5e0f618ab2aed1464f
MD5 02ba34a8d2d8ff6cbb19eef6adaaafb4
BLAKE2b-256 abb60fc3573837dd14c1c26f103ec4551467a2f63438f71ae8668eb359cfb790

See more details on using hashes here.

File details

Details for the file aioesphomeapi-18.2.6-cp39-cp39-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for aioesphomeapi-18.2.6-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 299aa476c5874e3a9c586da00167fb6df896fad92eb814431d2e4fb9ba4af00c
MD5 ab0bb859a30986593460c179e0236575
BLAKE2b-256 f22f7f7da920b0b8005e2a60808c5044ac4f4214a15059ddf141577c267c4052

See more details on using hashes here.

File details

Details for the file aioesphomeapi-18.2.6-cp39-cp39-musllinux_1_1_i686.whl.

File metadata

File hashes

Hashes for aioesphomeapi-18.2.6-cp39-cp39-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 2d78f3f948faff4eb0a129ecde1f770a2fd385b229f843706aaf0549cbd57482
MD5 f237ced625d3af0e7955d0d2e610810a
BLAKE2b-256 ffb14814aa65e9afd99a78c4c23cc4ab5d0c121519fe355dc43e6af1bcde37e4

See more details on using hashes here.

File details

Details for the file aioesphomeapi-18.2.6-cp39-cp39-musllinux_1_1_aarch64.whl.

File metadata

File hashes

Hashes for aioesphomeapi-18.2.6-cp39-cp39-musllinux_1_1_aarch64.whl
Algorithm Hash digest
SHA256 09727d02443ccfb0ff10adee4ce3607c5b811953d2409ead55433bdb1e0197fa
MD5 40cd85eea503d97516e80a3c4c291b0e
BLAKE2b-256 12897e640a2e529d96ed1089a1acd275515aedbf9c01c5bbad851431be31f30b

See more details on using hashes here.

File details

Details for the file aioesphomeapi-18.2.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for aioesphomeapi-18.2.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0b7ab4ce267571331fab7933d905b3706af9b037de909736dc85d72e1ccd2f93
MD5 9d7c76e5de6d5f9669a44196b4d18d23
BLAKE2b-256 d4f946cc827e08b04830813489c6f1d5c2352ee9bd0c3bfce8b0b9da6f9c9d50

See more details on using hashes here.

File details

Details for the file aioesphomeapi-18.2.6-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for aioesphomeapi-18.2.6-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 73011306219e8eb66f4835066c535221224633c2d1e2a3ae124e7a73ae27f7a1
MD5 2170411e65c3eca676a63748ac3f2b6d
BLAKE2b-256 c47fd2399b047ea02c97f82b91fd4f9e7a2a63a8e9a87321bec33003362d3725

See more details on using hashes here.

File details

Details for the file aioesphomeapi-18.2.6-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for aioesphomeapi-18.2.6-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 b4c78fbcacdb249677790ee56eea604ec916c461565503df65c8ec2780cfa1eb
MD5 9ab339d557ad71b70f114df8e7eb5c50
BLAKE2b-256 9026d3ed868cc844c2d9f95d2732e4bc98409b0433f77e8a65c91c51e7bbf91f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page