Added room definitions for future use.
This commit is contained in:
parent
46617bc952
commit
4fa00811c6
34
devices.py
34
devices.py
@ -2,7 +2,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
from devdi import topic as props
|
||||
from devdi.topic import topic_by_props
|
||||
from devdi.topic import get_topic
|
||||
import devices
|
||||
import logging
|
||||
|
||||
@ -53,7 +53,7 @@ class base(dict):
|
||||
else:
|
||||
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:
|
||||
this_device = get_device(dty, mqtt_client, topic)
|
||||
if this_device is None:
|
||||
@ -80,7 +80,7 @@ class base(dict):
|
||||
roo (numeric): Room (see ROO_* 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]
|
||||
|
||||
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_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
|
||||
|
59
topic.py
59
topic.py
@ -45,6 +45,8 @@ STG_SHE = 4
|
||||
""" Shellies """
|
||||
STG_MYA = 5
|
||||
""" My Applications """
|
||||
STG_VDE = 6
|
||||
""" Videv Devices """
|
||||
|
||||
|
||||
#
|
||||
@ -143,33 +145,35 @@ FUN_WLI = 22
|
||||
""" Warddrobe light """
|
||||
FUN_WIL = 23
|
||||
""" Window light """
|
||||
FUN_AMP = 24
|
||||
""" Amplifier """
|
||||
FUN_CDP = 25
|
||||
""" CD Player """
|
||||
FUN_BTP = 26
|
||||
""" Bluetooth """
|
||||
FUN_PHO = 27
|
||||
""" Phono """
|
||||
|
||||
|
||||
class topic_by_props(UserString):
|
||||
def __init__(self, stg, loc, roo, fun):
|
||||
UserString.__init__(self, '/'.join([self.__stg_repr__(stg), self.__loc_repr__(loc), self.__roo_repr__(roo), self.__fun_repr__(fun)]))
|
||||
|
||||
def __stg_repr__(self, stg):
|
||||
return {
|
||||
STG_TOPIC = {
|
||||
STG_ZGW: 'zigbee_gfw',
|
||||
STG_ZFW: 'zigbee_ffw',
|
||||
STG_ZFE: 'zigbee_ffe',
|
||||
STG_SHE: 'shellies',
|
||||
STG_MYA: 'my_apps',
|
||||
}.get(stg)
|
||||
STG_VDE: 'videv',
|
||||
}
|
||||
|
||||
def __loc_repr__(self, loc):
|
||||
return {
|
||||
LOC_TOPIC = {
|
||||
LOC_GFE: 'gfe',
|
||||
LOC_GFW: 'gfw',
|
||||
LOC_FFE: 'ffe',
|
||||
LOC_FFW: 'ffw',
|
||||
LOC_GAR: 'gar',
|
||||
LOC_STW: 'stw',
|
||||
}.get(loc)
|
||||
}
|
||||
|
||||
def __roo_repr__(self, roo):
|
||||
return {
|
||||
ROO_TOPIC = {
|
||||
ROO_DIN: 'diningroom',
|
||||
ROO_KIT: 'kitchen',
|
||||
ROO_LIV: 'livingroom',
|
||||
@ -182,10 +186,9 @@ class topic_by_props(UserString):
|
||||
ROO_STG: 'groundfloor',
|
||||
ROO_STF: 'firstfloor',
|
||||
ROO_GAR: 'garden',
|
||||
}.get(roo)
|
||||
}
|
||||
|
||||
def __fun_repr__(self, fun):
|
||||
return {
|
||||
FUN_TOPIC = {
|
||||
FUN_MAL: 'main_light',
|
||||
FUN_DEL: 'desk_light',
|
||||
FUN_FLL: 'floor_light',
|
||||
@ -209,4 +212,28 @@ class topic_by_props(UserString):
|
||||
FUN_REP: 'repeater',
|
||||
FUN_WLI: 'wardrobe_light',
|
||||
FUN_WIL: 'window_light',
|
||||
}.get(fun)
|
||||
FUN_AMP: 'amplifier',
|
||||
FUN_CDP: 'cd_player',
|
||||
FUN_BTP: 'bt',
|
||||
FUN_PHO: 'phono',
|
||||
}
|
||||
|
||||
|
||||
def get_topic(stg, loc, roo, fun):
|
||||
stg_topic = STG_TOPIC[stg]
|
||||
loc_topic = LOC_TOPIC[loc]
|
||||
roo_topic = ROO_TOPIC[roo]
|
||||
fun_topic = FUN_TOPIC[fun]
|
||||
s = '/'.join([stg_topic, loc_topic, roo_topic, fun_topic])
|
||||
# TODO: /!\ Changed TOPIC in VIDEV /!\ - Remove this line after changing nodered
|
||||
if stg == STG_VDE and fun == FUN_DCK:
|
||||
s = '/'.join([stg_topic, loc_topic, roo_topic, 'pc_dock'])
|
||||
if stg == STG_VDE and fun == FUN_FLL:
|
||||
s = '/'.join([stg_topic, loc_topic, roo_topic, 'floorlamp'])
|
||||
if stg == STG_VDE and roo == ROO_STF and fun == FUN_MAL:
|
||||
import config # nopep8
|
||||
s = config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_VIDEV
|
||||
if stg == STG_VDE and fun == FUN_XTR:
|
||||
s = '/'.join([stg_topic, loc_topic, roo_topic, 'xmas_tree'])
|
||||
# TODO: /!\ Changed TOPIC in VIDEV /!\ - Remove this line after changing nodered
|
||||
return s
|
||||
|
Loading…
x
Reference in New Issue
Block a user