Philips Hue lamp emulation for Amazon Echo
Project description
Alexa-Echo-Hue
Amazon alexa echo hue lamp emulation for python
Thanks to falk0069 and IcynatorHD for their work!
Table of Contents
Features
- Emulate a Philips Hue Light Bulb
- Control your devices with Alexa Echo
- Asyncronous processing
Installation
- Install Python 3.11 or higher
- And:
pip install echohue
Usage
Create a hub object and add devices to it. Then run the hub.
Hub
Arguments
| Argument | Type | Description | Default |
|---|---|---|---|
| debug | bool | Enable debug mode | False |
Methods
| Method | Args | Description |
|---|---|---|
| add | Device | Add a device to the hub |
| run | - | Run the hub |
Example
async with Hub() as hub:
hub.add(Device('Test Device', True, 254))
await hub.run()
Device
Has to return True or None if the override was successful, otherwise False.
Note: if the override returns false, the device value will not be updated. And Echo will receive an error. The same applies to if the task takes too long.
Arguments
| Argument | Type | Description | Default |
|---|---|---|---|
| name | str | The name of the device | - |
| on | bool | The state of the device | False |
| brightness | int (1-254) | The brightness of the device | 1 |
Overrides
| Override | Args | Description |
|---|---|---|
| on_on | - | Called when the device is turned on |
| on_off | - | Called when the device is turned off |
| on_bri | int (1-254) | Called when the brightness is changed |
| on_ct | int (153-500) | Called when the color temperature is changed |
| on_xy | tuple (float, float) | Called when the color is changed |
| on_hue | int (0-65535) | Called when the hue is changed |
| on_sat | int (0-254) | Called when the saturation is changed |
Example
from echohue import Hub, Device
class Lamp(Device):
def __init__(self, name, on, brightness):
super().__init__(name, on, brightness)
async def on_on(self):
print('Lamp turned on')
async def on_off(self):
print('Lamp turned off')
async def on_bri(self, bri):
print(f'Lamp brightness changed to {bri}')
Example
This example will create a hub with a device called "Lamp" and print the state changes to the console.
import asyncio
from echohue import Hub, Device
class Lamp(Device):
def __init__(self, name, on=True, brightness=1):
super().__init__(name, on, brightness)
async def on_on(self):
print('Lamp turned on')
async def on_off(self):
print('Lamp turned off')
async def on_bri(self, bri):
print(f'Lamp brightness changed to {bri}')
async def main():
async with Hub() as hub:
hub.add(Lamp('Test Device'))
await hub.run()
if __name__ == '__main__':
asyncio.run(main())
Contributing
Pull requests are welcome and greatly appreciated!. For major changes, please open an issue first to discuss what you would like to change.
Requirements (for development)
- Python 3.11 or higher
- Packages
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file echohue-0.1.3.tar.gz.
File metadata
- Download URL: echohue-0.1.3.tar.gz
- Upload date:
- Size: 25.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd5552c54f794e5b9e472ca2648888c6fed6010511c4759c5eb6a6b16c36b9ae
|
|
| MD5 |
55d7a519e922d604b0b28539dff36eb7
|
|
| BLAKE2b-256 |
a75558bcc0eb0385648da1481a554edb7abb4126dc35c91cd23850d63764d38e
|
File details
Details for the file echohue-0.1.3-py3-none-any.whl.
File metadata
- Download URL: echohue-0.1.3-py3-none-any.whl
- Upload date:
- Size: 23.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b172b012165ba6502336e38db4ab7cd3ef26fc4aca3ac95684d7bc6aa4fb755
|
|
| MD5 |
e914d2c15894360afddee4a0475c5675
|
|
| BLAKE2b-256 |
3429b66891e6806a4396ebe8ae75f8670a6d9c2cde410b6ece88fc4f9b4fce43
|