337 lines
15 KiB
Python

import config
import report
import time
from mqtt import mqtt_client
from simulation.rooms import house
from .help import testSession
from .help import STATES_SW, STATES_BR, STATES_CT, STATES_TEMP
from tests.common_testcases import device_follow
# TODO: Compare with nodered capabilities and remove todos in code
def device_follow_sw(ts, master, slave, master_ch=0, slave_ch=0, single=False):
master_key = getattr(master, "KEY_OUTPUT_%d" % master_ch)
slave_key = getattr(slave, "KEY_OUTPUT_%d" % slave_ch)
#
master_name = master.get_name(master_key)
slave_name = slave.get_name(slave_key)
#
testcase_id = master_name + " -> " + slave_name
ts.testCase(
testcase_id, report.TCEL_SINGLE if single else report.TCEL_SMOKE, device_follow,
master, master_key,
slave, slave_key,
STATES_SW, None
)
def device_follow_br(ts, master, slave, switch_on=None, single=False):
master_name = master.get_name(master.KEY_BRIGHTNESS)
slave_name = slave.get_name(slave.KEY_BRIGHTNESS)
#
testcase_id = master_name + " -> " + slave_name
ts.testCase(
testcase_id, report.TCEL_SINGLE if single else report.TCEL_SMOKE, device_follow,
master, master.KEY_BRIGHTNESS,
slave, slave.KEY_BRIGHTNESS,
STATES_BR, switch_on
)
def device_follow_ct(ts, master, slave, switch_on=None, single=False):
master_name = master.get_name(master.KEY_COLOR_TEMP)
slave_name = slave.get_name(slave.KEY_COLOR_TEMP)
#
testcase_id = master_name + " -> " + slave_name
ts.testCase(
testcase_id, report.TCEL_SINGLE if single else report.TCEL_SMOKE, device_follow,
master, master.KEY_COLOR_TEMP,
slave, slave.KEY_COLOR_TEMP,
STATES_CT, switch_on
)
def device_follow_temp(ts, master, slave, single=False):
master_name = master.get_name(master.KEY_USER_TEMPERATURE_SETPOINT)
slave_name = slave.get_name(slave.KEY_TEMPERATURE_SETPOINT)
#
testcase_id = master_name + " -> " + slave_name
ts.testCase(
testcase_id, report.TCEL_SINGLE if single else report.TCEL_SMOKE, device_follow,
master, master.KEY_USER_TEMPERATURE_SETPOINT,
slave, slave.KEY_TEMPERATURE_SETPOINT,
STATES_TEMP, None
)
def preconditions(ts: testSession, mc: mqtt_client, h: house):
def precond_test(tLogger):
mc.send("videv/all/oof", True)
time.sleep(0.5)
tLogger.debug("Collecting precondition logs...")
# Clean-Up
ts.testCase('Clean-Up', report.TCEL_SINGLE, precond_test)
def ffe(ts: testSession, mc: mqtt_client, h: house):
#
# ffe.livingroom
#
room = h.ffe.livingroom
# Switching devices ##################################
# main_light videv<-->shelly
device_follow_sw(ts, room.videv_main_light, room.main_light)
device_follow_sw(ts, room.main_light, room.videv_main_light)
# floor_lamp videv<->zigbee + main_light->zigbee
device_follow_sw(ts, room.videv_floor_lamp, room.floor_lamp_zigbee)
device_follow_sw(ts, room.floor_lamp_zigbee, room.videv_floor_lamp)
device_follow_sw(ts, room.main_light, room.floor_lamp_zigbee)
# xmas_tree videv<-->shelly
if config.CHRISTMAS:
device_follow_sw(ts, room.videv_xmas_tree, room.xmas_tree)
device_follow_sw(ts, room.xmas_tree, room.videv_xmas_tree)
# Brightness and Colortemperature ####################
device_follow_br(ts, room.videv_main_light, room.main_light_zigbee, room.main_light)
device_follow_br(ts, room.main_light_zigbee, room.videv_main_light, room.main_light)
device_follow_ct(ts, room.videv_main_light, room.main_light_zigbee, room.main_light)
device_follow_ct(ts, room.main_light_zigbee, room.videv_main_light, room.main_light)
device_follow_br(ts, room.videv_floor_lamp, room.floor_lamp_zigbee, room.floor_lamp_zigbee)
device_follow_br(ts, room.floor_lamp_zigbee, room.videv_floor_lamp, room.floor_lamp_zigbee)
device_follow_ct(ts, room.videv_floor_lamp, room.floor_lamp_zigbee, room.floor_lamp_zigbee)
device_follow_ct(ts, room.floor_lamp_zigbee, room.videv_floor_lamp, room.floor_lamp_zigbee)
# Temperature ########################################
device_follow_temp(ts, room.videv_heating, room.heating_valve)
#
# ffe.sleep
#
room = h.ffe.sleep
# Switching devices ##################################
# main_light videv<-->shelly
device_follow_sw(ts, room.videv_main_light, room.main_light)
device_follow_sw(ts, room.main_light, room.videv_main_light)
# bed_light_di videv<-->zigbee
device_follow_sw(ts, room.videv_bed_light_di, room.bed_light_di_zigbee)
device_follow_sw(ts, room.bed_light_di_zigbee, room.videv_bed_light_di)
#
device_follow_sw(ts, room.videv_bed_light_ma, room.bed_light_ma)
device_follow_sw(ts, room.bed_light_ma, room.videv_bed_light_ma)
# Brightness and Colortemperature ####################
device_follow_br(ts, room.videv_main_light, room.main_light_zigbee, room.main_light)
device_follow_br(ts, room.main_light_zigbee, room.videv_main_light, room.main_light)
device_follow_ct(ts, room.videv_main_light, room.main_light_zigbee, room.main_light)
device_follow_ct(ts, room.main_light_zigbee, room.videv_main_light, room.main_light)
device_follow_br(ts, room.videv_bed_light_di, room.bed_light_di_zigbee, room.bed_light_di_zigbee)
device_follow_br(ts, room.bed_light_di_zigbee, room.videv_bed_light_di, room.bed_light_di_zigbee)
# TODO: Wardrobe
# Temperature ########################################
device_follow_temp(ts, room.videv_heating, room.heating_valve)
#
# ffe.diningroom
#
room = h.ffe.diningroom
# Switching devices ##################################
# main_light videv<-->shelly
device_follow_sw(ts, room.videv_main_light, room.main_light)
device_follow_sw(ts, room.main_light, room.videv_main_light)
# floor_lamp videv<->zigbee + main_light->zigbee
device_follow_sw(ts, room.videv_floor_lamp, room.floor_lamp)
device_follow_sw(ts, room.floor_lamp, room.videv_floor_lamp)
device_follow_sw(ts, room.main_light, room.floor_lamp)
# garland
if config.CHRISTMAS:
device_follow_sw(ts, room.videv_garland, room.garland)
device_follow_sw(ts, room.garland, room.videv_garland)
#
# ffe.kitchen
#
room = h.ffe.kitchen
# Switching devices ##################################
# main_light videv<-->shelly
device_follow_sw(ts, room.videv_main_light, room.main_light)
device_follow_sw(ts, room.main_light, room.videv_main_light)
# circulation_pump
device_follow_sw(ts, room.videv_circulation_pump, room.circulation_pump)
device_follow_sw(ts, room.circulation_pump, room.videv_circulation_pump)
# Brightness and Colortemperature ####################
# TODO: device_follow_br(ts, room.videv_main_light, room.main_light_zigbee, room.main_light)
# TODO: device_follow_br(ts, room.main_light_zigbee, room.videv_main_light, room.main_light)
# TODO: device_follow_ct(ts, room.videv_main_light, room.main_light_zigbee, room.main_light)
# TODO: device_follow_ct(ts, room.main_light_zigbee, room.videv_main_light, room.main_light)
# Temperature ########################################
device_follow_temp(ts, room.videv_heating, room.heating_valve)
#
# ffe.floor
#
# Switching devices ##################################
room = h.ffe.floor
# main_light videv<-->shelly
device_follow_sw(ts, room.videv_main_light, room.main_light)
device_follow_sw(ts, room.main_light, room.videv_main_light)
def ffw(ts: testSession, mc: mqtt_client, h: house):
#
# ffw.livingroom
#
room = h.ffw.livingroom
# Switching devices ##################################
# main_light videv<-->shelly
device_follow_sw(ts, room.videv_main_light, room.main_light)
device_follow_sw(ts, room.main_light, room.videv_main_light)
# Brightness and Colortemperature ####################
device_follow_br(ts, room.videv_main_light, room.main_light_zigbee, room.main_light)
device_follow_br(ts, room.main_light_zigbee, room.videv_main_light, room.main_light)
device_follow_ct(ts, room.videv_main_light, room.main_light_zigbee, room.main_light)
device_follow_ct(ts, room.main_light_zigbee, room.videv_main_light, room.main_light)
# Temperature ########################################
device_follow_temp(ts, room.videv_heating, room.heating_valve)
#
# ffw.sleep
#
room = h.ffw.sleep
# Switching devices ##################################
# main_light videv<-->shelly
device_follow_sw(ts, room.videv_main_light, room.main_light)
device_follow_sw(ts, room.main_light, room.videv_main_light)
# TODO: window_light
# Brightness and Colortemperature ####################
device_follow_br(ts, room.videv_main_light, room.main_light_zigbee, room.main_light)
device_follow_br(ts, room.main_light_zigbee, room.videv_main_light, room.main_light)
# Temperature ########################################
device_follow_temp(ts, room.videv_heating, room.heating_valve)
#
# ffw.julian
#
room = h.ffw.julian
# Switching devices ##################################
# main_light videv<-->shelly
device_follow_sw(ts, room.videv_main_light, room.main_light)
device_follow_sw(ts, room.main_light, room.videv_main_light)
# Brightness and Colortemperature ####################
device_follow_br(ts, room.videv_main_light, room.main_light_zigbee, room.main_light)
device_follow_br(ts, room.main_light_zigbee, room.videv_main_light, room.main_light)
device_follow_ct(ts, room.videv_main_light, room.main_light_zigbee, room.main_light)
device_follow_ct(ts, room.main_light_zigbee, room.videv_main_light, room.main_light)
# Temperature ########################################
device_follow_temp(ts, room.videv_heating, room.heating_valve)
#
# ffw.bath
#
room = h.ffw.bath
# Switching devices ##################################
# main_light videv<-->shelly
device_follow_sw(ts, room.videv_main_light, room.main_light, single=True)
device_follow_sw(ts, room.main_light, room.videv_main_light, single=True)
# Temperature ########################################
device_follow_temp(ts, room.videv_heating, room.heating_valve)
#
# ffw.floor
#
room = h.ffw.floor
# Switching devices ##################################
# main_light videv<-->shelly
device_follow_sw(ts, room.videv_main_light, room.main_light)
device_follow_sw(ts, room.main_light, room.videv_main_light)
def gfe(ts: testSession, mc: mqtt_client, h: house):
#
# gfe.
#
# room = h.gfe
# Switching devices ##################################
pass
def gfw(ts: testSession, mc: mqtt_client, h: house):
#
# gfw.dirk
#
room = h.gfw.dirk
# Switching devices ##################################
# main_light videv<-->shelly
device_follow_sw(ts, room.videv_main_light, room.main_light)
device_follow_sw(ts, room.main_light, room.videv_main_light)
# desk_light videv<-->tradfri
device_follow_sw(ts, room.videv_desk_light, room.desk_light)
device_follow_sw(ts, room.desk_light, room.videv_desk_light)
# desk_light videv<-->powerplug
device_follow_sw(ts, room.videv_pc_dock, room.pc_dock)
device_follow_sw(ts, room.pc_dock, room.videv_pc_dock)
# powerplug videv <-> channel
device_follow_sw(ts, room.videv_amplifier, room.my_powerplug, slave_ch=0)
device_follow_sw(ts, room.my_powerplug, room.videv_amplifier, master_ch=0)
device_follow_sw(ts, room.videv_phono, room.my_powerplug, slave_ch=1)
device_follow_sw(ts, room.my_powerplug, room.videv_phono, master_ch=1)
device_follow_sw(ts, room.videv_cd_player, room.my_powerplug, slave_ch=2)
device_follow_sw(ts, room.my_powerplug, room.videv_cd_player, master_ch=2)
device_follow_sw(ts, room.videv_bt, room.my_powerplug, slave_ch=3)
device_follow_sw(ts, room.my_powerplug, room.videv_bt, master_ch=3)
# powerplug follow
device_follow_sw(ts, room.my_powerplug, room.my_powerplug, master_ch=1, slave_ch=0)
device_follow_sw(ts, room.my_powerplug, room.my_powerplug, master_ch=2, slave_ch=0)
device_follow_sw(ts, room.my_powerplug, room.my_powerplug, master_ch=3, slave_ch=0)
# Brightness and Colortemperature ####################
device_follow_br(ts, room.videv_main_light, room.main_light_zigbee, room.main_light)
device_follow_br(ts, room.main_light_zigbee, room.videv_main_light, room.main_light)
device_follow_ct(ts, room.videv_main_light, room.main_light_zigbee, room.main_light)
device_follow_ct(ts, room.main_light_zigbee, room.videv_main_light, room.main_light)
device_follow_br(ts, room.videv_desk_light, room.desk_light, room.desk_light)
device_follow_br(ts, room.desk_light, room.videv_desk_light, room.desk_light)
device_follow_ct(ts, room.videv_desk_light, room.desk_light, room.desk_light)
device_follow_ct(ts, room.desk_light, room.videv_desk_light, room.desk_light)
# Temperature ########################################
device_follow_temp(ts, room.videv_heating, room.heating_valve)
#
# gfw.marion
#
room = h.gfw.marion
# Switching devices ##################################
# main_light videv<-->shelly
device_follow_sw(ts, room.videv_main_light, room.main_light)
device_follow_sw(ts, room.main_light, room.videv_main_light)
# floor_lamp videv<->zigbee + main_light->zigbee
device_follow_sw(ts, room.videv_window_light, room.window_light)
device_follow_sw(ts, room.window_light, room.videv_window_light)
device_follow_sw(ts, room.main_light, room.window_light)
# Temperature ########################################
device_follow_temp(ts, room.videv_heating, room.heating_valve)
#
# gfw.floor
#
room = h.gfw.floor
# Switching devices ##################################
# main_light videv<-->shelly
device_follow_sw(ts, room.videv_main_light, room.main_light)
device_follow_sw(ts, room.main_light, room.videv_main_light)
# Brightness and Colortemperature ####################
device_follow_br(ts, room.videv_main_light, room.main_light_zigbee, room.main_light)
device_follow_br(ts, room.main_light_zigbee, room.videv_main_light, room.main_light)
device_follow_ct(ts, room.videv_main_light, room.main_light_zigbee, room.main_light)
device_follow_ct(ts, room.main_light_zigbee, room.videv_main_light, room.main_light)
def stw(ts: testSession, mc: mqtt_client, h: house):
#
# stairways
#
room = h.stairway
# Switching devices ##################################
# main_light videv<-->shelly
device_follow_sw(ts, room.videv_main_light, room.main_light)
device_follow_sw(ts, room.main_light, room.videv_main_light)