Skip to main content

Simple python library to control lights and switches in Home Assistant..

Project description

ha_lights

Simple python library to control lights and switches in Home Assistant.

Relies on dataclasses and namedtuples to provide auto-completion for interactive environments such as colab.

Requirements

Install the package with pip

pip install 'home-assistant-lights'

Sample use

import homeassistant_api as ha
import ha_lights
from collections import namedtuple

client = ha.Client(URL, TOKEN)
factory = ha_lights.Factory(client)
lights,switches = factory.AllLights(), factory.AllSwitches()


COLORS = {
    'chill_evening': [255,220,180],
    'pure_white': [255, 255, 255],
    'red': [255, 0, 0],
}
Colors = namedtuple('Colors', COLORS)(**COLORS)


# Turn on a specific light with optional brightness and color settings
lights.living_room_tripod.turn_on(brightness=255, rgb_color=Colors.chill_evening)

# Create an entity group and use it to control lights and switches with a single API
living_room = EntityGroup([lights.living_room_tripod, switches.lr_smart_plug])
living_room.toggle()

Optionally (if you have an invalid cert)

import urllib3

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

client = ha.Client(URL, TOKEN, global_request_kwargs={'verify': False})

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

home_assistant_lights-0.0.4-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file home_assistant_lights-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for home_assistant_lights-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8d389c8585fdf45601d063be9703a126935390855ef2160a58cdfa81ffc2ee9e
MD5 326ebfcb00c97680be099b61e64240b8
BLAKE2b-256 0fbc31f7c7e323fca3bab35f23ca224adb798fa68a6cca310116f8051b95c922

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