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-17.1.3.tar.gz (383.2 kB view details)

Uploaded Source

Built Distributions

aioesphomeapi-17.1.3-pp310-pypy310_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (552.3 kB view details)

Uploaded PyPy manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

aioesphomeapi-17.1.3-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (560.8 kB view details)

Uploaded PyPy manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

aioesphomeapi-17.1.3-pp39-pypy39_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (552.3 kB view details)

Uploaded PyPy manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

aioesphomeapi-17.1.3-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (560.7 kB view details)

Uploaded PyPy manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

aioesphomeapi-17.1.3-cp312-cp312-musllinux_1_1_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.12 musllinux: musl 1.1+ x86-64

aioesphomeapi-17.1.3-cp312-cp312-musllinux_1_1_i686.whl (1.5 MB view details)

Uploaded CPython 3.12 musllinux: musl 1.1+ i686

aioesphomeapi-17.1.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

aioesphomeapi-17.1.3-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (1.5 MB view details)

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

aioesphomeapi-17.1.3-cp311-cp311-musllinux_1_1_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

aioesphomeapi-17.1.3-cp311-cp311-musllinux_1_1_i686.whl (1.5 MB view details)

Uploaded CPython 3.11 musllinux: musl 1.1+ i686

aioesphomeapi-17.1.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

aioesphomeapi-17.1.3-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (1.5 MB view details)

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

aioesphomeapi-17.1.3-cp310-cp310-musllinux_1_1_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

aioesphomeapi-17.1.3-cp310-cp310-musllinux_1_1_i686.whl (1.4 MB view details)

Uploaded CPython 3.10 musllinux: musl 1.1+ i686

aioesphomeapi-17.1.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

aioesphomeapi-17.1.3-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (1.4 MB view details)

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

aioesphomeapi-17.1.3-cp39-cp39-musllinux_1_1_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

aioesphomeapi-17.1.3-cp39-cp39-musllinux_1_1_i686.whl (1.4 MB view details)

Uploaded CPython 3.9 musllinux: musl 1.1+ i686

aioesphomeapi-17.1.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

aioesphomeapi-17.1.3-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (1.4 MB view details)

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

File details

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

File metadata

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

File hashes

Hashes for aioesphomeapi-17.1.3.tar.gz
Algorithm Hash digest
SHA256 27298e14d914a6d121fa1101d9d9bd68d1c6148789984b80ca2d4682e1828d0c
MD5 67213743d82cf2059922f6a20e4c62d7
BLAKE2b-256 839f0905a1b7b3959128689ec15cad267edec6ee751125c6e67ebd486ea921f3

See more details on using hashes here.

File details

Details for the file aioesphomeapi-17.1.3-pp310-pypy310_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for aioesphomeapi-17.1.3-pp310-pypy310_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 47f88ae1a2531ff9faf17f346e378d80f9362cf12f3f19d4f2d9928b3968ac45
MD5 08d8df5a927d396c8e36a9866d9aebe4
BLAKE2b-256 55d8545cafd18c2956c8ec2c2ffebe6098458447c579637281bc5e4edc590388

See more details on using hashes here.

File details

Details for the file aioesphomeapi-17.1.3-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for aioesphomeapi-17.1.3-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 b0d46d50504c81247d0871f1cda2c32e5eefa015d33ccc28750c046e4c01ef03
MD5 65aeea51720dc985e728b3dc49895936
BLAKE2b-256 f09d1a4ec46e5c6a1ba1b2bf13261cb18732d30171fd43a982b4935b66d29e7a

See more details on using hashes here.

File details

Details for the file aioesphomeapi-17.1.3-pp39-pypy39_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for aioesphomeapi-17.1.3-pp39-pypy39_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 277c0ad882f8ad5bfd66354a4cc2159a5e9b3bd38e922ba1dd70b3e532b4c4f9
MD5 9b2cc60ecd930aec6a9fdf23a1e416db
BLAKE2b-256 5bcc37e23c989cc74604b63be2f294241d66bedfb4177188609d90f6fa61d47f

See more details on using hashes here.

File details

Details for the file aioesphomeapi-17.1.3-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for aioesphomeapi-17.1.3-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 70a85df41eab1a7a76f281157693c020e5fea68fcd659c906e626a2e8f52f4c4
MD5 88e20b6c5b8d6594f6ed665b7e244950
BLAKE2b-256 18988f692a8666107a2e1c29046f9dd31913fd5027853788fa3e7faa35fecc74

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aioesphomeapi-17.1.3-cp312-cp312-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 51a842e2d6c9ba46d7b1b137cf079fc73d8c1a5bb8d2702fe3ccf396b8324668
MD5 0140e66b8f6bb2caa3b4b37257a5ea84
BLAKE2b-256 9a3576451012b2827d7f6c6e7b7c68cf17356f0311080a5995b18fce1ab649ba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aioesphomeapi-17.1.3-cp312-cp312-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 a655f15c03f84802355ab66484aff408e24121f13d44b3a1e7d5e54d552fa5b6
MD5 2446c4a7e90b8ff8df08197f0d30f53c
BLAKE2b-256 75aa2bd323786b5514a80e75d138035006b27e1fda9b73ac9b3920a7fab9b2f2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aioesphomeapi-17.1.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 71aa600f4eacf8ed5f229461555098fe8947349020a3634f7e3394576d21f00b
MD5 fa1c1854fe0f72e9eed2850534ad02d9
BLAKE2b-256 824f2ac46212c80840bf4e154222c566788b544de717564c3673c9f254d83775

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aioesphomeapi-17.1.3-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 c16e1fd54c004366455426cd2bbfee5467bc662f412d3c3a0743abdb2d8e6d14
MD5 7e51bdb0fa6893cd1d1fcbcb8c72ad37
BLAKE2b-256 c5e1dfaa774f70ddda43122f83bb071bbcaaf3ea482f7cada44929d4567f962f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aioesphomeapi-17.1.3-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 ce97353a52c750c2dedda73966f7f9f41a59d20789e9782861176dcfe42783e0
MD5 9b411897239baf285efae3eb6d0be69e
BLAKE2b-256 51945835bf5df919513b5dcb9c4d516e5fd1070ea390111e818e9c1548398781

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aioesphomeapi-17.1.3-cp311-cp311-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 0646497f2478aa607a2cfd68f636bf4928b7390b7d4cf70f7e82d6bb9c77d4d0
MD5 d2cb31d64269704ad535c2336c80a23e
BLAKE2b-256 8433084fedbadaf327231ea06a9c5da4ef7e5862a56463c19d4f40b332e7dfd9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aioesphomeapi-17.1.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5fb3e436fa36a40b8097084ca6a788997d5983789476a78a5d2a4c85a027ad5c
MD5 5513b090b3e9393f27a994bfd7b9f932
BLAKE2b-256 69a222df74d5a3b935bbd7bd47699467a1c83ac6161bafcccfd47570c64e1ac5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aioesphomeapi-17.1.3-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 4cbb865a1f2c405b7f7d5dd12db2767a595dadb66d3e82b5dca68287d72f0071
MD5 aa94db3359d453ac9a8b484a7acfa651
BLAKE2b-256 ea01b94deb11368ba0df424035b986e83e2f36bb9cdf7d25945e779fc97fcfd6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aioesphomeapi-17.1.3-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 f46cfc3c0f9ffdaa0ac4069316bf5bc1255266b72c97a2e67e6a8728ed14f0f0
MD5 3786ef652e7e7464464c3618cf69c69e
BLAKE2b-256 7a2b76ffd1ac10a7cc3234274c48552e6da8d1b33914c5fbd752fdb3847eeb66

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aioesphomeapi-17.1.3-cp310-cp310-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 b960bd55d48b6def92962b124055ae34fc287ef798862bb5b63941233c1949b8
MD5 c71df45fb280fde500377192b475d14f
BLAKE2b-256 383c9e5f1c478a0bca13bd2888a34f86dfa8fe5fe3b98057b1476e4b37b63433

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aioesphomeapi-17.1.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 61ab4a651a66b78b19ed72975059a7708c7a0ab7e3bbe2803fb08e651a957bc3
MD5 e8b4bceef515b0cfa16b59954b14b53a
BLAKE2b-256 2b5d964b5027fa9b07c7a5a926bb94e9377833c8de0d66bba399c156db087623

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aioesphomeapi-17.1.3-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 690e1cddd93ae7c88bbfb1f5e1456607b585f1372d73efc9c19a31268f6a3bbf
MD5 03570646cd930e8147f8a8bd08e6d6ae
BLAKE2b-256 4c3810de999cec657690368e3e34595456e07c6e21224ea903fe4e580a56c9f8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aioesphomeapi-17.1.3-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 8507bd74f5333ccee7969d07c679ed4ad166123ee96fe41771477808664aea0d
MD5 ec009081882ae82e5f91146ec5ad2303
BLAKE2b-256 108c9c3b685edfb189b1c47c4679161bc051d249cdef259aa975b2b3e782c97d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aioesphomeapi-17.1.3-cp39-cp39-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 9ba712f1b52be9ae24f43ea5fd5d33c0705eda5d402b5ab0c7fb4498c38c8880
MD5 d7addd158cca5fcd3fda59589a0b0ede
BLAKE2b-256 0fcfffde8faa5b0104de1f26eb4590f728c53991d0e2b05224ef78816ce32c0f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aioesphomeapi-17.1.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a0e63ff06573e3cc58969afef821755db7a8e90324ca95f4b462aab0d828ad64
MD5 c64488eec8d5a0aa1ed23a02002694c1
BLAKE2b-256 e6304d47333f107eaf713f109255713131b01763ec58889eb334b5f14dc2014a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aioesphomeapi-17.1.3-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 054254705aa26ea9a14b85841f1ecaf4bcde27efd546bc3e86ec232cd92d50da
MD5 d176eedcc4229b866f251bcc5e30d17b
BLAKE2b-256 c0ad51624a39d6bd78a774a0a822a16780093109a7fc2e980f4e3ff9a8a41f21

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