Some simulation improvements (e.g. shelly input output linkage)
This commit is contained in:
parent
d2db60ac5b
commit
5f00c13710
@ -3,12 +3,10 @@ import json
|
||||
import sys
|
||||
import time
|
||||
|
||||
# TODO: implement my powerplug
|
||||
|
||||
COLOR_GUI_ACTIVE = colored.fg("light_blue")
|
||||
COLOR_GUI_PASSIVE = COLOR_GUI_ACTIVE + colored.attr("dim")
|
||||
COLOR_SHELLY_1 = colored.fg("light_magenta")
|
||||
COLOR_SHELLY_2 = colored.fg("light_cyan")
|
||||
COLOR_SHELLY = colored.fg("light_magenta")
|
||||
COLOR_POWERPLUG = colored.fg("light_cyan")
|
||||
COLOR_LIGHT_ACTIVE = colored.fg("yellow")
|
||||
COLOR_LIGHT_PASSIVE = COLOR_LIGHT_ACTIVE + colored.attr("dim")
|
||||
COLOR_MOTION_SENSOR = colored.fg("red")
|
||||
@ -46,6 +44,7 @@ class base(object):
|
||||
#
|
||||
self.data = {}
|
||||
self.callbacks = {}
|
||||
self.names = {}
|
||||
self.commands = self.COMMANDS[:]
|
||||
#
|
||||
self.mqtt_client.add_callback(self.topic, self.__rx__)
|
||||
@ -56,6 +55,9 @@ class base(object):
|
||||
self.callbacks[key] = []
|
||||
self.callbacks[key].append((callback, value))
|
||||
|
||||
def add_channel_name(self, key, name):
|
||||
self.names[key] = name
|
||||
|
||||
def capabilities(self):
|
||||
return self.commands
|
||||
|
||||
@ -81,49 +83,113 @@ class base(object):
|
||||
class shelly(base):
|
||||
KEY_OUTPUT_0 = "relay/0"
|
||||
KEY_OUTPUT_1 = "relay/1"
|
||||
KEY_INPUT_0 = "input/0"
|
||||
KEY_INPUT_1 = "input/1"
|
||||
KEY_LONGPUSH_0 = "longpush/0"
|
||||
KEY_LONGPUSH_1 = "longpush/1"
|
||||
#
|
||||
INPUT_FUNC_OUT1_FOLLOW = "out1_follow"
|
||||
INPUT_FUNC_OUT1_TRIGGER = "out1_trigger"
|
||||
INPUT_FUNC_OUT2_FOLLOW = "out2_follow"
|
||||
INPUT_FUNC_OUT2_TRIGGER = "out2_trigger"
|
||||
#
|
||||
COMMANDS = [
|
||||
"get_relay_0", "set_relay_0", "unset_relay_0",
|
||||
"get_relay_1", "set_relay_1", "unset_relay_1",
|
||||
"get_relay_0", "toggle_relay_0",
|
||||
"get_relay_1", "toggle_relay_1",
|
||||
"get_input_0", "trigger_input_0",
|
||||
"get_input_1", "trigger_input_1",
|
||||
"trigger_long_input_0", "trigger_long_input_1",
|
||||
]
|
||||
|
||||
def __init__(self, mqtt_client, topic):
|
||||
def __init__(self, mqtt_client, topic, input_0_func=None, input_1_func=None):
|
||||
super().__init__(mqtt_client, topic)
|
||||
#
|
||||
self.store_data(**{self.KEY_OUTPUT_0: "off", self.KEY_OUTPUT_1: "off"})
|
||||
self.store_data(**{self.KEY_OUTPUT_0: "off", self.KEY_OUTPUT_1: "off", self.KEY_INPUT_0: "off", self.KEY_INPUT_1: "off"})
|
||||
self.__input_0_func = input_0_func
|
||||
self.__input_1_func = input_1_func
|
||||
#
|
||||
self.add_callback(self.KEY_OUTPUT_0, self.print_formatted, None)
|
||||
self.add_callback(self.KEY_OUTPUT_1, self.print_formatted, None)
|
||||
#
|
||||
self.add_callback(self.KEY_INPUT_0, self.__input_function__, None)
|
||||
self.add_callback(self.KEY_INPUT_1, self.__input_function__, None)
|
||||
|
||||
def __rx__(self, client, userdata, message):
|
||||
value = payload_filter(message.payload)
|
||||
if message.topic == self.topic + "/relay/0/command":
|
||||
if value in ['on', 'off']:
|
||||
self.store_data(**{self.KEY_OUTPUT_0: value})
|
||||
elif value == 'toggle':
|
||||
self.store_data(**{self.KEY_OUTPUT_0: 'on' if self.data.get(self.KEY_OUTPUT_0) == 'off' else 'off'})
|
||||
elif message.topic == self.topic + "/relay/1/command":
|
||||
if value in ['on', 'off']:
|
||||
self.store_data(**{self.KEY_OUTPUT_1: value})
|
||||
elif value == 'toggle':
|
||||
self.store_data(**{self.KEY_OUTPUT_1: 'on' if self.data.get(self.KEY_OUTPUT_1) == 'off' else 'off'})
|
||||
if message.topic.startswith(self.topic) and message.topic.endswith("/command"):
|
||||
key = '/'.join(message.topic.split('/')[-3:-1])
|
||||
if value == 'toggle':
|
||||
self.__toggle_data__(key)
|
||||
else:
|
||||
self.__set_data__(key, value)
|
||||
|
||||
def __tx__(self, keys_changed):
|
||||
for key in keys_changed:
|
||||
self.mqtt_client.send(self.topic + '/' + key, self.data.get(key))
|
||||
|
||||
def __input_function__(self, device, key, data):
|
||||
if key == self.KEY_INPUT_0:
|
||||
func = self.__input_0_func
|
||||
elif key == self.KEY_INPUT_1:
|
||||
func = self.__input_1_func
|
||||
else:
|
||||
func = None
|
||||
if func == self.INPUT_FUNC_OUT1_FOLLOW:
|
||||
self.__set_data__(self.KEY_OUTPUT_0, data)
|
||||
elif func == self.INPUT_FUNC_OUT1_TRIGGER and data == 'on':
|
||||
print("Triggered Output 0 by Input 0")
|
||||
self.__toggle_data__(self.KEY_OUTPUT_0)
|
||||
elif func == self.INPUT_FUNC_OUT2_FOLLOW:
|
||||
self.__set_data__(self.KEY_OUTPUT_1, data)
|
||||
elif func == self.INPUT_FUNC_OUT2_TRIGGER and data == 'on':
|
||||
self.__toggle_data__(self.KEY_OUTPUT_1)
|
||||
|
||||
def __set_data__(self, key, value):
|
||||
if value in ["on", "off"]:
|
||||
self.store_data(**{key: value})
|
||||
else:
|
||||
print("Wrong value (%s)!" % repr(value))
|
||||
|
||||
def __toggle_data__(self, key):
|
||||
if key in self.data:
|
||||
self.__set_data__(key, 'on' if self.data.get(key) == 'off' else 'off')
|
||||
|
||||
def command(self, command):
|
||||
if command in self.COMMANDS:
|
||||
if command == self.COMMANDS[0]:
|
||||
self.print_formatted(self, self.KEY_OUTPUT_0, self.data.get(self.KEY_OUTPUT_0))
|
||||
elif command == self.COMMANDS[1]:
|
||||
self.store_data(**{self.KEY_OUTPUT_0: "on"})
|
||||
self.__toggle_data__(self.KEY_OUTPUT_0)
|
||||
elif command == self.COMMANDS[2]:
|
||||
self.store_data(**{self.KEY_OUTPUT_0: "off"})
|
||||
elif command == self.COMMANDS[3]:
|
||||
self.print_formatted(self, self.KEY_OUTPUT_1, self.data.get(self.KEY_OUTPUT_1))
|
||||
elif command == self.COMMANDS[3]:
|
||||
self.__toggle_data__(self.KEY_OUTPUT_1)
|
||||
elif command == self.COMMANDS[4]:
|
||||
self.store_data(**{self.KEY_OUTPUT_1: "on"})
|
||||
self.print_formatted(self, self.KEY_INPUT_0, self.data.get(self.KEY_INPUT_0))
|
||||
elif command == self.COMMANDS[5]:
|
||||
self.store_data(**{self.KEY_OUTPUT_1: "off"})
|
||||
self.__set_data__(self.KEY_INPUT_0, 'on')
|
||||
time.sleep(0.2)
|
||||
self.__set_data__(self.KEY_INPUT_0, 'off')
|
||||
elif command == self.COMMANDS[6]:
|
||||
self.print_formatted(self, self.KEY_INPUT_1, self.data.get(self.KEY_INPUT_1))
|
||||
elif command == self.COMMANDS[7]:
|
||||
self.__set_data__(self.KEY_INPUT_1, 'on')
|
||||
time.sleep(0.2)
|
||||
self.__set_data__(self.KEY_INPUT_1, 'off')
|
||||
elif command == self.COMMANDS[8]:
|
||||
self.__set_data__(self.KEY_INPUT_0, 'on')
|
||||
time.sleep(0.4)
|
||||
self.__set_data__(self.KEY_LONGPUSH_0, 'on')
|
||||
time.sleep(0.1)
|
||||
self.__set_data__(self.KEY_LONGPUSH_0, 'off')
|
||||
self.__set_data__(self.KEY_INPUT_0, 'off')
|
||||
elif command == self.COMMANDS[9]:
|
||||
self.__set_data__(self.KEY_INPUT_1, 'on')
|
||||
time.sleep(0.4)
|
||||
self.__set_data__(self.KEY_LONGPUSH_1, 'on')
|
||||
time.sleep(0.1)
|
||||
self.__set_data__(self.KEY_LONGPUSH_1, 'off')
|
||||
self.__set_data__(self.KEY_INPUT_1, 'off')
|
||||
else:
|
||||
print("%s: not yet implemented!" % command)
|
||||
else:
|
||||
@ -131,41 +197,43 @@ class shelly(base):
|
||||
|
||||
def print_formatted(self, device, key, value):
|
||||
if value is not None:
|
||||
if key == shelly.KEY_OUTPUT_0:
|
||||
color = COLOR_SHELLY_1
|
||||
else:
|
||||
color = COLOR_SHELLY_2
|
||||
if value == "on":
|
||||
print(color + 10 * ' ' + u'\u2b24' + 6 * ' ' + " - ".join(self.topic.split('/')[1:]) + colored.attr("reset"))
|
||||
else:
|
||||
print(color + 10 * ' ' + u'\u25ef' + 6 * ' ' + " - ".join(self.topic.split('/')[1:]) + colored.attr("reset"))
|
||||
icon = u'\u2b24' if value == "on" else u'\u25ef'
|
||||
channel = "(%s)" % self.names.get(key, key)
|
||||
devicename = " - ".join(self.topic.split('/')[1:])
|
||||
print(COLOR_SHELLY + 10 * ' ' + icon + 6 * ' ' + devicename + ' ' + channel + colored.attr("reset"))
|
||||
|
||||
|
||||
class my_powerplug(base):
|
||||
KEY_OUTPUT_0 = "0"
|
||||
KEY_OUTPUT_1 = "1"
|
||||
KEY_OUTPUT_2 = "2"
|
||||
KEY_OUTPUT_3 = "3"
|
||||
COMMANDS = [
|
||||
"get_state", "set_state", "unset_state",
|
||||
"get_output_0", "toggle_output_0",
|
||||
"get_output_1", "toggle_output_1",
|
||||
"get_output_2", "toggle_output_2",
|
||||
"get_output_3", "toggle_output_3",
|
||||
]
|
||||
|
||||
def __init__(self, mqtt_client, topic, names=[]):
|
||||
def __init__(self, mqtt_client, topic):
|
||||
super().__init__(mqtt_client, topic)
|
||||
#
|
||||
self.names = []
|
||||
#
|
||||
for i in range(0, 4):
|
||||
self.data[str(i)] = False
|
||||
try:
|
||||
self.names.append(names[i])
|
||||
except IndexError:
|
||||
self.names.append("Channel %d" % (i + 1))
|
||||
self.add_callback(str(i), self.print_formatted, None)
|
||||
|
||||
def __rx__(self, client, userdata, message):
|
||||
if message.topic.startswith(self.topic + '/output/') and message.topic.endswith('/set'):
|
||||
channel = int(message.topic.split('/')[-2]) - 1
|
||||
payload = payload_filter(message.payload)
|
||||
if payload == "toggle":
|
||||
payload = not self.data.get(str(channel))
|
||||
self.store_data(**{str(channel): payload})
|
||||
try:
|
||||
channels = [int(message.topic.split('/')[-2]) - 1]
|
||||
except ValueError:
|
||||
channels = range(0, 4)
|
||||
for channel in channels:
|
||||
payload = payload_filter(message.payload)
|
||||
print(channel, payload)
|
||||
if payload == "toggle":
|
||||
payload = not self.data.get(str(channel))
|
||||
self.store_data(**{str(channel): payload})
|
||||
|
||||
def __tx__(self, keys_changed):
|
||||
for key in keys_changed:
|
||||
@ -176,9 +244,19 @@ class my_powerplug(base):
|
||||
if command == self.COMMANDS[0]:
|
||||
self.print_formatted(self, self.KEY_OUTPUT_0, self.data.get(self.KEY_OUTPUT_0))
|
||||
elif command == self.COMMANDS[1]:
|
||||
self.store_data(**{self.KEY_OUTPUT_0: 'on'})
|
||||
self.store_data(**{self.KEY_OUTPUT_0: not self.data.get(self.KEY_OUTPUT_0)})
|
||||
elif command == self.COMMANDS[2]:
|
||||
self.store_data(**{self.KEY_OUTPUT_0: 'off'})
|
||||
self.print_formatted(self, self.KEY_OUTPUT_1, self.data.get(self.KEY_OUTPUT_1))
|
||||
elif command == self.COMMANDS[3]:
|
||||
self.store_data(**{self.KEY_OUTPUT_1: not self.data.get(self.KEY_OUTPUT_1)})
|
||||
elif command == self.COMMANDS[4]:
|
||||
self.print_formatted(self, self.KEY_OUTPUT_2, self.data.get(self.KEY_OUTPUT_2))
|
||||
elif command == self.COMMANDS[5]:
|
||||
self.store_data(**{self.KEY_OUTPUT_2: not self.data.get(self.KEY_OUTPUT_2)})
|
||||
elif command == self.COMMANDS[6]:
|
||||
self.print_formatted(self, self.KEY_OUTPUT_3, self.data.get(self.KEY_OUTPUT_3))
|
||||
elif command == self.COMMANDS[7]:
|
||||
self.store_data(**{self.KEY_OUTPUT_3: not self.data.get(self.KEY_OUTPUT_3)})
|
||||
else:
|
||||
print("%s: not yet implemented!" % command)
|
||||
else:
|
||||
@ -186,12 +264,10 @@ class my_powerplug(base):
|
||||
|
||||
def print_formatted(self, device, key, value):
|
||||
if value is not None:
|
||||
if value:
|
||||
print(COLOR_SHELLY_1 + 10 * ' ' + u'\u2b24' + 6 * ' ' + " - ".join(self.topic.split('/')
|
||||
[1:]) + " (%s)" % self.names[int(key)] + colored.attr("reset"))
|
||||
else:
|
||||
print(COLOR_SHELLY_1 + 10 * ' ' + u'\u25ef' + 6 * ' ' + " - ".join(self.topic.split('/')
|
||||
[1:]) + " (%s)" % self.names[int(key)] + colored.attr("reset"))
|
||||
icon = u'\u2b24' if value else u'\u25ef'
|
||||
channel = "(%s)" % self.names.get(key, "Channel %d" % (int(key) + 1))
|
||||
devicename = " - ".join(self.topic.split('/')[1:])
|
||||
print(COLOR_POWERPLUG + 10 * ' ' + icon + 6 * ' ' + devicename + ' ' + channel + colored.attr("reset"))
|
||||
|
||||
|
||||
class silvercrest_powerplug(base):
|
||||
@ -235,10 +311,10 @@ class silvercrest_powerplug(base):
|
||||
|
||||
def print_formatted(self, device, key, value):
|
||||
if value is not None:
|
||||
if value == "on":
|
||||
print(COLOR_SHELLY_1 + 10 * ' ' + u'\u2b24' + 6 * ' ' + " - ".join(self.topic.split('/')[1:]) + colored.attr("reset"))
|
||||
else:
|
||||
print(COLOR_SHELLY_1 + 10 * ' ' + u'\u25ef' + 6 * ' ' + " - ".join(self.topic.split('/')[1:]) + colored.attr("reset"))
|
||||
icon = u'\u2b24' if value == "on" else u'\u25ef'
|
||||
channel = "(%s)" % self.names.get(key, key)
|
||||
devicename = " - ".join(self.topic.split('/')[1:])
|
||||
print(COLOR_POWERPLUG + 10 * ' ' + icon + 6 * ' ' + devicename + ' ' + channel + colored.attr("reset"))
|
||||
|
||||
|
||||
class silvercrest_motion_sensor(base):
|
||||
@ -279,7 +355,7 @@ class tradfri_light(base):
|
||||
KEY_COLOR_TEMP = "color_temp"
|
||||
KEY_BRIGHTNESS_MOVE = "brightness_move"
|
||||
#
|
||||
STATE_COMMANDS = ("get_state", "change_state", )
|
||||
STATE_COMMANDS = ("get_state", "toggle_state", )
|
||||
BRIGHTNESS_COMMANDS = ("get_brightness", "set_brightness",)
|
||||
COLOR_TEMP_COMMANDS = ("get_color_temp", "set_color_temp",)
|
||||
|
||||
@ -530,16 +606,11 @@ class gui_led_array(base):
|
||||
KEY_LED_8 = "led8"
|
||||
KEY_LED_9 = "led9"
|
||||
|
||||
def __init__(self, mqtt_client, topic, names=[]):
|
||||
def __init__(self, mqtt_client, topic, ):
|
||||
super().__init__(mqtt_client, topic)
|
||||
self.names = {}
|
||||
for i in range(0, 10):
|
||||
key = getattr(self, "KEY_LED_%d" % i)
|
||||
self.data[key] = False
|
||||
try:
|
||||
self.names[key] = names[i]
|
||||
except IndexError:
|
||||
self.names[key] = key
|
||||
self.add_callback(key, self.print_formatted, None)
|
||||
|
||||
def __rx__(self, client, userdata, message):
|
||||
@ -552,9 +623,7 @@ class gui_led_array(base):
|
||||
print("Unknown key %s in %s" % (targetkey, self.__class__.__name__))
|
||||
|
||||
def print_formatted(self, device, key, value):
|
||||
if value:
|
||||
color = colored.fg('green')
|
||||
else:
|
||||
color = ""
|
||||
print(color + 10 * ' ' + u"\u2b24" + 6 * ' ' + COLOR_GUI_ACTIVE +
|
||||
' - '.join(self.topic.split('/')[:-1]) + ' (%s)' % self.names[key] + colored.attr("reset"))
|
||||
color = colored.fg('green') if value else ""
|
||||
channel = '(%s)' % self.names.get(key, key)
|
||||
devicename = ' - '.join(self.topic.split('/')[1:-1])
|
||||
print(color + 10 * ' ' + u"\u2b24" + 6 * ' ' + COLOR_GUI_ACTIVE + devicename + ' ' + channel + colored.attr("reset"))
|
||||
|
@ -2,12 +2,10 @@ import config
|
||||
from __simulation__.devices import shelly, silvercrest_powerplug, gui_light, tradfri_light, tradfri_button, gui_led_array, silvercrest_motion_sensor, my_powerplug
|
||||
import inspect
|
||||
|
||||
# TODO: ffe_floor: Implement longpress shelly
|
||||
# TODO: gfw_dirk: Implement 2nd input for floor light
|
||||
# TODO: ffe_sleep: Implement heating valve
|
||||
# TODO: gfw_dirk: Add at least brightness amplifier remote feedback to console
|
||||
# TODO: ffe_diningroom: Implement garland gui_switch
|
||||
# TODO: ffe_kitchen: Implement circulation pump
|
||||
# TODO: ffe_kitchen: Implement circulation pump (incl. shelly auto off function)
|
||||
|
||||
|
||||
class base(object):
|
||||
@ -47,7 +45,8 @@ 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.main_light = shelly(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_SHELLY)
|
||||
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)
|
||||
self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee_1.power_on, "on")
|
||||
self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee_1.power_off, "off")
|
||||
@ -60,19 +59,25 @@ class gfw_floor(base):
|
||||
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.main_light = shelly(mqtt_client, config.TOPIC_GFW_MARION_MAIN_LIGHT_SHELLY)
|
||||
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.main_light = shelly(mqtt_client, config.TOPIC_GFW_DIRK_MAIN_LIGHT_SHELLY)
|
||||
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, ["Amplifier", "Desk Light", "CD-Player", "PC-Dock"])
|
||||
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)
|
||||
@ -80,7 +85,10 @@ class gfw_dirk(base):
|
||||
self.gui_switch_pc_dock = gui_light(mqtt_client, config.TOPIC_GFW_DIRK_PC_DOCK_GUI_SWITCH, True, False, False)
|
||||
#
|
||||
self.input_device = tradfri_button(mqtt_client, config.TOPIC_GFW_DIRK_INPUT_DEVICE)
|
||||
self.led_array = gui_led_array(mqtt_client, config.TOPIC_GFW_DIRK_DEVICE_CHOOSER_LED, ["Main Light", "Desk Light", "Amplifier"])
|
||||
self.led_array = gui_led_array(mqtt_client, config.TOPIC_GFW_DIRK_DEVICE_CHOOSER_LED)
|
||||
self.led_array.add_channel_name(gui_led_array.KEY_LED_0, "Main Light")
|
||||
self.led_array.add_channel_name(gui_led_array.KEY_LED_1, "Desk Light")
|
||||
self.led_array.add_channel_name(gui_led_array.KEY_LED_2, "Amplifier")
|
||||
|
||||
|
||||
class gfw(base):
|
||||
@ -93,7 +101,8 @@ 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.main_light = shelly(mqtt_client, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_SHELLY)
|
||||
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")
|
||||
@ -103,7 +112,8 @@ class ffw_julian(base):
|
||||
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.main_light = shelly(mqtt_client, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_SHELLY)
|
||||
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")
|
||||
|
||||
|
||||
class ffw(base):
|
||||
@ -115,28 +125,34 @@ 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.main_light = shelly(mqtt_client, config.TOPIC_FFE_FLOOR_MAIN_LIGHT_SHELLY)
|
||||
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.main_light = shelly(mqtt_client, config.TOPIC_FFE_KITCHEN_MAIN_LIGHT_SHELLY)
|
||||
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")
|
||||
|
||||
|
||||
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.main_light = shelly(mqtt_client, config.TOPIC_FFE_DININGROOM_MAIN_LIGHT_SHELLY)
|
||||
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.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")
|
||||
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.main_light = shelly(mqtt_client, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_SHELLY)
|
||||
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")
|
||||
@ -147,13 +163,16 @@ class ffe_sleep(base):
|
||||
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, ["Main Light", "Bed Light Dirk"])
|
||||
self.led_array = gui_led_array(mqtt_client, config.TOPIC_FFE_SLEEP_DEVICE_CHOOSER_LED)
|
||||
self.led_array.add_channel_name(gui_led_array.KEY_LED_0, "Main Light")
|
||||
self.led_array.add_channel_name(gui_led_array.KEY_LED_1, "Bed Light Dirk")
|
||||
|
||||
|
||||
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.main_light = shelly(mqtt_client, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_SHELLY)
|
||||
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")
|
||||
@ -176,7 +195,8 @@ 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.main_light = shelly(mqtt_client, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_SHELLY)
|
||||
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)
|
||||
self.motion_sensor_ff = silvercrest_motion_sensor(mqtt_client, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_MOTION_SENSOR_FF)
|
||||
|
||||
|
@ -66,5 +66,7 @@ if __name__ == "__main__":
|
||||
print("Help is not yet implemented!")
|
||||
elif command in COMMANDS[2:]:
|
||||
h.command(userfeedback)
|
||||
else:
|
||||
elif userfeedback != "":
|
||||
print("Unknown command!")
|
||||
else:
|
||||
print()
|
||||
|
Loading…
x
Reference in New Issue
Block a user