GUI elements switch and brightness+color_temp joined; simulation extended by 1st automated test
This commit is contained in:
parent
03a6f83c42
commit
9907924e54
@ -527,7 +527,7 @@ class gui_light(tradfri_light):
|
||||
if targetkey in self.data.keys():
|
||||
self.store_data(**{targetkey: value})
|
||||
else:
|
||||
print("Unknown key %s in %s" % (targetkey, self.__class__.__name__))
|
||||
print("Unknown key %s in %s::%s" % (targetkey, message.topic, self.__class__.__name__))
|
||||
elif message.topic == self.topic + '/get':
|
||||
self.__tx__(None)
|
||||
|
||||
@ -564,9 +564,9 @@ class gui_light(tradfri_light):
|
||||
color = COLOR_GUI_ACTIVE
|
||||
if key == self.KEY_STATE:
|
||||
if value == True:
|
||||
print(color + 10 * ' ' + u'\u25a0' + 9 * ' ' + " - ".join(self.topic.split('/')[1:-1]) + colored.attr("reset"))
|
||||
print(color + 10 * ' ' + u'\u25a0' + 9 * ' ' + " - ".join(self.topic.split('/')[1:]) + colored.attr("reset"))
|
||||
else:
|
||||
print(color + 10 * ' ' + u'\u25a1' + 9*' ' + " - ".join(self.topic.split('/')[1:-1]) + colored.attr("reset"))
|
||||
print(color + 10 * ' ' + u'\u25a1' + 9*' ' + " - ".join(self.topic.split('/')[1:]) + colored.attr("reset"))
|
||||
elif key == self.KEY_ENABLE:
|
||||
self.print_formatted(device, self.KEY_BRIGHTNESS, self.data.get(self.KEY_BRIGHTNESS))
|
||||
self.print_formatted(device, self.KEY_COLOR_TEMP, self.data.get(self.KEY_COLOR_TEMP))
|
||||
@ -578,7 +578,7 @@ class gui_light(tradfri_light):
|
||||
sys.stdout.write('B' if key == self.KEY_BRIGHTNESS else 'C')
|
||||
sys.stdout.write(percent_bar(value))
|
||||
sys.stdout.write("%3d%%" % value + 5 * " ")
|
||||
print(" - ".join(self.topic.split('/')[1:-1]) + colored.attr("reset"))
|
||||
print(" - ".join(self.topic.split('/')[1:]) + colored.attr("reset"))
|
||||
|
||||
|
||||
class tradfri_button(base):
|
||||
@ -654,7 +654,7 @@ class gui_led_array(base):
|
||||
def print_formatted(self, device, key, value):
|
||||
led = green_led() if value else grey_led()
|
||||
channel = '(%s)' % self.names.get(key, key)
|
||||
devicename = ' - '.join(self.topic.split('/')[1:-1])
|
||||
devicename = ' - '.join(self.topic.split('/')[1:])
|
||||
print(10 * ' ' + led + 9 * ' ' + COLOR_GUI_ACTIVE + devicename + ' ' + channel + colored.attr("reset"))
|
||||
|
||||
|
||||
@ -693,13 +693,13 @@ class gui_timer(base):
|
||||
perc = payload / self.maxvalue * 100
|
||||
if self.last_printed is None or abs(self.last_printed - perc) >= 4.8:
|
||||
sys.stdout.write(COLOR_GUI_ACTIVE + 't' + percent_bar(perc))
|
||||
print('%3d%%' % perc + 2 * ' ' + ' - '.join(self.topic.split('/')[1:-1]) + ' (%.1f)' % payload + colored.attr('reset'))
|
||||
print('%3d%%' % perc + 2 * ' ' + ' - '.join(self.topic.split('/')[1:]) + ' (%.1f)' % payload + colored.attr('reset'))
|
||||
self.last_printed = perc
|
||||
else:
|
||||
self.maxvalue = None
|
||||
self.last_printed = None
|
||||
sys.stdout.write(COLOR_GUI_ACTIVE + 't' + percent_bar(0))
|
||||
print('%3d%%' % 0 + 2 * ' ' + ' - '.join(self.topic.split('/')[1:-1]) + colored.attr('reset'))
|
||||
print('%3d%%' % 0 + 2 * ' ' + ' - '.join(self.topic.split('/')[1:]) + colored.attr('reset'))
|
||||
else:
|
||||
print("Unknown Message")
|
||||
|
||||
|
@ -40,7 +40,7 @@ class base(object):
|
||||
|
||||
class gfw_floor(base):
|
||||
def __init__(self, mqtt_client):
|
||||
self.gui_switch_main_light = gui_light(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_GUI_SWITCH, True, False, False)
|
||||
self.gui_main_light = gui_light(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_GUI, True, True, True)
|
||||
self.main_light = shelly(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
|
||||
self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
|
||||
self.main_light_zigbee_1 = tradfri_light(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_1_ZIGBEE, True, True, True, False)
|
||||
@ -49,36 +49,36 @@ class gfw_floor(base):
|
||||
self.main_light_zigbee_2 = tradfri_light(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_2_ZIGBEE, True, True, True, False)
|
||||
self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee_2.power_on, "on")
|
||||
self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee_1.power_off, "off")
|
||||
self.gui_br_ct_main_light = gui_light(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_GUI_BR_CT, False, True, True)
|
||||
|
||||
|
||||
class gfw_marion(base):
|
||||
def __init__(self, mqtt_client):
|
||||
self.gui_switch_main_light = gui_light(mqtt_client, config.TOPIC_GFW_MARION_MAIN_LIGHT_GUI_SWITCH, True, False, False)
|
||||
self.gui_main_light = gui_light(mqtt_client, config.TOPIC_GFW_MARION_MAIN_LIGHT_GUI, True, False, False)
|
||||
self.main_light = shelly(mqtt_client, config.TOPIC_GFW_MARION_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
|
||||
self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
|
||||
|
||||
|
||||
class gfw_dirk(base):
|
||||
def __init__(self, mqtt_client):
|
||||
self.gui_switch_main_light = gui_light(mqtt_client, config.TOPIC_GFW_DIRK_MAIN_LIGHT_GUI_SWITCH, True, False, False)
|
||||
self.gui_main_light = gui_light(mqtt_client, config.TOPIC_GFW_DIRK_MAIN_LIGHT_GUI, True, True, True)
|
||||
self.main_light = shelly(mqtt_client, config.TOPIC_GFW_DIRK_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
|
||||
self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
|
||||
self.main_light_zigbee = tradfri_light(mqtt_client, config.TOPIC_GFW_DIRK_MAIN_LIGHT_ZIGBEE, True, True, True)
|
||||
self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_on, "on")
|
||||
self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_off, "off")
|
||||
self.gui_br_ct_main_light = gui_light(mqtt_client, config.TOPIC_GFW_DIRK_MAIN_LIGHT_GUI_BR_CT, False, True, True)
|
||||
#
|
||||
self.powerplug = my_powerplug(mqtt_client, config.TOPIC_GFW_DIRK_POWERPLUG)
|
||||
self.powerplug.add_channel_name(my_powerplug.KEY_OUTPUT_0, "Amplifier")
|
||||
self.powerplug.add_channel_name(my_powerplug.KEY_OUTPUT_1, "Desk Light")
|
||||
self.powerplug.add_channel_name(my_powerplug.KEY_OUTPUT_2, "CD-Player")
|
||||
self.powerplug.add_channel_name(my_powerplug.KEY_OUTPUT_3, "PC-Dock")
|
||||
self.gui_switch_amplifier = gui_light(mqtt_client, config.TOPIC_GFW_DIRK_AMPLIFIER_GUI_SWITCH, True, False, False)
|
||||
self.gui_switch_desk_light = gui_light(mqtt_client, config.TOPIC_GFW_DIRK_DESK_LIGHT_GUI_SWITCH, True, False, False)
|
||||
self.gui_br_ct_desk_light = gui_light(mqtt_client, config.TOPIC_GFW_DIRK_DESK_LIGHT_GUI_BR_CT, False, True, True)
|
||||
self.gui_switch_cd_player = gui_light(mqtt_client, config.TOPIC_GFW_DIRK_CD_PLAYER_GUI_SWITCH, True, False, False)
|
||||
self.gui_switch_pc_dock = gui_light(mqtt_client, config.TOPIC_GFW_DIRK_PC_DOCK_GUI_SWITCH, True, False, False)
|
||||
self.powerplug.add_channel_name(my_powerplug.KEY_OUTPUT_1, "Desk_Light")
|
||||
self.powerplug.add_channel_name(my_powerplug.KEY_OUTPUT_2, "CD_Player")
|
||||
self.powerplug.add_channel_name(my_powerplug.KEY_OUTPUT_3, "PC_Dock")
|
||||
self.gui_amplifier = gui_light(mqtt_client, config.TOPIC_GFW_DIRK_AMPLIFIER_GUI, True, False, False)
|
||||
self.gui_desk_light = gui_light(mqtt_client, config.TOPIC_GFW_DIRK_DESK_LIGHT_GUI, True, True, True)
|
||||
self.desk_light_zigbee = tradfri_light(mqtt_client, config.TOPIC_GFW_DIRK_DESK_LIGHT_ZIGBEE, True, True, True)
|
||||
self.powerplug.add_callback(my_powerplug.KEY_OUTPUT_1, self.desk_light_zigbee.power_on, True)
|
||||
self.powerplug.add_callback(my_powerplug.KEY_OUTPUT_1, self.desk_light_zigbee.power_off, False)
|
||||
self.gui_cd_player = gui_light(mqtt_client, config.TOPIC_GFW_DIRK_CD_PLAYER_GUI, True, False, False)
|
||||
self.gui_pc_dock = gui_light(mqtt_client, config.TOPIC_GFW_DIRK_PC_DOCK_GUI, True, False, False)
|
||||
#
|
||||
self.remote = remote(mqtt_client, config.TOPIC_GFW_DIRK_AMPLIFIER_REMOTE)
|
||||
#
|
||||
@ -98,18 +98,17 @@ class gfw(base):
|
||||
|
||||
class ffw_julian(base):
|
||||
def __init__(self, mqtt_client):
|
||||
self.gui_switch_main_light = gui_light(mqtt_client, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_GUI_SWITCH, True, False, False)
|
||||
self.gui_main_light = gui_light(mqtt_client, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_GUI, True, True, True)
|
||||
self.main_light = shelly(mqtt_client, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
|
||||
self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
|
||||
self.main_light_zigbee = tradfri_light(mqtt_client, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_ZIGBEE, True, True, True)
|
||||
self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_on, "on")
|
||||
self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_off, "off")
|
||||
self.gui_br_ct_main_light = gui_light(mqtt_client, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_GUI_BR_CT, False, True, True)
|
||||
|
||||
|
||||
class ffw_livingroom(base):
|
||||
def __init__(self, mqtt_client):
|
||||
self.gui_switch_main_light = gui_light(mqtt_client, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_GUI_SWITCH, True, False, False)
|
||||
self.gui_main_light = gui_light(mqtt_client, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_GUI, True, False, False)
|
||||
self.main_light = shelly(mqtt_client, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
|
||||
self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
|
||||
|
||||
@ -122,18 +121,18 @@ class ffw(base):
|
||||
|
||||
class ffe_floor(base):
|
||||
def __init__(self, mqtt_client):
|
||||
self.gui_switch_main_light = gui_light(mqtt_client, config.TOPIC_FFE_FLOOR_MAIN_LIGHT_GUI_SWITCH, True, False, False)
|
||||
self.gui_main_light = gui_light(mqtt_client, config.TOPIC_FFE_FLOOR_MAIN_LIGHT_GUI, True, False, False)
|
||||
self.main_light = shelly(mqtt_client, config.TOPIC_FFE_FLOOR_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
|
||||
self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
|
||||
|
||||
|
||||
class ffe_kitchen(base):
|
||||
def __init__(self, mqtt_client):
|
||||
self.gui_switch_main_light = gui_light(mqtt_client, config.TOPIC_FFE_KITCHEN_MAIN_LIGHT_GUI_SWITCH, True, False, False)
|
||||
self.gui_main_light = gui_light(mqtt_client, config.TOPIC_FFE_KITCHEN_MAIN_LIGHT_GUI, True, False, False)
|
||||
self.main_light = shelly(mqtt_client, config.TOPIC_FFE_KITCHEN_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
|
||||
self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
|
||||
#
|
||||
self.gui_switch_circulation_pump = gui_light(mqtt_client, config.TOPIC_FFE_KITCHEN_CIRCULATION_PUMP_GUI_SWITCH, True, False, False)
|
||||
self.gui_circulation_pump = gui_light(mqtt_client, config.TOPIC_FFE_KITCHEN_CIRCULATION_PUMP_GUI, True, False, False)
|
||||
self.circulation_pump = shelly(mqtt_client, config.TOPIC_FFE_KITCHEN_CIRCULATION_PUMP_SHELLY,
|
||||
input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER, output_0_auto_off=10*60)
|
||||
self.circulation_pump.add_channel_name(shelly.KEY_OUTPUT_0, "Circulation Pump")
|
||||
@ -142,29 +141,28 @@ class ffe_kitchen(base):
|
||||
|
||||
class ffe_diningroom(base):
|
||||
def __init__(self, mqtt_client):
|
||||
self.gui_switch_main_light = gui_light(mqtt_client, config.TOPIC_FFE_DININGROOM_MAIN_LIGHT_GUI_SWITCH, True, False, False)
|
||||
self.gui_main_light = gui_light(mqtt_client, config.TOPIC_FFE_DININGROOM_MAIN_LIGHT_GUI, True, False, False)
|
||||
self.main_light = shelly(mqtt_client, config.TOPIC_FFE_DININGROOM_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
|
||||
self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
|
||||
self.gui_switch_floor_lamp = gui_light(mqtt_client, config.TOPIC_FFE_DININGROOM_FLOOR_LAMP_GUI_SWITCH, True, False, False)
|
||||
self.gui_floor_lamp = gui_light(mqtt_client, config.TOPIC_FFE_DININGROOM_FLOOR_LAMP_GUI, True, False, False)
|
||||
self.floor_lamp = silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_DININGROOM_FLOOR_LAMP_POWERPLUG)
|
||||
self.floor_lamp.add_channel_name(silvercrest_powerplug.KEY_OUTPUT_0, "Floor Lamp")
|
||||
if config.CHRISTMAS:
|
||||
self.garland = silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_DININGROOM_GARLAND_POWERPLUG)
|
||||
self.garland.add_channel_name(silvercrest_powerplug, "Garland")
|
||||
|
||||
|
||||
class ffe_sleep(base):
|
||||
def __init__(self, mqtt_client):
|
||||
self.gui_switch_main_light = gui_light(mqtt_client, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_GUI_SWITCH, True, False, False)
|
||||
self.gui_main_light = gui_light(mqtt_client, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_GUI, True, True, True)
|
||||
self.main_light = shelly(mqtt_client, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
|
||||
self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
|
||||
self.main_light_zigbee = tradfri_light(mqtt_client, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_ZIGBEE, True, True, True)
|
||||
self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_on, "on")
|
||||
self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_off, "off")
|
||||
self.gui_br_ct_main_light = gui_light(mqtt_client, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_GUI_BR_CT, False, True, True)
|
||||
#
|
||||
self.gui_switch_bed_light_di = gui_light(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_DI_GUI_SWITCH, True, False, False)
|
||||
self.gui_bed_light_di = gui_light(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_DI_GUI, True, True, False)
|
||||
self.bed_light_di_zigbee = tradfri_light(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_DI_ZIGBEE, True, True, False)
|
||||
self.gui_br_ct_bed_light_di = gui_light(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_DI_GUI_BR_CT, False, True, False)
|
||||
#
|
||||
self.input_device = tradfri_button(mqtt_client, config.TOPIC_FFE_SLEEP_INPUT_DEVICE)
|
||||
self.led_array = gui_led_array(mqtt_client, config.TOPIC_FFE_SLEEP_DEVICE_CHOOSER_LED)
|
||||
@ -179,17 +177,21 @@ class ffe_sleep(base):
|
||||
|
||||
class ffe_livingroom(base):
|
||||
def __init__(self, mqtt_client):
|
||||
self.gui_switch_main_light = gui_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_GUI_SWITCH, True, False, False)
|
||||
self.gui_main_light = gui_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_GUI, True, True, True)
|
||||
self.main_light = shelly(mqtt_client, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
|
||||
self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
|
||||
self.main_light_zigbee = tradfri_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_ZIGBEE, True, True, True)
|
||||
self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_on, "on")
|
||||
self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_off, "off")
|
||||
self.gui_br_ct_main_light = gui_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_GUI_BR_CT, False, True, True)
|
||||
for i in range(1, 7):
|
||||
setattr(self, "floor_lamp_%d" % i, tradfri_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_ZIGBEE % i, True, True, True))
|
||||
self.gui_switch_floor_lamp = gui_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_GUI_SWITCH, True, False, False)
|
||||
self.gui_br_ct_floor_lamp = gui_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_GUI_BR_CT, False, True, True)
|
||||
setattr(self, "floor_lamp_zigbee_%d" % i, tradfri_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_ZIGBEE % i, True, True, True))
|
||||
self.gui_floor_lamp = gui_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_GUI, True, True, True)
|
||||
if config.CHRISTMAS:
|
||||
self.xmas_tree = silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_TREE_POWERPLUG)
|
||||
self.xmas_tree.add_channel_name(silvercrest_powerplug, "Xmas-Tree")
|
||||
self.gui_xmas_tree = gui_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_TREE_GUI)
|
||||
self.xmas_star = silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_STAR_POWERPLUG)
|
||||
self.xmas_star.add_channel_name(silvercrest_powerplug, "Xmas-Star")
|
||||
|
||||
|
||||
class ffe(base):
|
||||
@ -203,7 +205,7 @@ class ffe(base):
|
||||
|
||||
class stairway(base):
|
||||
def __init__(self, mqtt_client):
|
||||
self.gui_switch_main_light = gui_light(mqtt_client, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_GUI_SWITCH, True, False, False)
|
||||
self.gui_main_light = gui_light(mqtt_client, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_GUI, True, False, False)
|
||||
self.main_light = shelly(mqtt_client, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
|
||||
self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
|
||||
self.motion_sensor_gf = silvercrest_motion_sensor(mqtt_client, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_MOTION_SENSOR_GF)
|
||||
|
232
__simulation__/test.py
Normal file
232
__simulation__/test.py
Normal file
@ -0,0 +1,232 @@
|
||||
import colored
|
||||
import time
|
||||
|
||||
|
||||
DT_TOGGLE = 0.1
|
||||
|
||||
|
||||
class test_smarthome(object):
|
||||
def __init__(self, house):
|
||||
self.house = house
|
||||
|
||||
def __smoke__(self):
|
||||
result = ""
|
||||
result += "Smoke-Test\n"
|
||||
result += " GUI Element exists for every shelly instance\n"
|
||||
result += self.__gui_element_exists__("shelly")
|
||||
result += " On-Off test for every shelly instance\n"
|
||||
result += self.__on_off_test__("shelly")
|
||||
result += " GUI Element exists for every silvercrest_powerplug instance\n"
|
||||
result += self.__gui_element_exists__("silvercrest_powerplug")
|
||||
result += " On-Off test for every silvercrest_powerplug instance\n"
|
||||
result += self.__on_off_test__("silvercrest_powerplug")
|
||||
result += " GUI Element exists for every my_powerplug instance and port\n"
|
||||
result += self.__gui_element_exists_my_powerplug__()
|
||||
result += " On-Off test for every my_powerplug instance\n"
|
||||
result += self.__on_off_test_my_powerplug__()
|
||||
result += " GUI Element exists for every tradfri_light instance\n"
|
||||
result += self.__gui_element_exists__("tradfri_light")
|
||||
result += " Enable and disable test for gui elements corresponding with tradfri_light\n"
|
||||
result += self.__br_ct_enable_test__()
|
||||
result += " Chnage brightness and color_temp by gui test\n"
|
||||
result += self.__br_ct_change_test__()
|
||||
return result
|
||||
|
||||
def __full__(self):
|
||||
result = "Full-Test"
|
||||
return result
|
||||
|
||||
def smoke(self):
|
||||
print(self.__smoke__())
|
||||
|
||||
def full(self):
|
||||
out = self.__smoke__()
|
||||
out += self.__full__()
|
||||
print(out)
|
||||
|
||||
def print_error(self, text, lvl=2):
|
||||
return lvl*" " + colored.fg("light_red") + '* ' + text + "\n" + colored.attr("reset")
|
||||
|
||||
def print_success(self, text, lvl=2):
|
||||
return lvl*" " + colored.fg("light_green") + '* ' + text + "\n" + colored.attr("reset")
|
||||
|
||||
def __gui_element_exists__(self, obj_name):
|
||||
result = ""
|
||||
for member in self.house.getmembers():
|
||||
obj = self.house.getobjbyname(member)
|
||||
if obj.__class__.__name__ == obj_name:
|
||||
if obj_name == "tradfri_light":
|
||||
basename = member[:member.index('_zigbee')]
|
||||
else:
|
||||
basename = member
|
||||
try:
|
||||
gui = self.house.getobjbyname('.'.join(basename.split('.')[:-1]) + '.gui_' + basename.split('.')[-1])
|
||||
except AttributeError:
|
||||
result += self.print_error("No GUI element available, while testing %s (%s)." % (member, obj_name))
|
||||
else:
|
||||
result += self.print_success("GUI element available, while testing %s (%s)." % (member, obj_name))
|
||||
return result
|
||||
|
||||
def __gui_element_exists_my_powerplug__(self):
|
||||
result = ""
|
||||
for member in self.house.getmembers():
|
||||
obj = self.house.getobjbyname(member)
|
||||
if obj.__class__.__name__ == "my_powerplug":
|
||||
for channel in [obj.KEY_OUTPUT_0, obj.KEY_OUTPUT_1, obj.KEY_OUTPUT_2, obj.KEY_OUTPUT_3]:
|
||||
try:
|
||||
gui = self.house.getobjbyname('.'.join(member.split(
|
||||
'.')[:-1]) + '.gui_' + obj.names.get(channel.lower(), "__dummy__").lower())
|
||||
except AttributeError:
|
||||
result += self.print_error("No GUI element available, while testing %s (%s)." % (member, obj.names.get(channel)))
|
||||
else:
|
||||
result += self.print_success("GUI element available, while testing %s (%s)." % (member, obj.names.get(channel)))
|
||||
return result
|
||||
|
||||
def __on_off_test_my_powerplug__(self):
|
||||
result = ""
|
||||
for member in self.house.getmembers():
|
||||
obj = self.house.getobjbyname(member)
|
||||
if obj.__class__.__name__ == "my_powerplug":
|
||||
for channel in [obj.KEY_OUTPUT_0, obj.KEY_OUTPUT_1, obj.KEY_OUTPUT_2, obj.KEY_OUTPUT_3]:
|
||||
try:
|
||||
gui = self.house.getobjbyname('.'.join(member.split(
|
||||
'.')[:-1]) + '.gui_' + obj.names.get(channel.lower(), "__dummy__").lower())
|
||||
except AttributeError:
|
||||
raise AttributeError
|
||||
pass # exists test already covers non existing gui-elements
|
||||
else:
|
||||
success = True
|
||||
# Initial state equal between obj and gui
|
||||
obj_state = obj.data.get(channel)
|
||||
gui_state = gui.data.get(gui.KEY_STATE)
|
||||
if obj_state != gui_state:
|
||||
result += self.print_error("Initial state of %s (%s) is not equal to GUI state (%s), while testing %s (%s)" %
|
||||
("my_powerplug", obj_state, gui_state, member, obj.names.get(channel)))
|
||||
success = False
|
||||
# state obj change results in state change of obj and gui
|
||||
for i in range(1, 3):
|
||||
gui.command("toggle_state")
|
||||
time.sleep(2 * DT_TOGGLE)
|
||||
last_obj_state = obj_state
|
||||
obj_state = obj.data.get(channel)
|
||||
gui_state = gui.data.get(gui.KEY_STATE)
|
||||
if last_obj_state == obj_state:
|
||||
result += self.print_error("State after %d. toggle of gui state: State unchanged (%s), while testing %s (%s)" %
|
||||
(i, obj_state, member, obj.names.get(channel)))
|
||||
success = False
|
||||
if obj_state != gui_state:
|
||||
result += self.print_error("State after %d. toggle of gui state:: State of device (%s) is not equal to GUI state (%s), while testing %s (%s)" %
|
||||
(i, obj_state, gui_state, member, obj.names.get(channel)))
|
||||
success = False
|
||||
#
|
||||
if success:
|
||||
result += self.print_success("On-Off test successfull, while testing %s (%s)." % (member, obj.names.get(channel)))
|
||||
return result
|
||||
|
||||
def __on_off_test__(self, obj_name):
|
||||
result = ""
|
||||
for member in self.house.getmembers():
|
||||
obj = self.house.getobjbyname(member)
|
||||
if obj.__class__.__name__ == obj_name:
|
||||
try:
|
||||
gui = self.house.getobjbyname('.'.join(member.split('.')[:-1]) + '.gui_' + member.split('.')[-1])
|
||||
except AttributeError:
|
||||
pass # exists test already covers non existing gui-elements
|
||||
else:
|
||||
success = True
|
||||
# Initial state equal between obj and gui
|
||||
obj_state = obj.data.get(obj.KEY_OUTPUT_0).lower() == "on"
|
||||
gui_state = gui.data.get(gui.KEY_STATE)
|
||||
if obj_state != gui_state:
|
||||
result += self.print_error("Initial state of %s (%s) is not equal to GUI state (%s), while testing %s (%s)" %
|
||||
(obj_name, obj_state, gui_state, member, obj_name))
|
||||
success = False
|
||||
# state obj change results in state change of obj and gui
|
||||
for i in range(1, 3):
|
||||
gui.command("toggle_state")
|
||||
time.sleep(2 * DT_TOGGLE)
|
||||
last_obj_state = obj_state
|
||||
obj_state = obj.data.get(obj.KEY_OUTPUT_0).lower() == "on"
|
||||
gui_state = gui.data.get(gui.KEY_STATE)
|
||||
if last_obj_state == obj_state:
|
||||
result += self.print_error("State after %d. toggle of gui state: State unchanged (%s), while testing %s (%s)" %
|
||||
(i, obj_state, member, obj_name))
|
||||
success = False
|
||||
if obj_state != gui_state:
|
||||
result += self.print_error("State after %d. toggle of gui state:: State of device (%s) is not equal to GUI state (%s), while testing %s (%s)" %
|
||||
(i, obj_state, gui_state, member, obj_name))
|
||||
success = False
|
||||
#
|
||||
if success:
|
||||
result += self.print_success("On-Off test successfull, while testing %s." % (member))
|
||||
return result
|
||||
|
||||
def __br_ct_enable_test__(self):
|
||||
result = ""
|
||||
for member in self.house.getmembers():
|
||||
obj = self.house.getobjbyname(member)
|
||||
if obj.__class__.__name__ == "tradfri_light":
|
||||
basename = member[:member.index('_zigbee')]
|
||||
gui = self.house.getobjbyname('.'.join(basename.split('.')[:-1]) + '.gui_' + basename.split('.')[-1])
|
||||
success = True
|
||||
#
|
||||
if gui.data.get(gui.KEY_ENABLE) != False:
|
||||
result += self.print_error("Inital enable state is not False, while testing %s." % (member))
|
||||
success = False
|
||||
#
|
||||
gui.command("toggle_state")
|
||||
time.sleep(2 * DT_TOGGLE)
|
||||
if gui.data.get(gui.KEY_ENABLE) != True:
|
||||
result += self.print_error("Enable state is not True after switching on, while testing %s." % (member))
|
||||
success = False
|
||||
#
|
||||
gui.command("toggle_state")
|
||||
time.sleep(2 * DT_TOGGLE)
|
||||
if gui.data.get(gui.KEY_ENABLE) != False:
|
||||
result += self.print_error("Enable state is not False after switching off, while testing %s." % (member))
|
||||
success = False
|
||||
#
|
||||
if success:
|
||||
result += self.print_success("Enable-Disable test successfull, while testing %s." % (member))
|
||||
return result
|
||||
|
||||
def __br_ct_change_test__(self):
|
||||
result = ""
|
||||
for member in self.house.getmembers():
|
||||
obj = self.house.getobjbyname(member)
|
||||
if obj.__class__.__name__ == "tradfri_light":
|
||||
basename = member[:member.index('_zigbee')]
|
||||
gui = self.house.getobjbyname('.'.join(basename.split('.')[:-1]) + '.gui_' + basename.split('.')[-1])
|
||||
success = True
|
||||
#
|
||||
if gui.data.get(gui.KEY_STATE) != True:
|
||||
gui.command("toggle_state")
|
||||
time.sleep(2 * DT_TOGGLE)
|
||||
if gui.data.get(gui.KEY_STATE) != True:
|
||||
result += self.print_error("Unable to switch on light, while testing %s." % (member))
|
||||
success = False
|
||||
continue
|
||||
#
|
||||
if "set_brightness" in obj.capabilities():
|
||||
brightness = gui.data.get(obj.KEY_BRIGHTNESS)
|
||||
targetvalue = brightness + (25 if brightness <= 50 else -25)
|
||||
gui.command("set_brightness %d" % targetvalue)
|
||||
time.sleep(2 * DT_TOGGLE)
|
||||
if gui.data.get(obj.KEY_BRIGHTNESS) != targetvalue:
|
||||
result += self.print_error("Brightness change by gui was not successfull, while testing %s." % (member))
|
||||
success = False
|
||||
if "set_color_temp" in obj.capabilities():
|
||||
color_temp = gui.data.get(obj.KEY_COLOR_TEMP)
|
||||
targetvalue = color_temp + (3 if color_temp <= 5 else -3)
|
||||
gui.command("set_color_temp %d" % targetvalue)
|
||||
time.sleep(2 * DT_TOGGLE)
|
||||
if gui.data.get(obj.KEY_COLOR_TEMP) != targetvalue:
|
||||
result += self.print_error("Color temperature change by gui was not successfull, while testing %s." % (member))
|
||||
success = False
|
||||
#
|
||||
gui.command("toggle_state")
|
||||
time.sleep(2 * DT_TOGGLE)
|
||||
#
|
||||
if success:
|
||||
result += self.print_success("Brightness-ColorTemp test successfull, while testing %s." % (member))
|
||||
return result
|
@ -700,14 +700,14 @@ class nodered_gui_switch(nodered_gui_button):
|
||||
self.set_state(data)
|
||||
|
||||
|
||||
class nodered_gui_brightness_color_temp(base):
|
||||
class nodered_gui_light(nodered_gui_switch):
|
||||
KEY_ENABLE = "enable"
|
||||
KEY_BRIGHTNESS = "brightness"
|
||||
KEY_COLOR_TEMP = "color_temp"
|
||||
#
|
||||
TX_TYPE = base.TX_VALUE
|
||||
#
|
||||
RX_KEYS = [KEY_ENABLE, KEY_BRIGHTNESS, KEY_COLOR_TEMP]
|
||||
RX_KEYS = nodered_gui_switch.RX_KEYS + [KEY_ENABLE, KEY_BRIGHTNESS, KEY_COLOR_TEMP]
|
||||
|
||||
#
|
||||
# RX
|
||||
|
@ -16,14 +16,11 @@ except ImportError:
|
||||
ROOT_LOGGER_NAME = 'root'
|
||||
logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
|
||||
|
||||
# TODO: implement TOPIC-changes in config.py (gfw.floor.main_light)
|
||||
# TODO: implement gui element for tradfri light as one class
|
||||
# TODO: implement devices.nodered_gui_timer (for circulation pump)
|
||||
# TODO: implement devices.nodered_gui_heatvalve incl. setpoint, boost, ... + replace led with timer
|
||||
# TODO: improve heating function
|
||||
# TODO: implement timer and motion leds for stairwasy
|
||||
# TODO: implement devices.nodered_gui_timer (for circulation pump)
|
||||
# improve devices.brennenstuhl_heatvalve
|
||||
# improve the implementation in common if highly reduced, just move it to function.__init__.py
|
||||
# TODO: improve devices.brennenstuhl_heatvalve
|
||||
# TODO: implement garland (incl. day events like sunset, sunrise, ...)
|
||||
# TODO: implement warning message
|
||||
|
||||
|
@ -19,7 +19,7 @@ logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
|
||||
class common_circulation_pump(room_shelly):
|
||||
def __init__(self, mqtt_client):
|
||||
# http://shelly1-E89F6D85A466
|
||||
super().__init__(mqtt_client, config.TOPIC_FFE_KITCHEN_CIRCULATION_PUMP_SHELLY, config.TOPIC_FFE_KITCHEN_CIRCULATION_PUMP_GUI_SWITCH)
|
||||
super().__init__(mqtt_client, config.TOPIC_FFE_KITCHEN_CIRCULATION_PUMP_SHELLY, config.TOPIC_FFE_KITCHEN_CIRCULATION_PUMP_GUI)
|
||||
#
|
||||
self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.circ_pump_actions, True)
|
||||
#
|
||||
|
@ -17,30 +17,30 @@ logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
|
||||
class first_floor_east_floor(room_shelly):
|
||||
def __init__(self, mqtt_client):
|
||||
# http://shelly1l-3C6105E4E629
|
||||
super().__init__(mqtt_client, config.TOPIC_FFE_FLOOR_MAIN_LIGHT_SHELLY, config.TOPIC_FFE_FLOOR_MAIN_LIGHT_GUI_SWITCH)
|
||||
super().__init__(mqtt_client, config.TOPIC_FFE_FLOOR_MAIN_LIGHT_SHELLY, config.TOPIC_FFE_FLOOR_MAIN_LIGHT_GUI)
|
||||
|
||||
|
||||
class first_floor_east_kitchen(room_shelly):
|
||||
def __init__(self, mqtt_client):
|
||||
# http://shelly1l-8CAAB5616C01
|
||||
super().__init__(mqtt_client, config.TOPIC_FFE_KITCHEN_MAIN_LIGHT_SHELLY, config.TOPIC_FFE_KITCHEN_MAIN_LIGHT_GUI_SWITCH)
|
||||
super().__init__(mqtt_client, config.TOPIC_FFE_KITCHEN_MAIN_LIGHT_SHELLY, config.TOPIC_FFE_KITCHEN_MAIN_LIGHT_GUI)
|
||||
|
||||
|
||||
class first_floor_east_dining(room_shelly):
|
||||
def __init__(self, mqtt_client):
|
||||
# http://shelly1l-84CCA8ADD055
|
||||
super().__init__(mqtt_client, config.TOPIC_FFE_DININGROOM_MAIN_LIGHT_SHELLY, config.TOPIC_FFE_DININGROOM_MAIN_LIGHT_GUI_SWITCH)
|
||||
super().__init__(mqtt_client, config.TOPIC_FFE_DININGROOM_MAIN_LIGHT_SHELLY, config.TOPIC_FFE_DININGROOM_MAIN_LIGHT_GUI)
|
||||
self.floorlamp_powerplug = devices.silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_DININGROOM_FLOOR_LAMP_POWERPLUG)
|
||||
if config.CHRISTMAS:
|
||||
self.garland_powerplug = devices.silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_DININGROOM_GARLAND_POWERPLUG)
|
||||
#
|
||||
self.gui_switch_floorlamp = devices.nodered_gui_switch(mqtt_client, config.TOPIC_FFE_DININGROOM_FLOOR_LAMP_GUI_SWITCH)
|
||||
self.gui_floorlamp = devices.nodered_gui_switch(mqtt_client, config.TOPIC_FFE_DININGROOM_FLOOR_LAMP_GUI)
|
||||
#
|
||||
# Callback initialisation
|
||||
#
|
||||
self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.floorlamp_powerplug.set_output_0_mcb, True)
|
||||
self.gui_switch_floorlamp.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.floorlamp_powerplug.set_output_0_mcb)
|
||||
self.floorlamp_powerplug.add_callback(devices.silvercrest_powerplug.KEY_OUTPUT_0, None, self.gui_switch_floorlamp.set_state_mcb)
|
||||
self.gui_floorlamp.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.floorlamp_powerplug.set_output_0_mcb)
|
||||
self.floorlamp_powerplug.add_callback(devices.silvercrest_powerplug.KEY_OUTPUT_0, None, self.gui_floorlamp.set_state_mcb)
|
||||
|
||||
def all_off(self, device=None, key=None, data=None):
|
||||
super().all_off(device, key, data)
|
||||
@ -52,13 +52,11 @@ class first_floor_east_dining(room_shelly):
|
||||
class first_floor_east_sleep(room_shelly_tradfri_light):
|
||||
def __init__(self, mqtt_client):
|
||||
# http://shelly1l-E8DB84A254C7
|
||||
super().__init__(mqtt_client, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_SHELLY, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_GUI_SWITCH,
|
||||
config.TOPIC_FFE_SLEEP_MAIN_LIGHT_ZIGBEE, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_GUI_BR_CT)
|
||||
super().__init__(mqtt_client, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_SHELLY, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_GUI, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_ZIGBEE)
|
||||
#
|
||||
self.bed_light_di_tradfri = devices.tradfri_light(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_DI_ZIGBEE)
|
||||
#
|
||||
self.gui_switch_bed_light_di = devices.nodered_gui_switch(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_DI_GUI_SWITCH)
|
||||
self.gui_br_ct_bed_light_di = devices.nodered_gui_brightness_color_temp(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_DI_GUI_BR_CT)
|
||||
self.gui_bed_light_di = devices.nodered_gui_light(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_DI_GUI)
|
||||
#
|
||||
self.button_tradfri = devices.tradfri_button(mqtt_client, config.TOPIC_FFE_SLEEP_INPUT_DEVICE)
|
||||
#
|
||||
@ -76,14 +74,13 @@ class first_floor_east_sleep(room_shelly_tradfri_light):
|
||||
|
||||
# bed light
|
||||
# switch
|
||||
self.gui_switch_bed_light_di.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.bed_light_di_tradfri.set_output_0_mcb)
|
||||
self.bed_light_di_tradfri.add_callback(devices.tradfri_light.KEY_OUTPUT_0, None, self.gui_switch_bed_light_di.set_state_mcb)
|
||||
self.gui_bed_light_di.add_callback(devices.nodered_gui_light.KEY_STATE, None, self.bed_light_di_tradfri.set_output_0_mcb)
|
||||
self.bed_light_di_tradfri.add_callback(devices.tradfri_light.KEY_OUTPUT_0, None, self.gui_bed_light_di.set_state_mcb)
|
||||
# brightness and color temperature
|
||||
self.bed_light_di_tradfri.add_callback(devices.tradfri_light.KEY_OUTPUT_0, None, self.gui_br_ct_bed_light_di.set_enable_mcb)
|
||||
self.gui_br_ct_bed_light_di.add_callback(devices.nodered_gui_brightness_color_temp.KEY_BRIGHTNESS,
|
||||
None, self.bed_light_di_tradfri.set_brightness_mcb)
|
||||
self.bed_light_di_tradfri.add_callback(devices.tradfri_light.KEY_OUTPUT_0, None, self.gui_br_ct_bed_light_di.set_enable_mcb)
|
||||
self.bed_light_di_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_br_ct_bed_light_di.set_brightness_mcb)
|
||||
self.bed_light_di_tradfri.add_callback(devices.tradfri_light.KEY_OUTPUT_0, None, self.gui_bed_light_di.set_enable_mcb)
|
||||
self.gui_bed_light_di.add_callback(devices.nodered_gui_light.KEY_BRIGHTNESS, None, self.bed_light_di_tradfri.set_brightness_mcb)
|
||||
self.bed_light_di_tradfri.add_callback(devices.tradfri_light.KEY_OUTPUT_0, None, self.gui_bed_light_di.set_enable_mcb)
|
||||
self.bed_light_di_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_bed_light_di.set_brightness_mcb)
|
||||
|
||||
def all_off(self, device=None, key=None, data=None):
|
||||
super().all_off(device, key, data)
|
||||
@ -93,8 +90,8 @@ class first_floor_east_sleep(room_shelly_tradfri_light):
|
||||
class first_floor_east_living(room_shelly_tradfri_light):
|
||||
def __init__(self, mqtt_client):
|
||||
# http://shelly1l-3C6105E3F910
|
||||
super().__init__(mqtt_client, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_SHELLY, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_GUI_SWITCH,
|
||||
config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_ZIGBEE, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_GUI_BR_CT)
|
||||
super().__init__(mqtt_client, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_SHELLY,
|
||||
config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_GUI, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_ZIGBEE)
|
||||
for i in range(1, 7):
|
||||
setattr(self, 'floorlamp_tradfri_%d' % i, devices.tradfri_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_ZIGBEE % i))
|
||||
#
|
||||
@ -102,11 +99,10 @@ class first_floor_east_living(room_shelly_tradfri_light):
|
||||
self.powerplug_xmas_tree = devices.silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_TREE_POWERPLUG)
|
||||
self.powerplug_xmas_star = devices.silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_STAR_POWERPLUG)
|
||||
#
|
||||
self.gui_switch_floorlamp = devices.nodered_gui_switch(mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_GUI_SWITCH)
|
||||
self.gui_br_ct_floorlamp = devices.nodered_gui_brightness_color_temp(mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_GUI_BR_CT)
|
||||
self.gui_floorlamp = devices.nodered_gui_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_GUI)
|
||||
#
|
||||
if config.CHRISTMAS:
|
||||
self.gui_switch_xmas_tree = devices.nodered_gui_switch(mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_TREE_GUI_SWITCH)
|
||||
self.gui_xmas_tree = devices.nodered_gui_switch(mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_TREE_GUI)
|
||||
#
|
||||
# Callback initialisation
|
||||
#
|
||||
@ -114,17 +110,17 @@ class first_floor_east_living(room_shelly_tradfri_light):
|
||||
# floor lamp
|
||||
for device in self.__floorlamp_devices__():
|
||||
self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, device.set_output_0_mcb, True)
|
||||
self.gui_switch_floorlamp.add_callback(devices.nodered_gui_switch.KEY_STATE, None, device.set_output_0_mcb)
|
||||
self.gui_br_ct_floorlamp.add_callback(devices.nodered_gui_brightness_color_temp.KEY_BRIGHTNESS, None, device.set_brightness_mcb)
|
||||
self.gui_br_ct_floorlamp.add_callback(devices.nodered_gui_brightness_color_temp.KEY_COLOR_TEMP, None, device.set_color_temp_mcb)
|
||||
self.floorlamp_tradfri_1.add_callback(devices.tradfri_light.KEY_OUTPUT_0, None, self.gui_switch_floorlamp.set_state_mcb)
|
||||
self.floorlamp_tradfri_1.add_callback(devices.tradfri_light.KEY_OUTPUT_0, None, self.gui_br_ct_floorlamp.set_enable_mcb)
|
||||
self.floorlamp_tradfri_1.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_br_ct_floorlamp.set_brightness_mcb)
|
||||
self.floorlamp_tradfri_1.add_callback(devices.tradfri_light.KEY_COLOR_TEMP, None, self.gui_br_ct_floorlamp.set_color_temp_mcb)
|
||||
self.gui_floorlamp.add_callback(devices.nodered_gui_light.KEY_STATE, None, device.set_output_0_mcb)
|
||||
self.gui_floorlamp.add_callback(devices.nodered_gui_light.KEY_BRIGHTNESS, None, device.set_brightness_mcb)
|
||||
self.gui_floorlamp.add_callback(devices.nodered_gui_light.KEY_COLOR_TEMP, None, device.set_color_temp_mcb)
|
||||
self.floorlamp_tradfri_1.add_callback(devices.tradfri_light.KEY_OUTPUT_0, None, self.gui_floorlamp.set_state_mcb)
|
||||
self.floorlamp_tradfri_1.add_callback(devices.tradfri_light.KEY_OUTPUT_0, None, self.gui_floorlamp.set_enable_mcb)
|
||||
self.floorlamp_tradfri_1.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_floorlamp.set_brightness_mcb)
|
||||
self.floorlamp_tradfri_1.add_callback(devices.tradfri_light.KEY_COLOR_TEMP, None, self.gui_floorlamp.set_color_temp_mcb)
|
||||
#
|
||||
if config.CHRISTMAS:
|
||||
self.powerplug_xmas_tree.add_callback(devices.silvercrest_powerplug.KEY_OUTPUT_0, None, self.gui_switch_xmas_tree.set_state_mcb)
|
||||
self.gui_switch_xmas_tree.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.powerplug_xmas_tree.set_output_0_mcb)
|
||||
self.powerplug_xmas_tree.add_callback(devices.silvercrest_powerplug.KEY_OUTPUT_0, None, self.gui_xmas_tree.set_state_mcb)
|
||||
self.gui_xmas_tree.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.powerplug_xmas_tree.set_output_0_mcb)
|
||||
#
|
||||
self.powerplug_xmas_tree.add_callback(devices.silvercrest_powerplug.KEY_OUTPUT_0, None, self.powerplug_xmas_star.set_output_0_mcb)
|
||||
|
||||
|
@ -16,11 +16,10 @@ logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
|
||||
class first_floor_west_julian(room_shelly_tradfri_light):
|
||||
# http://shelly1l-3C6105E43452
|
||||
def __init__(self, mqtt_client):
|
||||
super().__init__(mqtt_client, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_SHELLY, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_GUI_SWITCH,
|
||||
config.TOPIC_FFW_JULIAN_MAIN_LIGHT_ZIGBEE, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_GUI_BR_CT)
|
||||
super().__init__(mqtt_client, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_SHELLY, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_GUI, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_ZIGBEE)
|
||||
|
||||
|
||||
class first_floor_west_living(room_shelly):
|
||||
# http://shelly1l-84CCA8ACE6A1
|
||||
def __init__(self, mqtt_client):
|
||||
super().__init__(mqtt_client, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_SHELLY, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_GUI_SWITCH)
|
||||
super().__init__(mqtt_client, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_SHELLY, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_GUI)
|
||||
|
@ -19,8 +19,7 @@ logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
|
||||
class ground_floor_west_floor(room_shelly_silvercrest_light):
|
||||
# http://shelly1l-84CCA8AD1148
|
||||
def __init__(self, mqtt_client):
|
||||
super().__init__(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_SHELLY, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_GUI_SWITCH,
|
||||
config.TOPIC_GFW_FLOOR_MAIN_LIGHT_1_ZIGBEE, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_GUI_BR_CT)
|
||||
super().__init__(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_SHELLY, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_GUI, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_1_ZIGBEE)
|
||||
#
|
||||
# Callback initialisation
|
||||
#
|
||||
@ -36,7 +35,7 @@ class ground_floor_west_floor(room_shelly_silvercrest_light):
|
||||
class ground_floor_west_marion(room_shelly):
|
||||
# http://shelly1l-E8DB84A1E067
|
||||
def __init__(self, mqtt_client):
|
||||
super().__init__(mqtt_client, config.TOPIC_GFW_MARION_MAIN_LIGHT_SHELLY, config.TOPIC_GFW_MARION_MAIN_LIGHT_GUI_SWITCH)
|
||||
super().__init__(mqtt_client, config.TOPIC_GFW_MARION_MAIN_LIGHT_SHELLY, config.TOPIC_GFW_MARION_MAIN_LIGHT_GUI)
|
||||
|
||||
|
||||
class ground_floor_west_dirk(room_shelly_tradfri_light):
|
||||
@ -60,19 +59,17 @@ class ground_floor_west_dirk(room_shelly_tradfri_light):
|
||||
|
||||
# http://shelly1l-3C6105E44F27
|
||||
def __init__(self, mqtt_client):
|
||||
super().__init__(mqtt_client, config.TOPIC_GFW_DIRK_MAIN_LIGHT_SHELLY, config.TOPIC_GFW_DIRK_MAIN_LIGHT_GUI_SWITCH,
|
||||
config.TOPIC_GFW_DIRK_MAIN_LIGHT_ZIGBEE, config.TOPIC_GFW_DIRK_MAIN_LIGHT_GUI_BR_CT)
|
||||
super().__init__(mqtt_client, config.TOPIC_GFW_DIRK_MAIN_LIGHT_SHELLY, config.TOPIC_GFW_DIRK_MAIN_LIGHT_GUI, config.TOPIC_GFW_DIRK_MAIN_LIGHT_ZIGBEE)
|
||||
#
|
||||
self.powerplug_common = devices.my_powerplug(mqtt_client, config.TOPIC_GFW_DIRK_POWERPLUG)
|
||||
self.desk_light_tradfri = devices.tradfri_light(mqtt_client, config.TOPIC_GFW_DIRK_DESK_LIGHT_ZIGBEE)
|
||||
self.button_tradfri = devices.tradfri_button(mqtt_client, config.TOPIC_GFW_DIRK_INPUT_DEVICE)
|
||||
#
|
||||
self.gui_switch_desk_light = devices.nodered_gui_switch(mqtt_client, config.TOPIC_GFW_DIRK_DESK_LIGHT_GUI_SWITCH)
|
||||
self.gui_br_cr_desk_light = devices.nodered_gui_brightness_color_temp(mqtt_client, config.TOPIC_GFW_DIRK_DESK_LIGHT_GUI_BR_CT)
|
||||
self.gui_desk_light = devices.nodered_gui_light(mqtt_client, config.TOPIC_GFW_DIRK_DESK_LIGHT_GUI)
|
||||
#
|
||||
self.gui_switch_amplifier = devices.nodered_gui_switch(mqtt_client, config.TOPIC_GFW_DIRK_AMPLIFIER_GUI_SWITCH)
|
||||
self.gui_switch_cd_player = devices.nodered_gui_switch(mqtt_client, config.TOPIC_GFW_DIRK_CD_PLAYER_GUI_SWITCH)
|
||||
self.gui_switch_pc_dock = devices.nodered_gui_switch(mqtt_client, config.TOPIC_GFW_DIRK_PC_DOCK_GUI_SWITCH)
|
||||
self.gui_amplifier = devices.nodered_gui_switch(mqtt_client, config.TOPIC_GFW_DIRK_AMPLIFIER_GUI)
|
||||
self.gui_cd_player = devices.nodered_gui_switch(mqtt_client, config.TOPIC_GFW_DIRK_CD_PLAYER_GUI)
|
||||
self.gui_pc_dock = devices.nodered_gui_switch(mqtt_client, config.TOPIC_GFW_DIRK_PC_DOCK_GUI)
|
||||
#
|
||||
self.remote_amplifier = devices.remote(mqtt_client, config.TOPIC_GFW_DIRK_AMPLIFIER_REMOTE)
|
||||
#
|
||||
@ -97,22 +94,20 @@ class ground_floor_west_dirk(room_shelly_tradfri_light):
|
||||
# switch
|
||||
self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_RIGHT,
|
||||
self.powerplug_common.toggle_output_1_mcb)
|
||||
self.gui_switch_desk_light.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.powerplug_common.set_output_1_mcb)
|
||||
self.powerplug_common.add_callback(self.KEY_POWERPLUG_DESK_LIGHT, None, self.gui_switch_desk_light.set_state_mcb)
|
||||
self.gui_desk_light.add_callback(devices.nodered_gui_light.KEY_STATE, None, self.powerplug_common.set_output_1_mcb)
|
||||
self.powerplug_common.add_callback(self.KEY_POWERPLUG_DESK_LIGHT, None, self.gui_desk_light.set_state_mcb)
|
||||
# brightness and color temp
|
||||
self.gui_br_cr_desk_light.add_callback(devices.nodered_gui_brightness_color_temp.KEY_BRIGHTNESS,
|
||||
None, self.desk_light_tradfri.set_brightness_mcb)
|
||||
self.gui_br_cr_desk_light.add_callback(devices.nodered_gui_brightness_color_temp.KEY_COLOR_TEMP,
|
||||
None, self.desk_light_tradfri.set_color_temp_mcb)
|
||||
self.powerplug_common.add_callback(self.KEY_POWERPLUG_DESK_LIGHT, None, self.gui_br_cr_desk_light.set_enable_mcb)
|
||||
self.desk_light_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_br_cr_desk_light.set_brightness_mcb)
|
||||
self.desk_light_tradfri.add_callback(devices.tradfri_light.KEY_COLOR_TEMP, None, self.gui_br_cr_desk_light.set_color_temp_mcb)
|
||||
self.gui_desk_light.add_callback(devices.nodered_gui_light.KEY_BRIGHTNESS, None, self.desk_light_tradfri.set_brightness_mcb)
|
||||
self.gui_desk_light.add_callback(devices.nodered_gui_light.KEY_COLOR_TEMP, None, self.desk_light_tradfri.set_color_temp_mcb)
|
||||
self.powerplug_common.add_callback(self.KEY_POWERPLUG_DESK_LIGHT, None, self.gui_desk_light.set_enable_mcb)
|
||||
self.desk_light_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_desk_light.set_brightness_mcb)
|
||||
self.desk_light_tradfri.add_callback(devices.tradfri_light.KEY_COLOR_TEMP, None, self.gui_desk_light.set_color_temp_mcb)
|
||||
|
||||
# amplifier
|
||||
self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_LEFT_LONG,
|
||||
self.powerplug_common.toggle_output_0_mcb)
|
||||
self.gui_switch_amplifier.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.powerplug_common.set_output_0_mcb)
|
||||
self.powerplug_common.add_callback(self.KEY_POWERPLUG_AMPLIFIER, None, self.gui_switch_amplifier.set_state_mcb)
|
||||
self.gui_amplifier.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.powerplug_common.set_output_0_mcb)
|
||||
self.powerplug_common.add_callback(self.KEY_POWERPLUG_AMPLIFIER, None, self.gui_amplifier.set_state_mcb)
|
||||
# amplifier auto on
|
||||
self.powerplug_common.add_callback(self.KEY_POWERPLUG_CD_PLAYER, None, self.cd_amplifier_synchronisation, True)
|
||||
self.spotify_state.add_callback(devices.status.KEY_STATE, None, self.raspi_amplifier_synchronisation, True)
|
||||
@ -127,14 +122,14 @@ class ground_floor_west_dirk(room_shelly_tradfri_light):
|
||||
# cd player
|
||||
self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_RIGHT_LONG,
|
||||
self.powerplug_common.toggle_output_2_mcb)
|
||||
self.gui_switch_cd_player.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.powerplug_common.set_output_2_mcb)
|
||||
self.powerplug_common.add_callback(self.KEY_POWERPLUG_CD_PLAYER, None, self.gui_switch_cd_player.set_state_mcb)
|
||||
self.gui_cd_player.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.powerplug_common.set_output_2_mcb)
|
||||
self.powerplug_common.add_callback(self.KEY_POWERPLUG_CD_PLAYER, None, self.gui_cd_player.set_state_mcb)
|
||||
|
||||
# pc dock
|
||||
self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_LEFT,
|
||||
self.powerplug_common.toggle_output_3_mcb)
|
||||
self.gui_switch_pc_dock.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.powerplug_common.set_output_3_mcb)
|
||||
self.powerplug_common.add_callback(self.KEY_POWERPLUG_PC_DOCK, None, self.gui_switch_pc_dock.set_state_mcb)
|
||||
self.gui_pc_dock.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.powerplug_common.set_output_3_mcb)
|
||||
self.powerplug_common.add_callback(self.KEY_POWERPLUG_PC_DOCK, None, self.gui_pc_dock.set_state_mcb)
|
||||
|
||||
def all_off(self, device=None, key=None, data=None):
|
||||
super().all_off(device, key, data)
|
||||
|
@ -21,16 +21,16 @@ class room(object):
|
||||
|
||||
|
||||
class room_shelly(room):
|
||||
def __init__(self, mqtt_client, topic_shelly, topic_gui_switch):
|
||||
def __init__(self, mqtt_client, topic_shelly, topic_gui):
|
||||
super().__init__(mqtt_client)
|
||||
self.main_light_shelly = devices.shelly(mqtt_client, topic=topic_shelly)
|
||||
self.main_light_shelly = devices.shelly(mqtt_client, topic_shelly)
|
||||
#
|
||||
self.gui_switch_main_light = devices.nodered_gui_switch(mqtt_client, topic=topic_gui_switch)
|
||||
self.gui_main_light = devices.nodered_gui_light(mqtt_client, topic_gui)
|
||||
#
|
||||
# Callback initialisation
|
||||
#
|
||||
self.gui_switch_main_light.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.main_light_shelly.set_output_0_mcb)
|
||||
self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_switch_main_light.set_state_mcb)
|
||||
self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_STATE, None, self.main_light_shelly.set_output_0_mcb)
|
||||
self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_main_light.set_state_mcb)
|
||||
#
|
||||
self.block_all_off = False
|
||||
self.last_flash_data = None
|
||||
@ -59,8 +59,8 @@ class room_shelly(room):
|
||||
|
||||
|
||||
class room_shelly_motion_sensor(room_shelly):
|
||||
def __init__(self, mqtt_client, topic_shelly, topic_gui_switch, topic_motion_sensor_1, topic_motion_sensor_2=None, timer_value=config.DEFAULT_ON_TIME_LIGHT):
|
||||
super().__init__(mqtt_client, topic_shelly, topic_gui_switch)
|
||||
def __init__(self, mqtt_client, topic_shelly, topic_gui, topic_motion_sensor_1, topic_motion_sensor_2=None, timer_value=config.DEFAULT_ON_TIME_LIGHT):
|
||||
super().__init__(mqtt_client, topic_shelly, topic_gui)
|
||||
self.timer_value = timer_value
|
||||
#
|
||||
self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, True, self.reload_timer, True)
|
||||
@ -108,26 +108,23 @@ class room_shelly_motion_sensor(room_shelly):
|
||||
|
||||
|
||||
class room_shelly_tradfri_light(room_shelly):
|
||||
def __init__(self, mqtt_client, topic_shelly, topic_gui_switch, topic_tradfri_light, topic_gui_br_ct):
|
||||
super().__init__(mqtt_client, topic_shelly, topic_gui_switch)
|
||||
def __init__(self, mqtt_client, topic_shelly, topic_gui, topic_tradfri_light):
|
||||
super().__init__(mqtt_client, topic_shelly, topic_gui)
|
||||
self.main_light_tradfri = devices.tradfri_light(mqtt_client, topic_tradfri_light)
|
||||
#
|
||||
self.gui_br_ct_main_light = devices.nodered_gui_brightness_color_temp(mqtt_client, topic_gui_br_ct)
|
||||
#
|
||||
# Callback initialisation
|
||||
#
|
||||
self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_br_ct_main_light.set_enable_mcb)
|
||||
self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_br_ct_main_light.set_brightness_mcb)
|
||||
self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_COLOR_TEMP, None, self.gui_br_ct_main_light.set_color_temp_mcb)
|
||||
self.gui_br_ct_main_light.add_callback(devices.nodered_gui_brightness_color_temp.KEY_BRIGHTNESS,
|
||||
None, self.main_light_tradfri.set_brightness_mcb)
|
||||
self.gui_br_ct_main_light.add_callback(devices.nodered_gui_brightness_color_temp.KEY_COLOR_TEMP,
|
||||
None, self.main_light_tradfri.set_color_temp_mcb)
|
||||
self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_main_light.set_state_mcb)
|
||||
self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_main_light.set_enable_mcb)
|
||||
self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_main_light.set_brightness_mcb)
|
||||
self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_COLOR_TEMP, None, self.gui_main_light.set_color_temp_mcb)
|
||||
self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_BRIGHTNESS, None, self.main_light_tradfri.set_brightness_mcb)
|
||||
self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_COLOR_TEMP, None, self.main_light_tradfri.set_color_temp_mcb)
|
||||
|
||||
|
||||
class room_shelly_silvercrest_light(room_shelly_tradfri_light):
|
||||
def __init__(self, mqtt_client, topic_shelly, topic_gui_switch, topic_tradfri_light, topic_gui_br_ct):
|
||||
super().__init__(mqtt_client, topic_shelly, topic_gui_switch, topic_tradfri_light, topic_gui_br_ct)
|
||||
def __init__(self, mqtt_client, topic_shelly, topic_gui, topic_tradfri_light):
|
||||
super().__init__(mqtt_client, topic_shelly, topic_gui, topic_tradfri_light)
|
||||
#
|
||||
# Callback initialisation
|
||||
#
|
||||
|
@ -16,6 +16,6 @@ logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
|
||||
class stairway(room_shelly_motion_sensor):
|
||||
def __init__(self, mqtt_client):
|
||||
# http://shelly1-3494546A9364
|
||||
super().__init__(mqtt_client, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_SHELLY, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_GUI_SWITCH,
|
||||
super().__init__(mqtt_client, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_SHELLY, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_GUI,
|
||||
config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_MOTION_SENSOR_GF,
|
||||
config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_MOTION_SENSOR_FF, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_MIN_ON_TIME)
|
||||
|
@ -4,6 +4,7 @@ import mqtt
|
||||
import readline
|
||||
import report
|
||||
from __simulation__.rooms import house
|
||||
from __simulation__.test import test_smarthome
|
||||
import time
|
||||
|
||||
if __name__ == "__main__":
|
||||
@ -12,7 +13,7 @@ if __name__ == "__main__":
|
||||
mc = mqtt.mqtt_client(host=config.MQTT_SERVER, port=config.MQTT_PORT, username=config.MQTT_USER,
|
||||
password=config.MQTT_PASSWORD, name=config.APP_NAME + '_simulation')
|
||||
#
|
||||
COMMANDS = ['quit', 'help']
|
||||
COMMANDS = ['quit', 'help', 'test.smoke', 'test.full']
|
||||
#
|
||||
h = house(mc)
|
||||
for name in h.getmembers():
|
||||
@ -20,6 +21,7 @@ if __name__ == "__main__":
|
||||
for c in d.capabilities():
|
||||
COMMANDS.append(name + '.' + c)
|
||||
#
|
||||
ts = test_smarthome(h)
|
||||
|
||||
def reduced_list(text):
|
||||
"""
|
||||
@ -56,7 +58,9 @@ if __name__ == "__main__":
|
||||
|
||||
readline.parse_and_bind("tab: complete")
|
||||
readline.set_completer(completer)
|
||||
time.sleep(0.3)
|
||||
print("\nEnter command: ")
|
||||
|
||||
while True:
|
||||
userfeedback = input('')
|
||||
command = userfeedback.split(' ')[0]
|
||||
@ -64,6 +68,10 @@ if __name__ == "__main__":
|
||||
break
|
||||
elif userfeedback == 'help':
|
||||
print("Help is not yet implemented!")
|
||||
elif userfeedback == 'test.full':
|
||||
ts.full()
|
||||
elif userfeedback == 'test.smoke':
|
||||
ts.smoke()
|
||||
elif command in COMMANDS[2:]:
|
||||
h.command(userfeedback)
|
||||
elif userfeedback != "":
|
||||
|
Loading…
x
Reference in New Issue
Block a user