All Projects → esphome → aioesphomeapi

esphome / aioesphomeapi

Licence: MIT License
Python Client for ESPHome native API. Used by Home Assistant.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to aioesphomeapi

Ha Tts Bluetooth Speaker
TTS Bluetooth Speaker for Home Assistant
Stars: ✭ 140 (+169.23%)
Mutual labels:  home-automation, internet-of-things, home-assistant
Homeassistant
Example Home Assistant Configs
Stars: ✭ 168 (+223.08%)
Mutual labels:  home-automation, internet-of-things, home-assistant
Entity Controller
Entity and lighting controller for managing devices via timers, scripts, and sun-based time restrictions.
Stars: ✭ 156 (+200%)
Mutual labels:  home-automation, internet-of-things, home-assistant
Home Assistant Js Websocket
🚡 JavaScript websocket client for Home Assistant
Stars: ✭ 100 (+92.31%)
Mutual labels:  home-automation, internet-of-things, home-assistant
jarvis
Jarvis Home Automation
Stars: ✭ 81 (+55.77%)
Mutual labels:  home-automation, internet-of-things, home-assistant
Core
🏡 Open source home automation that puts local control and privacy first.
Stars: ✭ 48,265 (+92717.31%)
Mutual labels:  home-automation, internet-of-things, asyncio
automate-home
Yet another python home automation (iot) project. Because a smart light is more than just on or off.
Stars: ✭ 59 (+13.46%)
Mutual labels:  home-automation, internet-of-things, asyncio
Esphome Core
🚨 No longer used 🚨 - The C++ framework behind ESPHome
Stars: ✭ 545 (+948.08%)
Mutual labels:  home-automation, internet-of-things, home-assistant
Netdisco
🔎 Python library to scan local network for services and devices.
Stars: ✭ 240 (+361.54%)
Mutual labels:  home-automation, internet-of-things, home-assistant
Homeassistant Config
Stars: ✭ 211 (+305.77%)
Mutual labels:  home-automation, internet-of-things, home-assistant
Home Assistant Config
🏠 My Home Assistant configuration, a bit different that others :) Be sure to 🌟 this repository for updates!
Stars: ✭ 1,050 (+1919.23%)
Mutual labels:  home-automation, internet-of-things, home-assistant
netdisco
🔎 Python library to scan local network for services and devices.
Stars: ✭ 252 (+384.62%)
Mutual labels:  home-automation, internet-of-things, home-assistant
Homeassistant
Example Home Assistant Configs
Stars: ✭ 846 (+1526.92%)
Mutual labels:  home-automation, internet-of-things, home-assistant
Ha Floorplan
Floorplan for Home Assistant
Stars: ✭ 1,626 (+3026.92%)
Mutual labels:  home-automation, internet-of-things, home-assistant
Home Assistant Config
Home Assistant config files, rewritten to use the latest features, 100+ documented automations, automatically generated ToC 🏠 🤖
Stars: ✭ 926 (+1680.77%)
Mutual labels:  home-automation, internet-of-things, home-assistant
Home assistant files
Here are my Home Assistant configuration files
Stars: ✭ 159 (+205.77%)
Mutual labels:  home-automation, internet-of-things, home-assistant
Awesome Home Assistant
A curated list of amazingly awesome Home Assistant resources.
Stars: ✭ 3,487 (+6605.77%)
Mutual labels:  home-automation, internet-of-things, home-assistant
Home Assistant
Home-Assistant-Config
Stars: ✭ 182 (+250%)
Mutual labels:  home-automation, internet-of-things, home-assistant
hifiberry
This is a custom component to allow control of HifiberryOS devices in Home Assistant using the audiocontrol2 REST API.
Stars: ✭ 26 (-50%)
Mutual labels:  home-automation, internet-of-things, home-assistant
home-assistant-notebooks
📓 Sample Jupyter Notebooks to explore Home Assistant data
Stars: ✭ 49 (-5.77%)
Mutual labels:  home-automation, internet-of-things, home-assistant

aioesphomeapi

aioesphomeapi allows you to interact with devices flashed with ESPHome.

Installation

The module is available from the Python Package Index.

$ pip3 install aioesphomeapi

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].