You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
970 B
Python

import lightrix.matrix as mc
import lightrix.patterns as lightrix
import lightrix.strip as strip
import click
import os
import sys
import yaml
@click.command()
@click.option('--config', '-c', default="~/.mcatrc", type=click.Path(exists=True))
@click.option('--room-id', '-r')
def start(config, room_id):
if room_id is None:
print("Require --room argument")
sys.exit(1)
if not os.path.exists(config):
print("Configuration file doesn't exist, please create one")
sys.exit(1)
led_count = 150
with open(config) as f:
conf = yaml.safe_load(f)
s = strip.Strip(count=led_count)
lx = lightrix.Lightrix(s)
client = mc.Client(conf['homeserver_uri'],
conf['username'], conf['password'],
room_id, strip=s)
lx.matrix = client
client.add_listener(lx.handler)
client.listen()
if __name__ == '__main__':
start()