25 rader
836 B
Python
25 rader
836 B
Python
import devices
|
|
import logging
|
|
|
|
try:
|
|
from config import APP_NAME as ROOT_LOGGER_NAME
|
|
except ImportError:
|
|
ROOT_LOGGER_NAME = 'root'
|
|
logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
|
|
|
|
|
|
class room_function(object):
|
|
def __init__(self, device_collection):
|
|
self.main_light_shelly = device_collection.shellies.dinigroom
|
|
self.floorlamp_powerplug = device_collection.powerplugs.dining_floorlamp
|
|
#
|
|
self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.main_light_shelly_callback)
|
|
#
|
|
self.main_light_shelly_last = None
|
|
|
|
def main_light_shelly_callback(self, device, key, data):
|
|
if data != self.main_light_shelly_last:
|
|
logger.info("Test")
|
|
self.floorlamp_powerplug.set_output_0(data)
|
|
self.main_light_shelly_last
|