Added room definitions for future use.

This commit is contained in:
Dirk Alders 2025-08-25 18:33:52 +02:00
parent 46617bc952
commit 4fa00811c6
2 changed files with 91 additions and 92 deletions

View File

@ -2,7 +2,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
from devdi import topic as props from devdi import topic as props
from devdi.topic import topic_by_props from devdi.topic import get_topic
import devices import devices
import logging import logging
@ -53,7 +53,7 @@ class base(dict):
else: else:
return dev_class(mqtt_client, topic) return dev_class(mqtt_client, topic)
topic = str(topic_by_props(stg, loc, roo, fun)) topic = get_topic(stg, loc, roo, fun)
if num is None: if num is None:
this_device = get_device(dty, mqtt_client, topic) this_device = get_device(dty, mqtt_client, topic)
if this_device is None: if this_device is None:
@ -80,7 +80,7 @@ class base(dict):
roo (numeric): Room (see ROO_* in props) roo (numeric): Room (see ROO_* in props)
fun (numeric): Function (see FUN_* in props) fun (numeric): Function (see FUN_* in props)
""" """
topic = topic_by_props(stg, loc, roo, fun) topic = get_topic(stg, loc, roo, fun)
return self[topic] return self[topic]
def get_str(self, stg, loc, roo, fun): def get_str(self, stg, loc, roo, fun):
@ -240,31 +240,3 @@ class physical_devices(base):
self.add(mqtt_client, props.STG_ZFE, loc, props.ROO_STF, props.FUN_MSE, props.DTY_SMS_xxx) # Motion Sensor First Floor self.add(mqtt_client, props.STG_ZFE, loc, props.ROO_STF, props.FUN_MSE, props.DTY_SMS_xxx) # Motion Sensor First Floor
self.add(mqtt_client, props.STG_ZGW, loc, props.ROO_STG, props.FUN_MSE, props.DTY_SMS_xxx) # Motion Sensor Ground Floor self.add(mqtt_client, props.STG_ZGW, loc, props.ROO_STG, props.FUN_MSE, props.DTY_SMS_xxx) # Motion Sensor Ground Floor
class videv_devices(base):
"""
Class to create and store videv smarthome devices
"""
def __init__(self, mqtt_client):
super().__init__(self)
self.__init_gfw__(mqtt_client)
self.__init_ffw__(mqtt_client)
self.__init_ffe__(mqtt_client)
self.__init_stw__(mqtt_client)
def __init_gfw__(self, mqtt_client):
loc = props.LOC_GFW
# TODO: Add devices
def __init_ffw__(self, mqtt_client):
loc = props.LOC_FFW
# TODO: Add devices
def __init_ffe__(self, mqtt_client):
loc = props.LOC_FFE
# TODO: Add devices
def __init_stw__(self, mqtt_client):
loc = props.LOC_STW
# TODO: Add devices

149
topic.py
View File

@ -45,6 +45,8 @@ STG_SHE = 4
""" Shellies """ """ Shellies """
STG_MYA = 5 STG_MYA = 5
""" My Applications """ """ My Applications """
STG_VDE = 6
""" Videv Devices """
# #
@ -143,70 +145,95 @@ FUN_WLI = 22
""" Warddrobe light """ """ Warddrobe light """
FUN_WIL = 23 FUN_WIL = 23
""" Window light """ """ Window light """
FUN_AMP = 24
""" Amplifier """
FUN_CDP = 25
""" CD Player """
FUN_BTP = 26
""" Bluetooth """
FUN_PHO = 27
""" Phono """
class topic_by_props(UserString): STG_TOPIC = {
def __init__(self, stg, loc, roo, fun): STG_ZGW: 'zigbee_gfw',
UserString.__init__(self, '/'.join([self.__stg_repr__(stg), self.__loc_repr__(loc), self.__roo_repr__(roo), self.__fun_repr__(fun)])) STG_ZFW: 'zigbee_ffw',
STG_ZFE: 'zigbee_ffe',
STG_SHE: 'shellies',
STG_MYA: 'my_apps',
STG_VDE: 'videv',
}
def __stg_repr__(self, stg): LOC_TOPIC = {
return { LOC_GFE: 'gfe',
STG_ZGW: 'zigbee_gfw', LOC_GFW: 'gfw',
STG_ZFW: 'zigbee_ffw', LOC_FFE: 'ffe',
STG_ZFE: 'zigbee_ffe', LOC_FFW: 'ffw',
STG_SHE: 'shellies', LOC_GAR: 'gar',
STG_MYA: 'my_apps', LOC_STW: 'stw',
}.get(stg) }
def __loc_repr__(self, loc): ROO_TOPIC = {
return { ROO_DIN: 'diningroom',
LOC_GFE: 'gfe', ROO_KIT: 'kitchen',
LOC_GFW: 'gfw', ROO_LIV: 'livingroom',
LOC_FFE: 'ffe', ROO_FLO: 'floor',
LOC_FFW: 'ffw', ROO_SLP: 'sleep',
LOC_GAR: 'gar', ROO_BAT: 'bath',
LOC_STW: 'stw', ROO_DIR: 'dirk',
}.get(loc) ROO_MAR: 'marion',
ROO_JUL: 'julian',
ROO_STG: 'groundfloor',
ROO_STF: 'firstfloor',
ROO_GAR: 'garden',
}
def __roo_repr__(self, roo): FUN_TOPIC = {
return { FUN_MAL: 'main_light',
ROO_DIN: 'diningroom', FUN_DEL: 'desk_light',
ROO_KIT: 'kitchen', FUN_FLL: 'floor_light',
ROO_LIV: 'livingroom', FUN_BLD: 'bed_light_di',
ROO_FLO: 'floor', FUN_BLM: 'bed_light_ma',
ROO_SLP: 'sleep', FUN_HEA: 'heating_valve',
ROO_BAT: 'bath', FUN_MPP: 'powerplug',
ROO_DIR: 'dirk', FUN_INP: 'input_device',
ROO_MAR: 'marion', FUN_DCK: 'dock',
ROO_JUL: 'julian', FUN_CIR: 'circulation_pump',
ROO_STG: 'groundfloor', FUN_GAR: 'garland',
ROO_STF: 'firstfloor', FUN_XTR: 'xmas-tree',
ROO_GAR: 'garden', FUN_XST: 'xmas-star',
}.get(roo) FUN_MSE: 'motion_sensor',
FUN_RCA: 'remote_ctrl/RAS5',
FUN_RCC: 'remote_ctrl/EUR642100',
FUN_ASS: 'audio_status_spotify',
FUN_ASM: 'audio_status_mpd',
FUN_ASB: 'audio_status_bt',
FUN_AMB: 'ambient',
FUN_REP: 'repeater',
FUN_WLI: 'wardrobe_light',
FUN_WIL: 'window_light',
FUN_AMP: 'amplifier',
FUN_CDP: 'cd_player',
FUN_BTP: 'bt',
FUN_PHO: 'phono',
}
def __fun_repr__(self, fun):
return { def get_topic(stg, loc, roo, fun):
FUN_MAL: 'main_light', stg_topic = STG_TOPIC[stg]
FUN_DEL: 'desk_light', loc_topic = LOC_TOPIC[loc]
FUN_FLL: 'floor_light', roo_topic = ROO_TOPIC[roo]
FUN_BLD: 'bed_light_di', fun_topic = FUN_TOPIC[fun]
FUN_BLM: 'bed_light_ma', s = '/'.join([stg_topic, loc_topic, roo_topic, fun_topic])
FUN_HEA: 'heating_valve', # TODO: /!\ Changed TOPIC in VIDEV /!\ - Remove this line after changing nodered
FUN_MPP: 'powerplug', if stg == STG_VDE and fun == FUN_DCK:
FUN_INP: 'input_device', s = '/'.join([stg_topic, loc_topic, roo_topic, 'pc_dock'])
FUN_DCK: 'dock', if stg == STG_VDE and fun == FUN_FLL:
FUN_CIR: 'circulation_pump', s = '/'.join([stg_topic, loc_topic, roo_topic, 'floorlamp'])
FUN_GAR: 'garland', if stg == STG_VDE and roo == ROO_STF and fun == FUN_MAL:
FUN_XTR: 'xmas-tree', import config # nopep8
FUN_XST: 'xmas-star', s = config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_VIDEV
FUN_MSE: 'motion_sensor', if stg == STG_VDE and fun == FUN_XTR:
FUN_RCA: 'remote_ctrl/RAS5', s = '/'.join([stg_topic, loc_topic, roo_topic, 'xmas_tree'])
FUN_RCC: 'remote_ctrl/EUR642100', # TODO: /!\ Changed TOPIC in VIDEV /!\ - Remove this line after changing nodered
FUN_ASS: 'audio_status_spotify', return s
FUN_ASM: 'audio_status_mpd',
FUN_ASB: 'audio_status_bt',
FUN_AMB: 'ambient',
FUN_REP: 'repeater',
FUN_WLI: 'wardrobe_light',
FUN_WIL: 'window_light',
}.get(fun)