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 homeassistant-api

pip install 'homeassistant_api>=4.0.0.post2'

Sample use

import homeassistant_api as ha
from collections import namedtuple

client = ha.Client(URL, TOKEN)
factory = 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.2-py3-none-any.whl (1.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: home_assistant_lights-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 1.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.11.3 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.64.0 CPython/3.9.12

File hashes

Hashes for home_assistant_lights-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ce07f1f2d6788748a356619bce017a7de72ce94607645d4a3c0d985ec5bcf03d
MD5 3576e6d5d1fa5272664d492b2d96375f
BLAKE2b-256 a63ab9e7037eb620129db40e4585fdba1c249f25cf38df6aa6a61f44c27a1d12

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