Added Channel names for devices

This commit is contained in:
Dirk Alders 2025-08-19 22:32:08 +02:00
parent b6433c4da8
commit 946ceead96
6 changed files with 15 additions and 40 deletions

2
devdi

@ -1 +1 @@
Subproject commit 6813ec40fe716cfc5bdab827769f8d88bfbc860e
Subproject commit 1afa4f73eee8ac5a5b1abda4d7b413a19e10019f

View File

@ -5,9 +5,9 @@ from simulation.devices import shelly as shelly_sw1
from simulation.devices import brennenstuhl_heatingvalve
from simulation.devices import my_powerplug
shelly_pro3 = None
tradfri_button = None
hue_sw_br_ct = None
silvercrest_button = None
silvercrest_motion_sensor = None
audio_status = None
@ -30,6 +30,11 @@ class tradfri_sw_br_ct(tradfri_light):
super().__init__(mqtt_client, topic, enable_state=True, enable_brightness=True, enable_color_temp=True, send_on_power_on=True)
class hue_sw_br_ct(tradfri_light):
def __init__(self, mqtt_client, topic):
super().__init__(mqtt_client, topic, enable_state=True, enable_brightness=True, enable_color_temp=True, send_on_power_on=True)
class livarno_sw_br_ct(tradfri_light):
def __init__(self, mqtt_client, topic):
super().__init__(mqtt_client, topic, enable_state=True, enable_brightness=True, enable_color_temp=True, send_on_power_on=False)

View File

@ -14,7 +14,7 @@ COLOR_WARNINGS = colored.fg("dark_orange_3b")
COLOR_HEATING_VALVE = colored.fg("red")
COLOR_REMOTE = colored.fg("green")
OUTPUT_ACTIVE = True
OUTPUT_ACTIVE = False
class base_common(mqtt_base):
@ -25,12 +25,8 @@ class base_common(mqtt_base):
def __init__(self, mqtt_client, topic, default_values=None):
super().__init__(mqtt_client, topic, default_values)
self.names = {}
self.commands = self.COMMANDS[:]
def add_channel_name(self, key, name):
self.names[key] = name
def __payload_filter__(self, payload):
try:
return json.loads(payload)
@ -282,7 +278,7 @@ class shelly(base):
def print_formatted(self, device, key, value):
if value is not None:
info = (" - %ds" % self.__output_0_auto_off__) if self.__output_0_auto_off__ is not None and value else ""
channel = "(%s%s)" % (self.names.get(key, key), info)
channel = "(%s%s)" % (self.get_name(key, key), info)
self.print_formatted_light(COLOR_SHELLY, value, channel)
def warning_state_on(self):
@ -348,7 +344,7 @@ class my_powerplug(base):
def print_formatted(self, device, key, value):
if value is not None:
self.print_formatted_light(COLOR_POWERPLUG, value, "(%s)" % self.names.get(key, "State"))
self.print_formatted_light(COLOR_POWERPLUG, value, "(%s)" % self.get_name(key, "State"))
class silvercrest_powerplug(base):
@ -393,7 +389,7 @@ class silvercrest_powerplug(base):
def print_formatted(self, device, key, value):
if value is not None:
self.print_formatted_light(COLOR_POWERPLUG, value, "(%s)" % self.names.get(key, key))
self.print_formatted_light(COLOR_POWERPLUG, value, "(%s)" % self.get_name(key, key))
class tradfri_light(base):

View File

@ -3,8 +3,6 @@ from simulation.devices import videv_light, videv_heating, videv_warnings
import inspect
from devdi import topic as props
# TODO: Add channel names for all devices in devdi! Move it from here to devdi. Adaption in other prjs required!
class base(object):
def getmembers(self, prefix=''):
@ -47,8 +45,7 @@ class gfw_floor(base):
#
self.main_light = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
self.main_light.configure(input_0_func=self.main_light.INPUT_FUNC_OUT1_TRIGGER)
self.main_light.add_channel_name(self.main_light.KEY_OUTPUT_0, "Main Light")
self.main_light_zigbee = pd.get(props.STG_ZGW, loc, roo, props.FUN_MAL) # , True, True, True, False
self.main_light_zigbee = pd.get(props.STG_ZGW, loc, roo, props.FUN_MAL)
self.main_light.add_callback(self.main_light.KEY_OUTPUT_0, True, self.main_light_zigbee.power_on)
self.main_light.add_callback(self.main_light.KEY_OUTPUT_0, False, self.main_light_zigbee.power_off)
#
@ -62,9 +59,7 @@ class gfw_marion(base):
#
self.main_light = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
self.main_light.configure(input_0_func=self.main_light.INPUT_FUNC_OUT1_TRIGGER)
self.main_light.add_channel_name(self.main_light.KEY_OUTPUT_0, "Main Light (gfw.marion)")
self.window_light = pd.get(props.STG_ZGW, loc, roo, props.FUN_WIL)
self.main_light.add_channel_name(self.main_light.KEY_OUTPUT_0, "Window Light (gfw.marion)")
self.heating_valve = pd.get(props.STG_ZGW, loc, roo, props.FUN_HEA)
@ -81,19 +76,13 @@ class gfw_dirk(base):
#
self.main_light = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
self.main_light.configure(input_0_func=self.main_light.INPUT_FUNC_OUT1_TRIGGER)
self.main_light.add_channel_name(self.main_light.KEY_OUTPUT_0, "Main Light (gfw.dirk)")
self.main_light_zigbee = pd.get(props.STG_ZGW, loc, roo, props.FUN_MAL)
self.main_light.add_callback(self.main_light.KEY_OUTPUT_0, True, self.main_light_zigbee.power_on)
self.main_light.add_callback(self.main_light.KEY_OUTPUT_0, False, self.main_light_zigbee.power_off)
self.desk_light = pd.get(props.STG_ZGW, loc, roo, props.FUN_DEL)
self.desk_light.add_channel_name(self.desk_light.KEY_OUTPUT_0, "Desk Light (gfw.dirk)")
self.pc_dock = pd.get(props.STG_ZGW, loc, roo, props.FUN_DCK)
self.my_powerplug = pd.get(props.STG_MYA, loc, roo, props.FUN_MPP)
self.my_powerplug.add_channel_name(self.my_powerplug.KEY_OUTPUT_0, "Amplifier (gfw.dirk)")
self.my_powerplug.add_channel_name(self.my_powerplug.KEY_OUTPUT_1, "Phono (gfw.dirk)")
self.my_powerplug.add_channel_name(self.my_powerplug.KEY_OUTPUT_2, "CD_Player (gfw.dirk)")
self.my_powerplug.add_channel_name(self.my_powerplug.KEY_OUTPUT_3, "Bluetooth (gfw.dirk)")
self.heating_valve = pd.get(props.STG_ZGW, loc, roo, props.FUN_HEA)
@ -124,7 +113,6 @@ class ffw_julian(base):
#
self.main_light = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
self.main_light.configure(input_0_func=self.main_light.INPUT_FUNC_OUT1_TRIGGER)
self.main_light.add_channel_name(self.main_light.KEY_OUTPUT_0, "Main Light (ffw.julian)")
self.main_light_zigbee = pd.get(props.STG_ZFW, loc, roo, props.FUN_MAL)
self.main_light.add_callback(self.main_light.KEY_OUTPUT_0, True, self.main_light_zigbee.power_on)
self.main_light.add_callback(self.main_light.KEY_OUTPUT_0, False, self.main_light_zigbee.power_off)
@ -140,7 +128,6 @@ class ffw_livingroom(base):
#
self.main_light = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
self.main_light.configure(input_0_func=self.main_light.INPUT_FUNC_OUT1_TRIGGER)
self.main_light.add_channel_name(self.main_light.KEY_OUTPUT_0, "Main Light (ffw.livingroom)")
self.main_light_zigbee = pd.get(props.STG_ZFW, loc, roo, props.FUN_MAL)
self.main_light.add_callback(self.main_light.KEY_OUTPUT_0, True, self.main_light_zigbee.power_on)
self.main_light.add_callback(self.main_light.KEY_OUTPUT_0, False, self.main_light_zigbee.power_off)
@ -156,7 +143,6 @@ class ffw_sleep(base):
#
self.main_light = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
self.main_light.configure(input_0_func=self.main_light.INPUT_FUNC_OUT1_TRIGGER)
self.main_light.add_channel_name(self.main_light.KEY_OUTPUT_0, "Main Light (ffw.sleep)")
self.main_light_zigbee = pd.get(props.STG_ZFW, loc, roo, props.FUN_MAL)
self.main_light.add_callback(self.main_light.KEY_OUTPUT_0, True, self.main_light_zigbee.power_on)
self.main_light.add_callback(self.main_light.KEY_OUTPUT_0, False, self.main_light_zigbee.power_off)
@ -182,7 +168,6 @@ class ffw_floor(base):
#
self.main_light = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
self.main_light.configure(input_0_func=self.main_light.INPUT_FUNC_OUT1_TRIGGER)
self.main_light.add_channel_name(self.main_light.KEY_OUTPUT_0, "Main Light (ffw.floor)")
#
self.videv_main_light = videv_light(mqtt_client, config.TOPIC_FFW_FLOOR_MAIN_LIGHT_VIDEV, True, False, False)
@ -203,7 +188,6 @@ class ffe_floor(base):
#
self.main_light = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
self.main_light.configure(input_0_func=self.main_light.INPUT_FUNC_OUT1_TRIGGER)
self.main_light.add_channel_name(self.main_light.KEY_OUTPUT_0, "Main Light (ffe.floor)")
#
self.videv_main_light = videv_light(mqtt_client, config.TOPIC_FFE_FLOOR_MAIN_LIGHT_VIDEV, True, False, False)
@ -216,11 +200,9 @@ class ffe_kitchen(base):
#
self.main_light = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
self.main_light.configure(input_0_func=self.main_light.INPUT_FUNC_OUT1_TRIGGER)
self.main_light.add_channel_name(self.main_light.KEY_OUTPUT_0, "Main Light (ffe.kitchen)")
self.circulation_pump = pd.get(props.STG_SHE, loc, roo, props.FUN_CIR)
self.circulation_pump.configure(input_0_func=self.main_light.INPUT_FUNC_OUT1_TRIGGER) # , output_0_auto_off=10*60)
self.circulation_pump.add_channel_name(self.circulation_pump.KEY_OUTPUT_0, "Circulation Pump (ffe.kitchen)")
#
self.videv_main_light = videv_light(mqtt_client, config.TOPIC_FFE_KITCHEN_MAIN_LIGHT_VIDEV, True, False, False)
@ -234,14 +216,11 @@ class ffe_diningroom(base):
#
self.main_light = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
self.main_light.configure(input_0_func=self.main_light.INPUT_FUNC_OUT1_TRIGGER)
self.main_light.add_channel_name(self.main_light.KEY_OUTPUT_0, "Main Light (ffe.diningroom)")
self.floor_lamp = pd.get(props.STG_ZFE, loc, roo, props.FUN_FLL)
self.floor_lamp.add_channel_name(self.floor_lamp.KEY_OUTPUT_0, "Floor Lamp (ffe.diningroom)")
if config.CHRISTMAS:
self.garland = pd.get(props.STG_ZFE, loc, roo, props.FUN_GAR)
self.garland.add_channel_name(self.garland.KEY_OUTPUT_0, "Garland (ffe.diningroom)")
#
self.videv_main_light = videv_light(mqtt_client, config.TOPIC_FFE_DININGROOM_MAIN_LIGHT_VIDEV, True, False, False)
@ -257,14 +236,12 @@ class ffe_sleep(base):
#
self.main_light = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
self.main_light.configure(input_0_func=self.main_light.INPUT_FUNC_OUT1_TRIGGER)
self.main_light.add_channel_name(self.main_light.KEY_OUTPUT_0, "Main Light (ffe.sleep)")
self.main_light_zigbee = pd.get(props.STG_ZFE, loc, roo, props.FUN_MAL)
self.main_light.add_callback(self.main_light.KEY_OUTPUT_0, True, self.main_light_zigbee.power_on)
self.main_light.add_callback(self.main_light.KEY_OUTPUT_0, False, self.main_light_zigbee.power_off)
self.bed_light_di_zigbee = pd.get(props.STG_ZFE, loc, roo, props.FUN_BLD)
self.bed_light_ma = pd.get(props.STG_ZFE, loc, roo, props.FUN_BLM)
self.bed_light_ma.add_channel_name(self.bed_light_ma.KEY_OUTPUT_0, "Bed light Marion (ffe.sleep)")
self.heating_valve = pd.get(props.STG_ZFE, loc, roo, props.FUN_HEA)
@ -284,7 +261,6 @@ class ffe_livingroom(base):
#
self.main_light = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
self.main_light.configure(input_0_func=self.main_light.INPUT_FUNC_OUT1_TRIGGER)
self.main_light.add_channel_name(self.main_light.KEY_OUTPUT_0, "Main Light (ffe.livingroom)")
self.main_light_zigbee = pd.get(props.STG_ZFE, loc, roo, props.FUN_MAL)
self.main_light.add_callback(self.main_light.KEY_OUTPUT_0, True, self.main_light_zigbee.power_on)
self.main_light.add_callback(self.main_light.KEY_OUTPUT_0, False, self.main_light_zigbee.power_off)
@ -293,9 +269,7 @@ class ffe_livingroom(base):
if config.CHRISTMAS:
self.xmas_tree = pd.get(props.STG_ZFE, loc, roo, props.FUN_XTR)
self.xmas_tree.add_channel_name(self.xmas_tree.KEY_OUTPUT_0, "Xmas-Tree (ffe.livingroom)")
self.xmas_star = pd.get(props.STG_ZFE, loc, roo, props.FUN_XST)
self.xmas_star.add_channel_name(self.xmas_star.KEY_OUTPUT_0, "Xmas-Star (ffe.livingroom)")
#
self.videv_main_light = videv_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_VIDEV, True, True, True)
@ -320,7 +294,6 @@ class stairway(base):
#
self.main_light = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
self.main_light.configure(input_0_func=self.main_light.INPUT_FUNC_OUT1_TRIGGER)
self.main_light.add_channel_name(self.main_light.KEY_OUTPUT_0, "Main Light (stairway)")
#
self.videv_main_light = videv_light(mqtt_client, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_VIDEV, True, False, False, True)

View File

@ -9,3 +9,4 @@ def add_all_testcases(ts, mc, h):
gfe(ts, mc, h)
gfw(ts, mc, h)
stw(ts, mc, h)
# TODO: GARDEN

View File

@ -19,9 +19,9 @@ def device_follow(tLogger, master, master_key, slave, slave_key, values):
# Test devices
for value in values:
tLogger.debug("Setting state of %s to %s", master.names.get(master_key, master.topic), repr(value))
tLogger.debug("Setting state of %s to %s", master.get_name(master_key, master.topic), repr(value))
master.set(master_key, value)
time.sleep(DELAY_SET_GET)
expectation = slave.get(slave_key)
time.sleep(DELAY_SET_GET)
equivalency_chk(expectation, value, tLogger, f"Value for {slave.names.get(slave_key, slave.topic)}")
equivalency_chk(expectation, value, tLogger, f"Value for {slave.get_name(slave_key, slave.topic)}")