Reactication of smarthome tests with reduced checks

This commit is contained in:
Dirk Alders 2025-08-17 22:30:37 +02:00
parent d538cba7e9
commit 57353c18a1
16 changed files with 493 additions and 178 deletions

6
.gitmodules vendored
View File

@ -19,3 +19,9 @@
[submodule "unittest"] [submodule "unittest"]
path = unittest path = unittest
url = https://git.mount-mockery.de/pylib/unittest.git url = https://git.mount-mockery.de/pylib/unittest.git
[submodule "rspec"]
path = rspec
url = https://git.mount-mockery.de/pylib/rspec.git
[submodule "devdi"]
path = devdi
url = https://git.mount-mockery.de/smarthome/smart_devdi.git

0
.venv_required Normal file
View File

154
Makefile
View File

@ -1,45 +1,133 @@
OUTDIR=testresults # git helper Makefile: Version 2.5 (2025-08-11)
TEXFILE=$(OUTDIR)/testrun.tex default: help
PDFFILE=$(OUTDIR)/testrun.pdf
TEXFILE_FULL=$(OUTDIR)/testrun_full.tex
PDFFILE_FULL=$(OUTDIR)/testrun_full.pdf
smoke: test_smoke pdf view pdf_full clean .ONESHELL:
@echo FINISHED... SHELL = /usr/bin/bash
MAKEFLAGS += --no-print-directory
.SILENT:
short: test_short pdf view pdf_full clean -include __make.d__/*.mk
@echo FINISHED...
full: test_full pdf view pdf_full clean GIT_FLAG = ./.git
@echo FINISHED... VENV_FLAG = ./.venv_required
VENV_FOLDER = ./venv
test_smoke: localhelp:
venv/bin/python smart_brain_test.py test.all.smoke
test_short: help:
venv/bin/python smart_brain_test.py test.all.short echo "Possible common options are:"
echo " - init - Initialise the repository and all folders below with a Makefile"
echo " - giti - Get the git status of all submodules including their submodules"
echo " - update_submodules - Set all submodules to remote master"
echo " - venv_flag - Set the venev flag for the base folder. A venv will be generated"
echo " - clean - clean up"
echo " - deepclean - clean up this and all Makefiles below"
$(MAKE) localhelp
echo "You are able to create files make.d/*.mk and add local rules there. "
echo " - localinit: print_head - Will be executed as last step in the init process."
echo " - localhelp: print_head - Will be executed in th middle of the help text generation"
echo " - localclean:print_head - Will be executed before the clean rule"
test_full: localinit:
venv/bin/python smart_brain_test.py test.all.full
pdf: init: print_head
@latexmk -pdf -quiet -pdflatex="pdflatex -interaction=nonstopmode" -output-directory=$(OUTDIR) -use-make $(TEXFILE) > /dev/null # Init git repo
if [[ -e $(GIT_FLAG) ]]; then
echo -e "\033[1;33mInitialising git submodules...\e[0m"
git submodule init
git submodule update
echo
fi
# Init submodules
SUBDIRS=$$(find . -maxdepth 2 -mindepth 2 -name Makefile | sort)
for subdir in $$SUBDIRS; do
$(MAKE) --no-print-directory -C $$(dirname $$subdir) init
done
if [[ $$SUBDIRS = *[![:space:]]* ]]; then
$(MAKE) print_head
fi
# Create venv if needed
if [[ -e $(VENV_FLAG) ]]; then
BASEPATH=$$(pwd -P)
#
# Create venv
#
if [ ! -e venv ];then
echo -e "\033[1;33mCreating venv in $$BASEPATH...\e[0m"
python3 -m venv $$BASEPATH/venv > /dev/null 2>&1
else
echo -e "\033[1;33mVirtualenv already exists in $$BASEPATH...\e[0m"
fi
echo
pdf_full: #
@latexmk -pdf -quiet -pdflatex="pdflatex -interaction=nonstopmode" -output-directory=$(OUTDIR) -use-make $(TEXFILE_FULL) > /dev/null # Install modules
#
echo -e "\033[1;33mInstalling modules to venv in $$BASEPATH...\e[0m"
for req_file in $$(find -L $$BASEPATH -name requirements.txt 2> /dev/null); do
# echo " $$req_file"
while read req_mod; do
if [[ $$req_mod = *[![:space:]]* ]]; then
# req_mod is not empty
OUT=$$($$BASEPATH/venv/bin/pip install -U $$req_mod 2>&1 )
if [[ $$OUT =~ "Successfully installed" ]]; then
echo -e " * \033[1;32m$$req_mod installed.\e[0m"
elif [[ $$OUT =~ "already satisfied" ]]; then
echo -e " * \033[1;36m$$req_mod already installed.\e[0m"
else
echo -e " * \033[1;31m$$req_mod installation FAILED!\e[0m"
#echo $$OUT
fi
fi
done < $$req_file
done
echo
fi
# Start local init
echo -e "\033[1;33mDoing localinit...\e[0m"
$(MAKE) localinit
view: update_submodules:
@open $(PDFFILE) git submodule foreach "git fetch && git checkout master && git pull && git submodule init && git submodule update"
view_full: giti_this: print_head
@open $(PDFFILE_FULL) giti
echo " Submodules:"
git submodule --quiet foreach "echo -n ' ' && giti"
clean: giti:
@latexmk -quiet -output-directory=$(OUTDIR) -c $(TEXFILE) > /dev/null git submodule --quiet foreach "[ -e Makefile ] && make --no-print-directory giti_this || :"
@latexmk -quiet -output-directory=$(OUTDIR) -c $(TEXFILE_FULL) > /dev/null
@find . -name *~ -type f | xargs rm -f
@find . -name __pycache__ -type d | xargs rm -rf
%: localclean:
venv/bin/python smart_brain_test.py $@
$(MAKE) pdf_full view_full pdf clean clean: localclean
if [[ ! -e $(VENV_FLAG) ]]; then
if [[ -d $(VENV_FOLDER) ]]; then
rm -rf $(VENV_FOLDER)
fi
fi
cleanall: clean
for subdir in $$(find . -maxdepth 2 -mindepth 2 -name Makefile | sort); do
$(MAKE) --no-print-directory -C $$(dirname $$subdir) cleanall
done
venv_flag:
if [[ ! -e $(VENV_FLAG) ]]; then
touch $(VENV_FLAG)
if [[ -e $(GIT_FLAG) ]]; then
git add $(VENV_FLAG)
fi
fi
print_head:
DIRNAME=$$(basename $$(pwd))
DIRLENGTH=$${#DIRNAME}
echo -ne "\n\n\033[1;34m╔═"
for i in $$(seq 1 $$DIRLENGTH); do echo -n "═"; done
echo -e "═╗"
echo -e "$$DIRNAME ║"
echo -ne "╚═"
for i in $$(seq 1 $$DIRLENGTH); do echo -n "═"; done
echo -e "═╝\033[00m"

45
__make.d__/test.mk Normal file
View File

@ -0,0 +1,45 @@
OUTDIR=testresults
TEXFILE=$(OUTDIR)/testrun.tex
PDFFILE=$(OUTDIR)/testrun.pdf
TEXFILE_FULL=$(OUTDIR)/testrun_full.tex
PDFFILE_FULL=$(OUTDIR)/testrun_full.pdf
smoke: test_smoke pdf view pdf_full clean
@echo FINISHED...
short: test_short pdf view pdf_full clean
@echo FINISHED...
full: test_full pdf view pdf_full clean
@echo FINISHED...
test_smoke:
venv/bin/python smart_brain_test.py test.all.smoke
test_short:
venv/bin/python smart_brain_test.py test.all.short
test_full:
venv/bin/python smart_brain_test.py test.all.full
pdf:
@latexmk -pdf -quiet -pdflatex="pdflatex -interaction=nonstopmode" -output-directory=$(OUTDIR) -use-make $(TEXFILE) > /dev/null
pdf_full:
@latexmk -pdf -quiet -pdflatex="pdflatex -interaction=nonstopmode" -output-directory=$(OUTDIR) -use-make $(TEXFILE_FULL) > /dev/null
view:
@open $(PDFFILE)
view_full:
@open $(PDFFILE_FULL)
localclean:
@latexmk -quiet -output-directory=$(OUTDIR) -c $(TEXFILE) > /dev/null
@latexmk -quiet -output-directory=$(OUTDIR) -c $(TEXFILE_FULL) > /dev/null
@find . -name *~ -type f | xargs rm -f
@find . -name __pycache__ -type d | xargs rm -rf
#%:
# venv/bin/python smart_brain_test.py $@
# $(MAKE) pdf_full view_full pdf clean

1
devdi Submodule

@ -0,0 +1 @@
Subproject commit 619d7f926f13ce03950db9c5dab3461e5b7da23a

93
devices/__init__.py Normal file
View File

@ -0,0 +1,93 @@
from simulation.devices import tradfri_light
from simulation.devices import shelly as shelly_sw1
from simulation.devices import brennenstuhl_heatingvalve
class tradfri_sw(tradfri_light):
def __init__(self, mqtt_client, topic):
super().__init__(mqtt_client, topic, enable_state=True, enable_brightness=False, enable_color_temp=False, send_on_power_on=True)
class tradfri_sw_br(tradfri_light):
def __init__(self, mqtt_client, topic):
super().__init__(mqtt_client, topic, enable_state=True, enable_brightness=True, enable_color_temp=False, send_on_power_on=True)
class tradfri_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)
my_powerplug = None
shelly_pro3 = None
tradfri_button = None
hue_sw_br_ct = None
silvercrest_button = None
silvercrest_powerplug = None
silvercrest_motion_sensor = None
audio_status = None
remote = None
my_ambient = None
class group(object):
def __init__(self, *args):
super().__init__()
self._members = args
self._iter_counter = 0
#
self.methods = []
self.variables = []
for name in [m for m in args[0].__class__.__dict__.keys()]:
if not name.startswith('_') and callable(getattr(args[0], name)): # add all public callable attributes to the list
self.methods.append(name)
if not name.startswith('_') and not callable(getattr(args[0], name)): # add all public callable attributes to the list
self.variables.append(name)
#
for member in self:
methods = [m for m in member.__class__.__dict__.keys() if not m.startswith(
'_') if not m.startswith('_') and callable(getattr(args[0], m))]
if self.methods != methods:
raise ValueError("All given instances needs to have same methods:", self.methods, methods)
#
variables = [v for v in member.__class__.__dict__.keys() if not v.startswith(
'_') if not v.startswith('_') and not callable(getattr(args[0], v))]
if self.variables != variables:
raise ValueError("All given instances needs to have same variables:", self.variables, variables)
def __iter__(self):
return self
def __next__(self):
if self._iter_counter < len(self):
self._iter_counter += 1
return self._members[self._iter_counter - 1]
self._iter_counter = 0
raise StopIteration
def __getitem__(self, i):
return self._members[i]
def __len__(self):
return len(self._members)
def __getattribute__(self, name):
def group_execution(*args, **kwargs):
for member in self[:]:
m = getattr(member, name)
m(*args, **kwargs)
try:
rv = super().__getattribute__(name)
except AttributeError:
if callable(getattr(self[0], name)):
return group_execution
else:
return getattr(self[0], name)
else:
return rv

2
mqtt

@ -1 +1 @@
Subproject commit 1adfb0626e7777c6d29be65d4ad4ce2d57541301 Subproject commit 95dda53a55b40591bbd5200ae5ea8c354610b913

1
rspec Submodule

@ -0,0 +1 @@
Subproject commit 871ea528c0bc9e686a5c0fa4936a2ed715a5b54e

View File

@ -1,6 +1,5 @@
from base import mqtt_base from base import mqtt_base
import colored import colored
import copy
import json import json
import task import task
import time import time
@ -166,14 +165,14 @@ class shelly(base):
"toggle_overtemperature", "toggle_overtemperature",
] ]
def __init__(self, mqtt_client, topic, input_0_func=None, input_1_func=None, output_0_auto_off=None): def __init__(self, mqtt_client, topic):
super().__init__(mqtt_client, topic, default_values={self.KEY_OUTPUT_0: False, self.KEY_OUTPUT_1: False, super().__init__(mqtt_client, topic, default_values={self.KEY_OUTPUT_0: False, self.KEY_OUTPUT_1: False,
self.KEY_INPUT_0: False, self.KEY_INPUT_1: False, self.KEY_INPUT_0: False, self.KEY_INPUT_1: False,
self.KEY_TEMPERATURE: 35.2, self.KEY_OVERTEMPERATURE: False}) self.KEY_TEMPERATURE: 35.2, self.KEY_OVERTEMPERATURE: False})
# #
self.__input_0_func = input_0_func self.__input_0_func = None
self.__input_1_func = input_1_func self.__input_1_func = None
self.__output_0_auto_off__ = output_0_auto_off self.__output_0_auto_off__ = None
# print ouput changes # print ouput changes
self.add_callback(self.KEY_OUTPUT_0, None, self.print_formatted, True) self.add_callback(self.KEY_OUTPUT_0, None, self.print_formatted, True)
self.add_callback(self.KEY_OUTPUT_1, None, self.print_formatted, True) self.add_callback(self.KEY_OUTPUT_1, None, self.print_formatted, True)
@ -192,6 +191,11 @@ class shelly(base):
# #
self.__tx__((self.KEY_OUTPUT_0, self.KEY_OUTPUT_1)) self.__tx__((self.KEY_OUTPUT_0, self.KEY_OUTPUT_1))
def configure(self, input_0_func=None, input_1_func=None, output_0_auto_off=None):
self.__input_0_func = input_0_func
self.__input_1_func = input_1_func
self.__output_0_auto_off__ = output_0_auto_off
def __int_to_ext__(self, key, value): def __int_to_ext__(self, key, value):
if key == self.KEY_OVERTEMPERATURE: if key == self.KEY_OVERTEMPERATURE:
return int(value) return int(value)
@ -498,7 +502,7 @@ class tradfri_light(base):
) )
class brennenstuhl_heating_valve(base): class brennenstuhl_heatingvalve(base):
TEMP_RANGE = [10, 30] TEMP_RANGE = [10, 30]
# #
KEY_TEMPERATURE_SETPOINT = "current_heating_setpoint" KEY_TEMPERATURE_SETPOINT = "current_heating_setpoint"

View File

@ -1,7 +1,7 @@
import config import config
from simulation.devices import shelly, silvercrest_powerplug, tradfri_light, my_powerplug, brennenstuhl_heating_valve
from simulation.devices import videv_light, videv_heating, videv_warnings from simulation.devices import videv_light, videv_heating, videv_warnings
import inspect import inspect
from devdi import topic as props
class base(object): class base(object):
@ -39,26 +39,35 @@ class base(object):
class gfw_floor(base): class gfw_floor(base):
def __init__(self, mqtt_client): def __init__(self, mqtt_client, pd):
self.main_light = shelly(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER) loc = props.LOC_GFW
self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light") roo = props.ROO_FLO
self.main_light_zigbee_1 = tradfri_light(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_ZIGBEE % 1, True, True, True, False) #
self.main_light.add_callback(shelly.KEY_OUTPUT_0, True, self.main_light_zigbee_1.power_on) self.main_light = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
self.main_light.add_callback(shelly.KEY_OUTPUT_0, False, self.main_light_zigbee_1.power_off) self.main_light.configure(input_0_func=self.main_light.INPUT_FUNC_OUT1_TRIGGER)
self.main_light_zigbee_2 = tradfri_light(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_ZIGBEE % 2, True, True, True, False) self.main_light.add_channel_name(self.main_light.KEY_OUTPUT_0, "Main Light")
self.main_light.add_callback(shelly.KEY_OUTPUT_0, True, self.main_light_zigbee_2.power_on) self.main_light_zigbee = pd.get(props.STG_ZGW, loc, roo, props.FUN_MAL) # , True, True, True, False
self.main_light.add_callback(shelly.KEY_OUTPUT_0, False, self.main_light_zigbee_2.power_off) 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)
# TODO: Ist "self.main_light_zigbee" schon eine Gruppe???
# self.main_light_zigbee_2 = tradfri_light(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_ZIGBEE % 2, True, True, True, False)
# self.main_light.add_callback(self.main_light.KEY_OUTPUT_0, True, self.main_light_zigbee_2.power_on)
# self.main_light.add_callback(self.main_light.KEY_OUTPUT_0, False, self.main_light_zigbee_2.power_off)
# #
self.videv_main_light = videv_light(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_VIDEV, True, True, True) self.videv_main_light = videv_light(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_VIDEV, True, True, True)
class gfw_marion(base): class gfw_marion(base):
def __init__(self, mqtt_client): def __init__(self, mqtt_client, pd):
self.main_light = shelly(mqtt_client, config.TOPIC_GFW_MARION_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER) loc = props.LOC_GFW
self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light") roo = props.ROO_MAR
#
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.heating_valve = brennenstuhl_heating_valve(mqtt_client, config.TOPIC_GFW_MARION_HEATING_VALVE_ZIGBEE) self.heating_valve = pd.get(props.STG_ZGW, loc, roo, props.FUN_HEA)
# #
self.videv_main_light = videv_light(mqtt_client, config.TOPIC_GFW_MARION_MAIN_LIGHT_VIDEV, True, False, False) self.videv_main_light = videv_light(mqtt_client, config.TOPIC_GFW_MARION_MAIN_LIGHT_VIDEV, True, False, False)
@ -66,111 +75,140 @@ class gfw_marion(base):
class gfw_dirk(base): class gfw_dirk(base):
def __init__(self, mqtt_client): def __init__(self, mqtt_client, pd):
self.main_light = shelly(mqtt_client, config.TOPIC_GFW_DIRK_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER) loc = props.LOC_GFW
self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light") roo = props.ROO_DIR
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, True, self.main_light_zigbee.power_on) self.main_light = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
self.main_light.add_callback(shelly.KEY_OUTPUT_0, False, self.main_light_zigbee.power_off) 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)
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.amplifier = my_powerplug(mqtt_client, config.TOPIC_GFW_DIRK_POWERPLUG, 0) # TODO: Add this again...
self.amplifier.add_channel_name(my_powerplug.KEY_OUTPUT_0, "Amplifier") # self.amplifier = my_powerplug(mqtt_client, config.TOPIC_GFW_DIRK_POWERPLUG, 0)
self.desk_light = my_powerplug(mqtt_client, config.TOPIC_GFW_DIRK_POWERPLUG, 1) # self.amplifier.add_channel_name(self.amplifier.KEY_OUTPUT_0, "Amplifier")
self.desk_light.add_channel_name(my_powerplug.KEY_OUTPUT_0, "Desk Light") # self.desk_light = my_powerplug(mqtt_client, config.TOPIC_GFW_DIRK_POWERPLUG, 1)
self.cd_player = my_powerplug(mqtt_client, config.TOPIC_GFW_DIRK_POWERPLUG, 2) # self.desk_light.add_channel_name(self.desk_light.KEY_OUTPUT_0, "Desk Light")
self.cd_player.add_channel_name(my_powerplug.KEY_OUTPUT_0, "CD_Player") # self.cd_player = my_powerplug(mqtt_client, config.TOPIC_GFW_DIRK_POWERPLUG, 2)
self.pc_dock = my_powerplug(mqtt_client, config.TOPIC_GFW_DIRK_POWERPLUG, 3) # self.cd_player.add_channel_name(self.cd_player.KEY_OUTPUT_0, "CD_Player")
self.pc_dock.add_channel_name(my_powerplug.KEY_OUTPUT_0, "PC_Dock") # self.pc_dock = my_powerplug(mqtt_client, config.TOPIC_GFW_DIRK_POWERPLUG, 3)
self.desk_light_zigbee = tradfri_light(mqtt_client, config.TOPIC_GFW_DIRK_DESK_LIGHT_ZIGBEE, True, True, True) # self.pc_dock.add_channel_name(self.pc_dock.KEY_OUTPUT_0, "PC_Dock")
self.desk_light.add_callback(my_powerplug.KEY_OUTPUT_0, True, self.desk_light_zigbee.power_on) # self.desk_light_zigbee = tradfri_light(mqtt_client, config.TOPIC_GFW_DIRK_DESK_LIGHT_ZIGBEE, True, True, True)
self.desk_light.add_callback(my_powerplug.KEY_OUTPUT_0, False, self.desk_light_zigbee.power_off) # self.desk_light.add_callback(self.amplifier.KEY_OUTPUT_0, True, self.desk_light_zigbee.power_on)
# self.desk_light.add_callback(self.amplifier.KEY_OUTPUT_0, False, self.desk_light_zigbee.power_off)
self.heating_valve = brennenstuhl_heating_valve(mqtt_client, config.TOPIC_GFW_DIRK_HEATING_VALVE_ZIGBEE) self.heating_valve = pd.get(props.STG_ZGW, loc, roo, props.FUN_HEA)
# #
self.videv_main_light = videv_light(mqtt_client, config.TOPIC_GFW_DIRK_MAIN_LIGHT_VIDEV, True, True, True) self.videv_main_light = videv_light(mqtt_client, config.TOPIC_GFW_DIRK_MAIN_LIGHT_VIDEV, True, True, True)
self.videv_amplifier = videv_light(mqtt_client, config.TOPIC_GFW_DIRK_AMPLIFIER_VIDEV, True, False, False) # TODO: Add this again...
self.videv_desk_light = videv_light(mqtt_client, config.TOPIC_GFW_DIRK_DESK_LIGHT_VIDEV, True, True, True) # self.videv_amplifier = videv_light(mqtt_client, config.TOPIC_GFW_DIRK_AMPLIFIER_VIDEV, True, False, False)
self.videv_cd_player = videv_light(mqtt_client, config.TOPIC_GFW_DIRK_CD_PLAYER_VIDEV, True, False, False) # self.videv_desk_light = videv_light(mqtt_client, config.TOPIC_GFW_DIRK_DESK_LIGHT_VIDEV, True, True, True)
self.videv_pc_dock = videv_light(mqtt_client, config.TOPIC_GFW_DIRK_PC_DOCK_VIDEV, True, False, False) # self.videv_cd_player = videv_light(mqtt_client, config.TOPIC_GFW_DIRK_CD_PLAYER_VIDEV, True, False, False)
# self.videv_pc_dock = videv_light(mqtt_client, config.TOPIC_GFW_DIRK_PC_DOCK_VIDEV, True, False, False)
self.videv_heating = videv_heating(mqtt_client, config.TOPIC_GFW_DIRK_HEATING_VALVE_VIDEV) self.videv_heating = videv_heating(mqtt_client, config.TOPIC_GFW_DIRK_HEATING_VALVE_VIDEV)
class gfw(base): class gfw(base):
def __init__(self, mqtt_client): def __init__(self, mqtt_client, pd):
self.floor = gfw_floor(mqtt_client) self.floor = gfw_floor(mqtt_client, pd)
self.marion = gfw_marion(mqtt_client) self.marion = gfw_marion(mqtt_client, pd)
self.dirk = gfw_dirk(mqtt_client) self.dirk = gfw_dirk(mqtt_client, pd)
class ffw_julian(base): class ffw_julian(base):
def __init__(self, mqtt_client): def __init__(self, mqtt_client, pd):
self.main_light = shelly(mqtt_client, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER) loc = props.LOC_FFW
self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light") roo = props.ROO_JUL
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, True, self.main_light_zigbee.power_on) self.main_light = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
self.main_light.add_callback(shelly.KEY_OUTPUT_0, False, self.main_light_zigbee.power_off) 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_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)
# #
self.videv_main_light = videv_light(mqtt_client, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_VIDEV, True, True, True) self.videv_main_light = videv_light(mqtt_client, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_VIDEV, True, True, True)
class ffw_livingroom(base): class ffw_livingroom(base):
def __init__(self, mqtt_client): def __init__(self, mqtt_client, pd):
self.main_light = shelly(mqtt_client, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER) loc = props.LOC_FFW
self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light") roo = props.ROO_LIV
self.main_light_zigbee = tradfri_light(mqtt_client, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_ZIGBEE, True, True, True) #
self.main_light.add_callback(shelly.KEY_OUTPUT_0, True, self.main_light_zigbee.power_on) self.main_light = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
self.main_light.add_callback(shelly.KEY_OUTPUT_0, False, self.main_light_zigbee.power_off) 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_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)
# #
self.videv_main_light = videv_light(mqtt_client, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_VIDEV, True, True, True) self.videv_main_light = videv_light(mqtt_client, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_VIDEV, True, True, True)
class ffw_sleep(base): class ffw_sleep(base):
def __init__(self, mqtt_client): def __init__(self, mqtt_client, pd):
self.main_light = shelly(mqtt_client, config.TOPIC_FFW_SLEEP_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER) loc = props.LOC_FFW
self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light") roo = props.ROO_SLP
self.main_light_zigbee = tradfri_light(mqtt_client, config.TOPIC_FFW_SLEEP_MAIN_LIGHT_ZIGBEE, True, True, True) #
self.main_light.add_callback(shelly.KEY_OUTPUT_0, True, self.main_light_zigbee.power_on) self.main_light = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
self.main_light.add_callback(shelly.KEY_OUTPUT_0, False, self.main_light_zigbee.power_off) 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_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)
# #
self.videv_main_light = videv_light(mqtt_client, config.TOPIC_FFW_SLEEP_MAIN_LIGHT_VIDEV, True, True, False) self.videv_main_light = videv_light(mqtt_client, config.TOPIC_FFW_SLEEP_MAIN_LIGHT_VIDEV, True, True, False)
class ffw_bath(base): class ffw_bath(base):
def __init__(self, mqtt_client): def __init__(self, mqtt_client, pd):
self.heating_valve = brennenstuhl_heating_valve(mqtt_client, config.TOPIC_FFW_BATH_HEATING_VALVE_ZIGBEE) loc = props.LOC_FFW
roo = props.ROO_BAT
#
self.heating_valve = pd.get(props.STG_ZFW, loc, roo, props.FUN_HEA)
# #
self.videv_heating = videv_heating(mqtt_client, config.TOPIC_FFW_BATH_HEATING_VALVE_VIDEV) self.videv_heating = videv_heating(mqtt_client, config.TOPIC_FFW_BATH_HEATING_VALVE_VIDEV)
class ffw(base): class ffw(base):
def __init__(self, mqtt_client): def __init__(self, mqtt_client, pd):
self.julian = ffw_julian(mqtt_client) self.julian = ffw_julian(mqtt_client, pd)
self.livingroom = ffw_livingroom(mqtt_client) self.livingroom = ffw_livingroom(mqtt_client, pd)
self.sleep = ffw_sleep(mqtt_client) self.sleep = ffw_sleep(mqtt_client, pd)
self.bath = ffw_bath(mqtt_client) self.bath = ffw_bath(mqtt_client, pd)
class ffe_floor(base): class ffe_floor(base):
def __init__(self, mqtt_client): def __init__(self, mqtt_client, pd):
self.main_light = shelly(mqtt_client, config.TOPIC_FFE_FLOOR_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER) loc = props.LOC_FFE
self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light") roo = props.ROO_FLO
#
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.videv_main_light = videv_light(mqtt_client, config.TOPIC_FFE_FLOOR_MAIN_LIGHT_VIDEV, True, False, False) self.videv_main_light = videv_light(mqtt_client, config.TOPIC_FFE_FLOOR_MAIN_LIGHT_VIDEV, True, False, False)
class ffe_kitchen(base): class ffe_kitchen(base):
def __init__(self, mqtt_client): def __init__(self, mqtt_client, pd):
self.main_light = shelly(mqtt_client, config.TOPIC_FFE_KITCHEN_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER) loc = props.LOC_FFE
self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light") roo = props.ROO_KIT
#
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.circulation_pump = shelly(mqtt_client, config.TOPIC_FFE_KITCHEN_CIRCULATION_PUMP_SHELLY, self.circulation_pump = pd.get(props.STG_SHE, loc, roo, props.FUN_CIR)
input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER, output_0_auto_off=10*60) 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(shelly.KEY_OUTPUT_0, "Circulation Pump") self.circulation_pump.add_channel_name(self.circulation_pump.KEY_OUTPUT_0, "Circulation Pump")
# #
self.videv_main_light = videv_light(mqtt_client, config.TOPIC_FFE_KITCHEN_MAIN_LIGHT_VIDEV, True, False, False) self.videv_main_light = videv_light(mqtt_client, config.TOPIC_FFE_KITCHEN_MAIN_LIGHT_VIDEV, True, False, False)
@ -178,92 +216,114 @@ class ffe_kitchen(base):
class ffe_diningroom(base): class ffe_diningroom(base):
def __init__(self, mqtt_client): def __init__(self, mqtt_client, pd):
self.main_light = shelly(mqtt_client, config.TOPIC_FFE_DININGROOM_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER) loc = props.LOC_FFE
self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light") roo = props.ROO_DIN
#
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.floor_lamp = silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_DININGROOM_FLOOR_LAMP_POWERPLUG) # TODO: Add this again...
self.floor_lamp.add_channel_name(silvercrest_powerplug.KEY_OUTPUT_0, "Floor Lamp") # self.floor_lamp = silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_DININGROOM_FLOOR_LAMP_POWERPLUG)
# self.floor_lamp.add_channel_name(self.floor_lamp.KEY_OUTPUT_0, "Floor Lamp")
if config.CHRISTMAS: # if config.CHRISTMAS:
self.garland = silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_DININGROOM_GARLAND_POWERPLUG) # self.garland = silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_DININGROOM_GARLAND_POWERPLUG)
self.garland.add_channel_name(silvercrest_powerplug, "Garland") # self.garland.add_channel_name(self.garland, "Garland")
# #
self.videv_main_light = videv_light(mqtt_client, config.TOPIC_FFE_DININGROOM_MAIN_LIGHT_VIDEV, True, False, False) # self.videv_main_light = videv_light(mqtt_client, config.TOPIC_FFE_DININGROOM_MAIN_LIGHT_VIDEV, True, False, False)
self.videv_floor_lamp = videv_light(mqtt_client, config.TOPIC_FFE_DININGROOM_FLOOR_LAMP_VIDEV, True, False, False) # self.videv_floor_lamp = videv_light(mqtt_client, config.TOPIC_FFE_DININGROOM_FLOOR_LAMP_VIDEV, True, False, False)
if config.CHRISTMAS: # if config.CHRISTMAS:
self.videv_garland = videv_light(mqtt_client, config.TOPIC_FFE_DININGROOM_GARLAND_VIDEV, True, False, False) # self.videv_garland = videv_light(mqtt_client, config.TOPIC_FFE_DININGROOM_GARLAND_VIDEV, True, False, False)
class ffe_sleep(base): class ffe_sleep(base):
def __init__(self, mqtt_client): def __init__(self, mqtt_client, pd):
self.main_light = shelly(mqtt_client, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER) loc = props.LOC_FFE
self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light") roo = props.ROO_SLP
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, True, self.main_light_zigbee.power_on) self.main_light = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
self.main_light.add_callback(shelly.KEY_OUTPUT_0, False, self.main_light_zigbee.power_off) 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_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 = tradfri_light(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_DI_ZIGBEE, True, True, False) # TODO: Add this again...
self.bed_light_ma = silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_MA_POWERPLUG) # self.bed_light_di_zigbee = tradfri_light(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_DI_ZIGBEE, True, True, False)
# self.bed_light_ma = silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_MA_POWERPLUG)
self.heating_valve = brennenstuhl_heating_valve(mqtt_client, config.TOPIC_FFE_SLEEP_HEATING_VALVE_ZIGBEE) self.heating_valve = pd.get(props.STG_ZFE, loc, roo, props.FUN_HEA)
# #
self.videv_bed_light_ma = videv_light(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_MA_VIDEV, True, False, False)
self.videv_main_light = videv_light(mqtt_client, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_VIDEV, True, True, True) self.videv_main_light = videv_light(mqtt_client, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_VIDEV, True, True, True)
self.videv_bed_light_di = videv_light(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_DI_VIDEV, True, True, False) # TODO: Add this again...
self.videv_bed_light_ma = videv_light(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_MA_VIDEV, True, False, False) # self.videv_bed_light_ma = videv_light(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_MA_VIDEV, True, False, False)
# self.videv_bed_light_di = videv_light(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_DI_VIDEV, True, True, False)
# self.videv_bed_light_ma = videv_light(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_MA_VIDEV, True, False, False)
self.videv_heating = videv_heating(mqtt_client, config.TOPIC_FFE_SLEEP_HEATING_VALVE_VIDEV) self.videv_heating = videv_heating(mqtt_client, config.TOPIC_FFE_SLEEP_HEATING_VALVE_VIDEV)
class ffe_livingroom(base): class ffe_livingroom(base):
def __init__(self, mqtt_client): def __init__(self, mqtt_client, pd):
self.main_light = shelly(mqtt_client, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER) loc = props.LOC_FFE
self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light") roo = props.ROO_LIV
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, True, self.main_light_zigbee.power_on) self.main_light = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
self.main_light.add_callback(shelly.KEY_OUTPUT_0, False, self.main_light_zigbee.power_off) 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_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)
for i in range(1, 7): # TODO: Add this again...
setattr(self, "floor_lamp_zigbee_%d" % i, tradfri_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_ZIGBEE % i, True, True, True)) # for i in range(1, 7):
# setattr(self, "floor_lamp_zigbee_%d" % i, tradfri_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_ZIGBEE % i, True, True, True))
if config.CHRISTMAS: # if config.CHRISTMAS:
self.xmas_tree = silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_TREE_POWERPLUG) # 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.xmas_tree.add_channel_name(self.xmas_tree, "Xmas-Tree")
self.xmas_star = silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_STAR_POWERPLUG) # self.xmas_star = silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_STAR_POWERPLUG)
self.xmas_star.add_channel_name(silvercrest_powerplug, "Xmas-Star") # self.xmas_star.add_channel_name(self.xmas_star, "Xmas-Star")
# #
self.videv_main_light = videv_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_VIDEV, True, True, True) self.videv_main_light = videv_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_VIDEV, True, True, True)
self.videv_floor_lamp = videv_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_VIDEV, True, True, True) # TODO: Add this again...
if config.CHRISTMAS: # self.videv_floor_lamp = videv_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_VIDEV, True, True, True)
self.videv_xmas_tree = videv_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_TREE_VIDEV) # if config.CHRISTMAS:
# self.videv_xmas_tree = videv_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_TREE_VIDEV)
class ffe(base): class ffe(base):
def __init__(self, mqtt_client): def __init__(self, mqtt_client, pd):
self.floor = ffe_floor(mqtt_client) self.floor = ffe_floor(mqtt_client, pd)
self.kitchen = ffe_kitchen(mqtt_client) self.kitchen = ffe_kitchen(mqtt_client, pd)
self.diningroom = ffe_diningroom(mqtt_client) self.diningroom = ffe_diningroom(mqtt_client, pd)
self.sleep = ffe_sleep(mqtt_client) self.sleep = ffe_sleep(mqtt_client, pd)
self.livingroom = ffe_livingroom(mqtt_client) self.livingroom = ffe_livingroom(mqtt_client, pd)
class stairway(base): class stairway(base):
def __init__(self, mqtt_client): def __init__(self, mqtt_client, pd):
self.main_light = shelly(mqtt_client, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER) loc = props.LOC_STW
self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light") roo = props.ROO_STF
#
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.videv_main_light = videv_light(mqtt_client, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_VIDEV, True, False, False, True) self.videv_main_light = videv_light(mqtt_client, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_VIDEV, True, False, False, True)
class house(base): class house(base):
def __init__(self, mqtt_client): def __init__(self, mqtt_client, pd):
self.gfw = gfw(mqtt_client) self.gfw = gfw(mqtt_client, pd)
self.ffw = ffw(mqtt_client) self.ffw = ffw(mqtt_client, pd)
self.ffe = ffe(mqtt_client) self.ffe = ffe(mqtt_client, pd)
self.stairway = stairway(mqtt_client) self.stairway = stairway(mqtt_client, pd)
self.warnings = videv_warnings(mqtt_client, config.TOPIC_WARNINGS) # TODO: Add this again...
# self.warnings = videv_warnings(mqtt_client, pd, config.TOPIC_WARNINGS)

View File

@ -1,10 +1,13 @@
import config import config
import devdi.devices
import mqtt import mqtt
import readline import readline
from simulation.rooms import house from simulation.rooms import house
import sys import sys
from tests.all import test_smarthome from tests.all import test_smarthome
# TODO: Reimplement failed test(s)
# TODO: Reimplement existing test
# TODO: Extend tests in simulation # TODO: Extend tests in simulation
# - Test: Check of warning messages for battery and overtemperature # - Test: Check of warning messages for battery and overtemperature
# - Switching button functions (gfw_dirk, ffe.sleep) # - Switching button functions (gfw_dirk, ffe.sleep)
@ -16,12 +19,20 @@ from tests.all import test_smarthome
# - Stairways (Extend Motion sensor and Timer) # - Stairways (Extend Motion sensor and Timer)
if __name__ == "__main__": if __name__ == "__main__":
#
# MQTT Client
#
mc = mqtt.mqtt_client(host=config.MQTT_SERVER, port=config.MQTT_PORT, username=config.MQTT_USER, 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') password=config.MQTT_PASSWORD, name=config.APP_NAME + '_simulation')
#
# Smarthome physical Devices
#
pd = devdi.devices.physical_devices(mc)
# #
COMMANDS = ['quit', 'help'] COMMANDS = ['quit', 'help']
# #
h = house(mc) h = house(mc, pd)
for name in h.getmembers(): for name in h.getmembers():
d = h.getobjbyname(name) d = h.getobjbyname(name)
for c in d.capabilities(): for c in d.capabilities():

View File

@ -46,6 +46,8 @@ class test_smarthome(object):
common_name = '.'.join(name.split('.')[:-1]) + '.' + name.split('.')[-1][6:] common_name = '.'.join(name.split('.')[:-1]) + '.' + name.split('.')[-1][6:]
heat_device = rooms.getobjbyname(common_name + '_valve') heat_device = rooms.getobjbyname(common_name + '_valve')
setattr(self, common_name.replace('.', '_'), testcase_heating(self.tcl, obj, heat_device)) setattr(self, common_name.replace('.', '_'), testcase_heating(self.tcl, obj, heat_device))
# TODO: Add this again...
"""
# synchronisation # synchronisation
# gfw.dirk.amplifier with cd_player # gfw.dirk.amplifier with cd_player
self.gfw_dirk_cd_player_amplifier_sync = testcase_synchronisation( self.gfw_dirk_cd_player_amplifier_sync = testcase_synchronisation(
@ -70,6 +72,7 @@ class test_smarthome(object):
*[getattr(rooms.ffe.livingroom, "floor_lamp_zigbee_%d" % i) for i in range(1, 7)] *[getattr(rooms.ffe.livingroom, "floor_lamp_zigbee_%d" % i) for i in range(1, 7)]
) )
# add test collection # add test collection
"""
self.all = test_collection(self) self.all = test_collection(self)
def __init__tcl__(self): def __init__tcl__(self):

View File

@ -11,7 +11,7 @@ class testcase_heating(testcase):
super().__init__(tcl) super().__init__(tcl)
self.__videv__ = videv self.__videv__ = videv
self.__valve__ = valve self.__valve__ = valve
self.__default_temperature__ = config.DEFAULT_TEMPERATURE.get(self.__valve__.topic) self.__default_temperature__ = config.DEFAULT_TEMPERATURE
self.__test_list__ = ["test_user_temperature_setpoint", "test_default_temperature", "test_summer_mode", "test_away_mode", "test_boost_mode"] self.__test_list__ = ["test_user_temperature_setpoint", "test_default_temperature", "test_summer_mode", "test_away_mode", "test_boost_mode"]
def test_user_temperature_setpoint(self, tcel=report.TCEL_FULL): def test_user_temperature_setpoint(self, tcel=report.TCEL_FULL):
@ -19,7 +19,7 @@ class testcase_heating(testcase):
if tcel != report.TCEL_SMOKE or not self.METHOD_EXECUTED.get(fname, False): if tcel != report.TCEL_SMOKE or not self.METHOD_EXECUTED.get(fname, False):
self.METHOD_EXECUTED[fname] = True self.METHOD_EXECUTED[fname] = True
# #
self.tcl.testCase("User temperature setpoint test for device and virtual device: %s" % self.tcl.testCase("User temperature setpoint test for virtual device and device: %s" %
self.__valve__.topic, tcel, self.__test_user_temperature_setpoint__, tcel) self.__valve__.topic, tcel, self.__test_user_temperature_setpoint__, tcel)
def __test_user_temperature_setpoint__(self, tLogger, tcel): def __test_user_temperature_setpoint__(self, tLogger, tcel):
@ -28,13 +28,15 @@ class testcase_heating(testcase):
delta = 5 if setp < mtemp else -5 delta = 5 if setp < mtemp else -5
for i in range(0, 2): for i in range(0, 2):
self.__valve__.set(self.__valve__.KEY_TEMPERATURE_SETPOINT, setp + delta) self.__videv__.set(self.__videv__.KEY_USER_TEMPERATURE_SETPOINT, setp + delta)
time.sleep(DT_TOGGLE) time.sleep(DT_TOGGLE)
tLogger.debug("Changing valve temperature setpoint to '%.1f'", setp + delta) tLogger.debug("Changing valve temperature setpoint to '%.1f'", setp + delta)
equivalency_chk(self.__videv__.get(self.__videv__.KEY_VALVE_TEMPERATURE_SETPOINT), equivalency_chk(self.__videv__.get(self.__videv__.KEY_VALVE_TEMPERATURE_SETPOINT),
setp + delta, tLogger, "Virtual device valve temperature") setp + delta, tLogger, "Virtual device valve temperature")
equivalency_chk(self.__videv__.get(self.__videv__.KEY_USER_TEMPERATURE_SETPOINT), equivalency_chk(self.__videv__.get(self.__videv__.KEY_USER_TEMPERATURE_SETPOINT),
setp + delta, tLogger, "Virtual device user temperature") setp + delta, tLogger, "Virtual device user temperature")
equivalency_chk(self.__valve__.get(self.__valve__.KEY_TEMPERATURE_SETPOINT),
setp + delta, tLogger, "Valve temperature setpoint")
# #
self.__videv__.set(self.__videv__.KEY_USER_TEMPERATURE_SETPOINT, setp) self.__videv__.set(self.__videv__.KEY_USER_TEMPERATURE_SETPOINT, setp)
time.sleep(DT_TOGGLE) time.sleep(DT_TOGGLE)
@ -51,11 +53,11 @@ class testcase_heating(testcase):
self.__valve__.topic, tcel, self.__test_default_temperature__, tcel) self.__valve__.topic, tcel, self.__test_default_temperature__, tcel)
def __test_default_temperature__(self, tLogger, tcel): def __test_default_temperature__(self, tLogger, tcel):
dtemp = config.DEFAULT_TEMPERATURE.get(self.__valve__.topic) dtemp = config.DEFAULT_TEMPERATURE
mtemp = round(self.__valve__.TEMP_RANGE[0] + (self.__valve__.TEMP_RANGE[1] - self.__valve__.TEMP_RANGE[0]) / 2, 1) mtemp = round(self.__valve__.TEMP_RANGE[0] + (self.__valve__.TEMP_RANGE[1] - self.__valve__.TEMP_RANGE[0]) / 2, 1)
ptemp = dtemp + (5 if dtemp < mtemp else -5) ptemp = dtemp + (5 if dtemp < mtemp else -5)
self.__valve__.set(self.__valve__.KEY_TEMPERATURE_SETPOINT, ptemp) self.__videv__.set(self.__videv__.KEY_USER_TEMPERATURE_SETPOINT, config.DEFAULT_TEMPERATURE - 5)
time.sleep(DT_TOGGLE) time.sleep(DT_TOGGLE)
tLogger.debug("Setting preconditions (Valve setpoint to %.1f)", ptemp) tLogger.debug("Setting preconditions (Valve setpoint to %.1f)", ptemp)

View File

@ -50,7 +50,7 @@ class testcase_light(testcase):
self.tcl.testCase("Brightness test for device and virtual device: %s" % self.li_device.topic, tcel, self.__test_brightness__, tcel) self.tcl.testCase("Brightness test for device and virtual device: %s" % self.li_device.topic, tcel, self.__test_brightness__, tcel)
def __test_brightness__(self, tLogger, tcel): def __test_brightness__(self, tLogger, tcel):
br_state = self.li_device.get(self.li_device.KEY_BRIGHTNESS) br_state = self.li_device.get(self.li_device.KEY_BRIGHTNESS) or 50 # if br_state is None
delta = -15 if br_state > 50 else 15 delta = -15 if br_state > 50 else 15
self.sw_device.set(self.sw_device.KEY_OUTPUT_0, True) self.sw_device.set(self.sw_device.KEY_OUTPUT_0, True)
time.sleep(DT_TOGGLE) time.sleep(DT_TOGGLE)
@ -81,7 +81,7 @@ class testcase_light(testcase):
self.tcl.testCase("Color temperature test for device and virtual device: %s" % self.li_device.topic, tcel, self.__test_color_temp__, tcel) self.tcl.testCase("Color temperature test for device and virtual device: %s" % self.li_device.topic, tcel, self.__test_color_temp__, tcel)
def __test_color_temp__(self, tLogger, tcel): def __test_color_temp__(self, tLogger, tcel):
ct_state = self.li_device.get(self.li_device.KEY_COLOR_TEMP) ct_state = self.li_device.get(self.li_device.KEY_COLOR_TEMP) or 5 # Use 5 if None
delta = -3 if ct_state > 5 else 3 delta = -3 if ct_state > 5 else 3
self.sw_device.set(self.sw_device.KEY_OUTPUT_0, True) self.sw_device.set(self.sw_device.KEY_OUTPUT_0, True)
time.sleep(DT_TOGGLE) time.sleep(DT_TOGGLE)

1
topics.py Symbolic link
View File

@ -0,0 +1 @@
../smart_brain/topics.py

@ -1 +1 @@
Subproject commit a73c8f8c3523df17eeddad6297d1454c16fc4552 Subproject commit e5282ac16addbe4d6e59f4a7accaac6b73b469ee