1
0
Fork 0

set the active scene when applying a rule

master
Bob Carroll 2021-02-15 11:29:31 -05:00 committed by Bob Carroll
parent dbc958214b
commit 7cc193ef00
3 changed files with 8 additions and 2 deletions

View File

@ -121,6 +121,7 @@ async def periodic_rule_check(client, state, mutex):
"""
async with mutex:
rules = state['rules']
scene_name = state['scene-name']
while True:
logging.debug('Begin rule check')
@ -142,6 +143,8 @@ async def periodic_rule_check(client, state, mutex):
elif matched:
logging.info(f'Rule triggered: {r.get("name")}')
await apply_rule(r, client)
await client.publish(
'scene/active', scene_name, retain=True)
active = i
break
elif active == i:
@ -222,7 +225,8 @@ async def init(config):
:param config: configuration dictionary
"""
state = {'rules': config.get('rules', [])}
state = {'rules': config.get('rules', []),
'scene-name': config.get('scene-name', 'Circadian')}
mutex = asyncio.Lock()
tasks = set()

View File

@ -7,6 +7,8 @@ log:
# CRITICAL, ERROR, WARNING, INFO, DEBUG
level: INFO
scene-name: Circadian
rules:
- name: Early Morning
trigger:

View File

@ -2,7 +2,7 @@
from setuptools import setup, find_namespace_packages
setup(name='cherry-circadian',
version='0.1',
version='0.2',
description='adapts lighting based on the sun movement',
author='Bob Carroll',
author_email='bob.carroll@alum.rit.edu',