mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-27 19:57:38 +00:00
test suite: lots of refactoring and fixing
This commit is contained in:
+10
-2
@@ -53,6 +53,7 @@ class ControllerEmu:
|
||||
|
||||
def clear_mqtt(self):
|
||||
"""clear queue"""
|
||||
time.sleep(1)
|
||||
while not self.mqtt_messages.empty():
|
||||
self.mqtt_messages.get()
|
||||
|
||||
@@ -126,13 +127,20 @@ class ControllerEmu:
|
||||
self.linebased_lines.get()
|
||||
|
||||
|
||||
def clear(self, sleep=0):
|
||||
self.clear_http()
|
||||
self.clear_mqtt()
|
||||
self.clear_linebased()
|
||||
time.sleep(sleep)
|
||||
|
||||
|
||||
def recv_domoticz_http(self, sensor_type, idx, timeout=60):
|
||||
"""recv a domoticz http request from espeasy, and convert back to espeasy values"""
|
||||
|
||||
start_time=time.time()
|
||||
self.log.info("Waiting for domoticz http request idx {idx} with sensortype {sensor_type}".format(sensor_type=sensor_type,idx=idx))
|
||||
|
||||
self.clear_http()
|
||||
# self.clear_http()
|
||||
|
||||
# read and parse http requests
|
||||
while time.time()-start_time<timeout:
|
||||
@@ -188,7 +196,7 @@ class ControllerEmu:
|
||||
start_time=time.time()
|
||||
self.log.info("Waiting for domoticz mqtt request idx {idx} with sensortype {sensor_type}".format(sensor_type=sensor_type,idx=idx))
|
||||
|
||||
self.clear_mqtt()
|
||||
# self.clear_mqtt()
|
||||
|
||||
# read and parse mqtt requests
|
||||
while time.time()-start_time<timeout:
|
||||
|
||||
+140
-164
@@ -25,19 +25,24 @@ class EspEasy:
|
||||
)
|
||||
|
||||
|
||||
def controller_domoticz_mqtt(self, controllerip=config.mqtt_broker, controllerport=config.mqtt_port, **kwargs):
|
||||
"""config controller to use domoticz via mqtt"""
|
||||
|
||||
self._node.log.info("Configuring controller domoticz mqtt "+str(kwargs))
|
||||
def post_controller(self, index, data):
|
||||
"""post controller form to espeasy"""
|
||||
self._node.http_post(
|
||||
twice=True, # needed for controllers and devices because of the way its implemented
|
||||
page="controllers",
|
||||
|
||||
params="""
|
||||
index:{index}
|
||||
""".format(**kwargs),
|
||||
""".format(index=index),
|
||||
|
||||
data="""
|
||||
data=data
|
||||
)
|
||||
|
||||
def controller_domoticz_mqtt(self, index=1, controllerip=config.mqtt_broker, controllerport=config.mqtt_port, **kwargs):
|
||||
"""config controller to use domoticz via mqtt"""
|
||||
|
||||
self._node.log.info("Configuring controller domoticz mqtt "+str(kwargs))
|
||||
self.post_controller(index,"""
|
||||
protocol:2
|
||||
usedns:0
|
||||
controllerip:{controllerip}
|
||||
@@ -51,19 +56,11 @@ class EspEasy:
|
||||
)
|
||||
|
||||
|
||||
def controller_domoticz_http(self, controllerip=config.test_server, controllerport=config.http_port, **kwargs):
|
||||
def controller_domoticz_http(self, index=1, controllerip=config.test_server, controllerport=config.http_port, **kwargs):
|
||||
"""config controller to use domoticz via http"""
|
||||
|
||||
self._node.log.info("Configuring controller domoticz http "+str(kwargs))
|
||||
self._node.http_post(
|
||||
twice=True, # needed for controllers and devices because of the way its implemented
|
||||
page="controllers",
|
||||
|
||||
params="""
|
||||
index:{index}
|
||||
""".format(**kwargs),
|
||||
|
||||
data="""
|
||||
self.post_controller(index,"""
|
||||
protocol:1
|
||||
usedns:0
|
||||
controllerip:{controllerip}
|
||||
@@ -75,19 +72,11 @@ class EspEasy:
|
||||
)
|
||||
|
||||
|
||||
def controller_nodo(self, controllerip=config.test_server, controllerport=config.linebased_port, **kwargs):
|
||||
def controller_nodo(self, index=1,controllerip=config.test_server, controllerport=config.linebased_port, **kwargs):
|
||||
"""config controller to use nodo"""
|
||||
|
||||
self._node.log.info("Configuring controller nodo "+str(kwargs))
|
||||
self._node.http_post(
|
||||
twice=True, # needed for controllers and devices because of the way its implemented
|
||||
page="controllers",
|
||||
|
||||
params="""
|
||||
index:{index}
|
||||
""".format(**kwargs),
|
||||
|
||||
data="""
|
||||
self.post_controller(index,"""
|
||||
protocol:3
|
||||
usedns:0
|
||||
controllerip:{controllerip}
|
||||
@@ -98,22 +87,10 @@ class EspEasy:
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def controller_thingspeak(self, **kwargs):
|
||||
def controller_thingspeak(self, index=1, **kwargs):
|
||||
|
||||
self._node.log.info("Configuring controller thingspeak "+str(kwargs))
|
||||
self._node.http_post(
|
||||
twice=True, # needed for controllers and devices because of the way its implemented
|
||||
page="controllers",
|
||||
|
||||
params="""
|
||||
index:{index}
|
||||
""".format(**kwargs),
|
||||
|
||||
data="""
|
||||
self.post_controller(index,"""
|
||||
protocol:4
|
||||
usedns:0
|
||||
controllerip:{controllerip}
|
||||
@@ -125,105 +102,104 @@ class EspEasy:
|
||||
)
|
||||
|
||||
|
||||
def device_p001(self, **kwargs):
|
||||
self._node.log.info("Config device plugin p001 "+str(kwargs))
|
||||
|
||||
def post_device(self, index, data):
|
||||
"""post a device form to espeasy"""
|
||||
self._node.log.info("Configuring tasknumber {index}".format(index=index))
|
||||
self._node.http_post(
|
||||
twice=True, # needed for controllers and devices because of the way its implemented
|
||||
page="devices",
|
||||
|
||||
params="""
|
||||
index:{index}
|
||||
""".format(**kwargs),
|
||||
|
||||
data="""
|
||||
TDNUM:1
|
||||
TDN:
|
||||
TDE:on
|
||||
taskdevicepin1:{taskdevicepin1}
|
||||
plugin_001_type:{plugin_001_type}
|
||||
plugin_001_button:{plugin_001_button}
|
||||
TDSD1:on
|
||||
TDID1:{TDID1}
|
||||
TDT:0
|
||||
TDVN1:Switch
|
||||
edit:1
|
||||
""".format(**kwargs)
|
||||
""".format(index=index),
|
||||
data=data
|
||||
)
|
||||
|
||||
|
||||
def device_p004(self, **kwargs):
|
||||
self._node.log.info("Config ds18b20 with "+str(kwargs))
|
||||
|
||||
self._node.http_post(
|
||||
twice=True, # needed for controllers and devices because of the way its implemented
|
||||
page="devices",
|
||||
|
||||
params="""
|
||||
index:{index}
|
||||
""".format(**kwargs),
|
||||
|
||||
data="""
|
||||
TDNUM:4
|
||||
TDN:temp
|
||||
TDE:on
|
||||
taskdevicepin1:{taskdevicepin1}
|
||||
plugin_004_dev:{plugin_004_dev}
|
||||
plugin_004_res:{plugin_004_res}
|
||||
TDT:5
|
||||
TDVN1:Temperature
|
||||
TDF1:
|
||||
TDVD1:2
|
||||
TDSD1:on
|
||||
TDID1:{TDID1}
|
||||
edit:1
|
||||
page:1
|
||||
""".format(**kwargs)
|
||||
)
|
||||
|
||||
def device_p005(self, **kwargs):
|
||||
self._node.log.info("Config DHT22 on D3 with "+str(kwargs))
|
||||
|
||||
self._node.http_post(
|
||||
twice=True, # needed for controllers and devices because of the way its implemented
|
||||
page="devices",
|
||||
|
||||
params="""
|
||||
index:{index}
|
||||
""".format(**kwargs),
|
||||
|
||||
data="""
|
||||
TDNUM:5
|
||||
TDN:
|
||||
TDE:on
|
||||
taskdevicepin1:0
|
||||
plugin_005_dhttype:22
|
||||
TDSD1:on
|
||||
TDID1:{TDID1}
|
||||
TDT:5
|
||||
TDVN1:Temperature
|
||||
TDF1:
|
||||
TDVD1:2
|
||||
TDVN2:Humidity
|
||||
TDF2:
|
||||
TDVD2:2
|
||||
edit:1
|
||||
page:1
|
||||
""".format(**kwargs)
|
||||
)
|
||||
# def device_p001(self, index, **kwargs):
|
||||
# self._node.log.info("Config device plugin p001 "+str(kwargs))
|
||||
#
|
||||
# self.post_device(index, """
|
||||
# TDNUM:1
|
||||
# TDN:
|
||||
# TDE:on
|
||||
# taskdevicepin1:{taskdevicepin1}
|
||||
# plugin_001_type:{plugin_001_type}
|
||||
# plugin_001_button:{plugin_001_button}
|
||||
# TDSD1:on
|
||||
# TDID1:{TDID1}
|
||||
# TDT:0
|
||||
# TDVN1:Switch
|
||||
# edit:1
|
||||
# """.format(**kwargs)
|
||||
# )
|
||||
|
||||
|
||||
def device_p033(self, **kwargs):
|
||||
# def device_p004(self, **kwargs):
|
||||
# self._node.log.info("Config ds18b20 with "+str(kwargs))
|
||||
#
|
||||
# self._node.http_post(
|
||||
# twice=True, # needed for controllers and devices because of the way its implemented
|
||||
# page="devices",
|
||||
#
|
||||
# params="""
|
||||
# index:{index}
|
||||
# """.format(**kwargs),
|
||||
#
|
||||
# data="""
|
||||
# TDNUM:4
|
||||
# TDN:temp
|
||||
# TDE:on
|
||||
# taskdevicepin1:{taskdevicepin1}
|
||||
# plugin_004_dev:{plugin_004_dev}
|
||||
# plugin_004_res:{plugin_004_res}
|
||||
# TDT:5
|
||||
# TDVN1:Temperature
|
||||
# TDF1:
|
||||
# TDVD1:2
|
||||
# TDSD1:on
|
||||
# TDID1:{TDID1}
|
||||
# edit:1
|
||||
# page:1
|
||||
# """.format(**kwargs)
|
||||
# )
|
||||
|
||||
# def device_p005(self, **kwargs):
|
||||
# self._node.log.info("Config DHT22 on D3 with "+str(kwargs))
|
||||
#
|
||||
# self._node.http_post(
|
||||
# twice=True, # needed for controllers and devices because of the way its implemented
|
||||
# page="devices",
|
||||
#
|
||||
# params="""
|
||||
# index:{index}
|
||||
# """.format(**kwargs),
|
||||
#
|
||||
# data="""
|
||||
# TDNUM:5
|
||||
# TDN:
|
||||
# TDE:on
|
||||
# taskdevicepin1:0
|
||||
# plugin_005_dhttype:22
|
||||
# TDSD1:on
|
||||
# TDID1:{TDID1}
|
||||
# TDT:5
|
||||
# TDVN1:Temperature
|
||||
# TDF1:
|
||||
# TDVD1:2
|
||||
# TDVN2:Humidity
|
||||
# TDF2:
|
||||
# TDVD2:2
|
||||
# edit:1
|
||||
# page:1
|
||||
# """.format(**kwargs)
|
||||
# )
|
||||
|
||||
|
||||
def device_p033(self, index, **kwargs):
|
||||
self._node.log.info("Config dummy device "+str(kwargs))
|
||||
|
||||
self._node.http_post(
|
||||
twice=True, # needed for controllers and devices because of the way its implemented
|
||||
page="devices",
|
||||
|
||||
params="""
|
||||
index:{index}
|
||||
""".format(**kwargs),
|
||||
|
||||
self.post_device(index=index,
|
||||
data="""
|
||||
TDNUM:33
|
||||
TDN:
|
||||
@@ -246,41 +222,41 @@ class EspEasy:
|
||||
)
|
||||
|
||||
|
||||
def device_p036(self, **kwargs):
|
||||
self._node.log.info("Config framed oled p036 with "+str(kwargs))
|
||||
|
||||
self._node.http_post(
|
||||
twice=True, # needed for controllers and devices because of the way its implemented
|
||||
page="devices",
|
||||
|
||||
params="""
|
||||
index:{index}
|
||||
""".format(**kwargs),
|
||||
|
||||
data="""
|
||||
TDNUM:36
|
||||
TDN:
|
||||
TDE:on
|
||||
plugin_036_adr:60
|
||||
plugin_036_rotate:1
|
||||
plugin_036_nlines:1
|
||||
plugin_036_scroll:1
|
||||
Plugin_036_template1:espeasy
|
||||
Plugin_036_template2:test
|
||||
Plugin_036_template3:suite
|
||||
Plugin_036_template4:test1
|
||||
Plugin_036_template5:test2
|
||||
Plugin_036_template6:test3
|
||||
Plugin_036_template7:test4
|
||||
Plugin_036_template8:test5
|
||||
Plugin_036_template9:test6
|
||||
Plugin_036_template10:test7
|
||||
Plugin_036_template11:test8
|
||||
Plugin_036_template12:test9
|
||||
taskdevicepin3:-1
|
||||
plugin_036_timer:0
|
||||
TDT:1
|
||||
edit:1
|
||||
page:1
|
||||
""".format(**kwargs)
|
||||
)
|
||||
# def device_p036(self, **kwargs):
|
||||
# self._node.log.info("Config framed oled p036 with "+str(kwargs))
|
||||
#
|
||||
# self._node.http_post(
|
||||
# twice=True, # needed for controllers and devices because of the way its implemented
|
||||
# page="devices",
|
||||
#
|
||||
# params="""
|
||||
# index:{index}
|
||||
# """.format(**kwargs),
|
||||
#
|
||||
# data="""
|
||||
# TDNUM:36
|
||||
# TDN:
|
||||
# TDE:on
|
||||
# plugin_036_adr:60
|
||||
# plugin_036_rotate:1
|
||||
# plugin_036_nlines:1
|
||||
# plugin_036_scroll:1
|
||||
# Plugin_036_template1:espeasy
|
||||
# Plugin_036_template2:test
|
||||
# Plugin_036_template3:suite
|
||||
# Plugin_036_template4:test1
|
||||
# Plugin_036_template5:test2
|
||||
# Plugin_036_template6:test3
|
||||
# Plugin_036_template7:test4
|
||||
# Plugin_036_template8:test5
|
||||
# Plugin_036_template9:test6
|
||||
# Plugin_036_template10:test7
|
||||
# Plugin_036_template11:test8
|
||||
# Plugin_036_template12:test9
|
||||
# taskdevicepin3:-1
|
||||
# plugin_036_timer:0
|
||||
# TDT:1
|
||||
# edit:1
|
||||
# page:1
|
||||
# """.format(**kwargs)
|
||||
# )
|
||||
|
||||
@@ -112,3 +112,9 @@ def test_is(value, shouldbe):
|
||||
raise(Exception("Value {value} should be {shouldbe}".format(value=value, shouldbe=shouldbe)))
|
||||
|
||||
log.info("OK: Value is {value}".format(value=value, shouldbe=shouldbe))
|
||||
|
||||
|
||||
def pause(seconds):
|
||||
log.info("Waiting for {seconds} seconds".format(seconds=seconds))
|
||||
time.sleep(seconds)
|
||||
|
||||
|
||||
+3
-1
@@ -205,9 +205,11 @@ class Node():
|
||||
data_dict=None
|
||||
|
||||
|
||||
url=self._url+page
|
||||
self.log.debug("HTTP POST {url} with params {params} and data {data}".format(url=url,params=params,data=data))
|
||||
|
||||
r=requests.post(
|
||||
self._url+page,
|
||||
url,
|
||||
params=params_dict,
|
||||
data=data_dict
|
||||
)
|
||||
|
||||
+27
-18
@@ -10,24 +10,33 @@ from esptest import *
|
||||
# tests:
|
||||
# - pulsing the node0 pin and picking it up on node1 which sends it via domoticz mqtt
|
||||
|
||||
espeasy[1].controller_domoticz_mqtt(index=1, controllerip=config.mqtt_broker)
|
||||
espeasy[1].device_p001(index=1, taskdevicepin1=12, plugin_001_type=1, plugin_001_button=0, TDID1=1415)
|
||||
@step()
|
||||
def prepare():
|
||||
node[0].reboot()
|
||||
node[0].pingserial()
|
||||
node[0].serialcmd("resetFlashWriteCounter")
|
||||
espeasy[1].controller_domoticz_mqtt()
|
||||
espeasy[1].post_device(1, """
|
||||
TDNUM:1
|
||||
TDN:
|
||||
TDE:on
|
||||
taskdevicepin1:12
|
||||
plugin_001_type:1
|
||||
plugin_001_button:0
|
||||
TDSD1:on
|
||||
TDID1:1000
|
||||
TDT:0
|
||||
TDVN1:Switch
|
||||
edit:1
|
||||
""")
|
||||
|
||||
|
||||
|
||||
### test
|
||||
espeasy[0].control(cmd="gpio,12,1")
|
||||
time.sleep(1)
|
||||
espeasy[0].control(cmd="gpio,12,0")
|
||||
time.sleep(1)
|
||||
|
||||
# check mqtt results
|
||||
for message in mqtt_messages:
|
||||
payload=json.loads(message.payload.decode())
|
||||
if message.topic == 'domoticz/in' and payload['idx']==1415 and payload['switchcmd']=='Off' and payload['command']=='switchlight':
|
||||
log.info("all tests ok")
|
||||
sys.exit(0)
|
||||
#FIXME: this need to be callable, to run a batch of tests at once
|
||||
|
||||
|
||||
raise(Exception("Test failed"))
|
||||
@step()
|
||||
def test():
|
||||
espeasy[0].control(cmd="gpio,12,1")
|
||||
pause(5)
|
||||
controller.clear_mqtt()
|
||||
espeasy[0].control(cmd="gpio,12,0")
|
||||
values=controller.recv_domoticz_mqtt(SENSOR_TYPE_SWITCH,1000)
|
||||
test_is(values[0],0)
|
||||
|
||||
+39
-21
@@ -7,41 +7,62 @@ from esptest import *
|
||||
# - 2x ds18b12 connected to D4
|
||||
|
||||
# tests:
|
||||
# - correct values are send to domoticz via http
|
||||
# - correct values are send to domoticz via mqtt
|
||||
# - test if powercycle value is valid (https://github.com/letscontrolit/ESPEasy/issues/719)
|
||||
|
||||
# espeasy[0].controller_thingspeak(index=1, controllerip=config.test_server, controllerport=config.http_port)
|
||||
|
||||
|
||||
@step
|
||||
def prepare_devices():
|
||||
@step()
|
||||
def prepare():
|
||||
node[0].reboot()
|
||||
node[0].pingserial()
|
||||
espeasy[0].device_p004(index=1, taskdevicepin1=2, plugin_004_dev=0, plugin_004_res=9, TDID1=2001)
|
||||
espeasy[0].device_p004(index=2, taskdevicepin1=2, plugin_004_dev=1, plugin_004_res=9, TDID1=2002)
|
||||
# espeasy[0].device_p004(index=1, taskdevicepin1=2, plugin_004_dev=0, plugin_004_res=9, TDID1=2001)
|
||||
# espeasy[0].device_p004(index=2, taskdevicepin1=2, plugin_004_dev=1, plugin_004_res=9, TDID1=2002)
|
||||
espeasy[0].post_device(index=1, data="""
|
||||
TDNUM:4
|
||||
TDN:temp
|
||||
TDE:on
|
||||
taskdevicepin1:2
|
||||
plugin_004_dev:0
|
||||
plugin_004_res:9
|
||||
TDT:5
|
||||
TDVN1:Temperature
|
||||
TDF1:
|
||||
TDVD1:2
|
||||
TDSD1:on
|
||||
TDID1:2001
|
||||
edit:1
|
||||
page:1
|
||||
""")
|
||||
|
||||
|
||||
@step
|
||||
def test_domoticz_http():
|
||||
espeasy[0].controller_domoticz_http(index=1, controllerip=config.test_server, controllerport=config.http_port)
|
||||
results=controller.recv_domoticz_http(SENSOR_TYPE_SINGLE,2001)
|
||||
test_in_range(results[0], -5,40)
|
||||
results=controller.recv_domoticz_http(SENSOR_TYPE_SINGLE,2002)
|
||||
test_in_range(results[0], -5,40)
|
||||
espeasy[0].post_device(index=2, data="""
|
||||
TDNUM:4
|
||||
TDN:temp
|
||||
TDE:on
|
||||
taskdevicepin1:2
|
||||
plugin_004_dev:1
|
||||
plugin_004_res:9
|
||||
TDT:5
|
||||
TDVN1:Temperature
|
||||
TDF1:
|
||||
TDVD1:2
|
||||
TDSD1:on
|
||||
TDID1:2002
|
||||
edit:1
|
||||
page:1
|
||||
""")
|
||||
|
||||
|
||||
|
||||
@step
|
||||
def test_domoticz_mqtt():
|
||||
espeasy[0].controller_domoticz_mqtt(index=1, controllerip=config.mqtt_broker)
|
||||
@step()
|
||||
def test():
|
||||
results=controller.recv_domoticz_mqtt(SENSOR_TYPE_SINGLE,2001)
|
||||
test_in_range(results[0], -5,40)
|
||||
results=controller.recv_domoticz_mqtt(SENSOR_TYPE_SINGLE,2002)
|
||||
test_in_range(results[0], -5,40)
|
||||
|
||||
|
||||
@step
|
||||
@step()
|
||||
def powercycle():
|
||||
"""test result on poweron"""
|
||||
node[0].powercycle()
|
||||
@@ -49,6 +70,3 @@ def powercycle():
|
||||
test_in_range(results[0], -5,40)
|
||||
results=controller.recv_domoticz_mqtt(SENSOR_TYPE_SINGLE,2002)
|
||||
test_in_range(results[0], -5,40)
|
||||
|
||||
|
||||
run()
|
||||
|
||||
+26
-1
@@ -9,4 +9,29 @@ from esptest import *
|
||||
# tests:
|
||||
# - only configures it, nothing is verfied yet
|
||||
|
||||
espeasy[0].device_p036(index=1)
|
||||
espeasy[0].post_device(1, data="""
|
||||
TDNUM:36
|
||||
TDN:
|
||||
TDE:on
|
||||
plugin_036_adr:60
|
||||
plugin_036_rotate:1
|
||||
plugin_036_nlines:1
|
||||
plugin_036_scroll:1
|
||||
Plugin_036_template1:espeasy
|
||||
Plugin_036_template2:test
|
||||
Plugin_036_template3:suite
|
||||
Plugin_036_template4:test1
|
||||
Plugin_036_template5:test2
|
||||
Plugin_036_template6:test3
|
||||
Plugin_036_template7:test4
|
||||
Plugin_036_template8:test5
|
||||
Plugin_036_template9:test6
|
||||
Plugin_036_template10:test7
|
||||
Plugin_036_template11:test8
|
||||
Plugin_036_template12:test9
|
||||
taskdevicepin3:-1
|
||||
plugin_036_timer:0
|
||||
TDT:1
|
||||
edit:1
|
||||
page:1
|
||||
""")
|
||||
|
||||
+22
-4
@@ -10,16 +10,34 @@ from esptest import *
|
||||
# - correct values are send to domoticz via mqtt
|
||||
|
||||
|
||||
@step
|
||||
@step()
|
||||
def prepare():
|
||||
node[0].reboot()
|
||||
node[0].pingserial()
|
||||
node[0].serialcmd("resetFlashWriteCounter")
|
||||
espeasy[0].controller_domoticz_mqtt(index=1, controllerip=config.mqtt_broker)
|
||||
espeasy[0].device_p005(index=1, TDID1=4001)
|
||||
espeasy[0].controller_domoticz_mqtt()
|
||||
espeasy[0].post_device(index=1,data="""
|
||||
TDNUM:5
|
||||
TDN:
|
||||
TDE:on
|
||||
taskdevicepin1:0
|
||||
plugin_005_dhttype:22
|
||||
TDSD1:on
|
||||
TDID1:4001
|
||||
TDT:5
|
||||
TDVN1:Temperature
|
||||
TDF1:
|
||||
TDVD1:2
|
||||
TDVN2:Humidity
|
||||
TDF2:
|
||||
TDVD2:2
|
||||
edit:1
|
||||
page:1
|
||||
|
||||
""")
|
||||
|
||||
|
||||
@step
|
||||
@step()
|
||||
def test():
|
||||
results=controller.recv_domoticz_mqtt(SENSOR_TYPE_TEMP_HUM,4001)
|
||||
test_in_range(results[0], -5,40)
|
||||
|
||||
+26
-26
@@ -13,7 +13,7 @@ def prepare():
|
||||
node[0].reboot()
|
||||
node[0].pingserial()
|
||||
node[0].serialcmd("resetFlashWriteCounter")
|
||||
|
||||
controller.clear()
|
||||
|
||||
#traverse most controllers
|
||||
for ( title, controller_config, controller_recv ) in [
|
||||
@@ -24,115 +24,115 @@ for ( title, controller_config, controller_recv ) in [
|
||||
|
||||
@step(title)
|
||||
def config_controller():
|
||||
controller_config(index=1)
|
||||
controller_config()
|
||||
|
||||
|
||||
|
||||
@step(title)
|
||||
def single():
|
||||
espeasy[0].device_p033(index=1, TDID1=5000, plugin_033_sensortype=SENSOR_TYPE_SINGLE)
|
||||
node[0].serialcmd("TaskValueSet 1,1,5001")
|
||||
results=controller_recv(SENSOR_TYPE_SINGLE,5000)
|
||||
espeasy[0].device_p033(index=1, TDID1=5100, plugin_033_sensortype=SENSOR_TYPE_SINGLE)
|
||||
results=controller_recv(SENSOR_TYPE_SINGLE,5100)
|
||||
test_is(results, [ 5001 ])
|
||||
|
||||
|
||||
@step(title)
|
||||
def long():
|
||||
espeasy[0].device_p033(index=1, TDID1=5000, plugin_033_sensortype=SENSOR_TYPE_LONG)
|
||||
a=50025003
|
||||
#long is actually quite hackish in espeasy: since uservar only supports floats, we use 2 uservars and some bitshifting. the controller will see just one value
|
||||
node[0].serialcmd("TaskValueSet 1,1,{0}".format(a & 0xffff))
|
||||
node[0].serialcmd("TaskValueSet 1,2,{0}".format(a>>16))
|
||||
results=controller_recv(SENSOR_TYPE_LONG,5000)
|
||||
espeasy[0].device_p033(index=1, TDID1=5101, plugin_033_sensortype=SENSOR_TYPE_LONG)
|
||||
results=controller_recv(SENSOR_TYPE_LONG,5101)
|
||||
test_is(results, [ a ])
|
||||
|
||||
|
||||
@step(title)
|
||||
def dual():
|
||||
espeasy[0].device_p033(index=1, TDID1=5000, plugin_033_sensortype=SENSOR_TYPE_DUAL)
|
||||
node[0].serialcmd("TaskValueSet 1,1,5004")
|
||||
node[0].serialcmd("TaskValueSet 1,2,5005")
|
||||
results=controller_recv(SENSOR_TYPE_DUAL,5000)
|
||||
espeasy[0].device_p033(index=1, TDID1=5102, plugin_033_sensortype=SENSOR_TYPE_DUAL)
|
||||
results=controller_recv(SENSOR_TYPE_DUAL,5102)
|
||||
test_is(results, [ 5004, 5005 ])
|
||||
|
||||
|
||||
@step(title)
|
||||
def temp_hum():
|
||||
espeasy[0].device_p033(index=1, TDID1=5000, plugin_033_sensortype=SENSOR_TYPE_TEMP_HUM)
|
||||
node[0].serialcmd("TaskValueSet 1,1,5006")
|
||||
node[0].serialcmd("TaskValueSet 1,2,5007")
|
||||
results=controller_recv(SENSOR_TYPE_TEMP_HUM,5000)
|
||||
espeasy[0].device_p033(index=1, TDID1=5103, plugin_033_sensortype=SENSOR_TYPE_TEMP_HUM)
|
||||
results=controller_recv(SENSOR_TYPE_TEMP_HUM,5103)
|
||||
test_is(results, [ 5006, 5007 ])
|
||||
|
||||
|
||||
@step(title)
|
||||
def temp_baro():
|
||||
espeasy[0].device_p033(index=1, TDID1=5000, plugin_033_sensortype=SENSOR_TYPE_TEMP_BARO)
|
||||
node[0].serialcmd("TaskValueSet 1,1,5008")
|
||||
node[0].serialcmd("TaskValueSet 1,2,5009")
|
||||
results=controller_recv(SENSOR_TYPE_TEMP_BARO,5000)
|
||||
espeasy[0].device_p033(index=1, TDID1=5104, plugin_033_sensortype=SENSOR_TYPE_TEMP_BARO)
|
||||
results=controller_recv(SENSOR_TYPE_TEMP_BARO,5104)
|
||||
test_is(results, [ 5008, 5009 ])
|
||||
|
||||
|
||||
@step(title)
|
||||
def triple():
|
||||
espeasy[0].device_p033(index=1, TDID1=5000, plugin_033_sensortype=SENSOR_TYPE_TRIPLE)
|
||||
node[0].serialcmd("TaskValueSet 1,1,5010")
|
||||
node[0].serialcmd("TaskValueSet 1,2,5011")
|
||||
node[0].serialcmd("TaskValueSet 1,3,5012")
|
||||
results=controller_recv(SENSOR_TYPE_TRIPLE,5000)
|
||||
espeasy[0].device_p033(index=1, TDID1=5105, plugin_033_sensortype=SENSOR_TYPE_TRIPLE)
|
||||
results=controller_recv(SENSOR_TYPE_TRIPLE,5105)
|
||||
test_is(results, [ 5010, 5011, 5012 ])
|
||||
|
||||
|
||||
@step(title)
|
||||
def temp_hum_baro():
|
||||
espeasy[0].device_p033(index=1, TDID1=5000, plugin_033_sensortype=SENSOR_TYPE_TEMP_HUM_BARO)
|
||||
node[0].serialcmd("TaskValueSet 1,1,5013")
|
||||
node[0].serialcmd("TaskValueSet 1,2,5014")
|
||||
node[0].serialcmd("TaskValueSet 1,3,5015")
|
||||
results=controller_recv(SENSOR_TYPE_TEMP_HUM_BARO,5000)
|
||||
espeasy[0].device_p033(index=1, TDID1=5106, plugin_033_sensortype=SENSOR_TYPE_TEMP_HUM_BARO)
|
||||
results=controller_recv(SENSOR_TYPE_TEMP_HUM_BARO,5106)
|
||||
test_is(results, [ 5013, 5014, 5015 ])
|
||||
|
||||
|
||||
@step(title)
|
||||
def quad():
|
||||
espeasy[0].device_p033(index=1, TDID1=5000, plugin_033_sensortype=SENSOR_TYPE_QUAD)
|
||||
node[0].serialcmd("TaskValueSet 1,1,5016")
|
||||
node[0].serialcmd("TaskValueSet 1,2,5017")
|
||||
node[0].serialcmd("TaskValueSet 1,3,5018")
|
||||
node[0].serialcmd("TaskValueSet 1,4,5019")
|
||||
results=controller_recv(SENSOR_TYPE_QUAD,5000)
|
||||
espeasy[0].device_p033(index=1, TDID1=5107, plugin_033_sensortype=SENSOR_TYPE_QUAD)
|
||||
results=controller_recv(SENSOR_TYPE_QUAD,5107)
|
||||
test_is(results, [ 5016, 5017, 5018, 5019 ])
|
||||
|
||||
|
||||
@step(title)
|
||||
def switch():
|
||||
espeasy[0].device_p033(index=1, TDID1=5020, plugin_033_sensortype=SENSOR_TYPE_SWITCH)
|
||||
node[0].serialcmd("TaskValueSet 1,1,0")
|
||||
results=controller_recv(SENSOR_TYPE_SWITCH,5020)
|
||||
espeasy[0].device_p033(index=1, TDID1=5108, plugin_033_sensortype=SENSOR_TYPE_SWITCH)
|
||||
results=controller_recv(SENSOR_TYPE_SWITCH,5108)
|
||||
test_is(results, [ 0 ])
|
||||
node[0].serialcmd("TaskValueSet 1,1,1")
|
||||
results=controller_recv(SENSOR_TYPE_SWITCH,5020)
|
||||
results=controller_recv(SENSOR_TYPE_SWITCH,5108)
|
||||
test_is(results, [ 1 ])
|
||||
|
||||
|
||||
@step(title)
|
||||
def dimmer():
|
||||
espeasy[0].device_p033(index=1, TDID1=5021, plugin_033_sensortype=SENSOR_TYPE_DIMMER)
|
||||
node[0].serialcmd("TaskValueSet 1,1,0")
|
||||
results=controller_recv(SENSOR_TYPE_DIMMER,5021)
|
||||
espeasy[0].device_p033(index=1, TDID1=5109, plugin_033_sensortype=SENSOR_TYPE_DIMMER)
|
||||
results=controller_recv(SENSOR_TYPE_DIMMER,5109)
|
||||
test_is(results, [ 0 ])
|
||||
node[0].serialcmd("TaskValueSet 1,1,25")
|
||||
results=controller_recv(SENSOR_TYPE_DIMMER,5021)
|
||||
results=controller_recv(SENSOR_TYPE_DIMMER,5109)
|
||||
test_is(results, [ 25 ])
|
||||
|
||||
|
||||
|
||||
@step(title)
|
||||
def wind():
|
||||
espeasy[0].device_p033(index=1, TDID1=5000, plugin_033_sensortype=SENSOR_TYPE_WIND)
|
||||
node[0].serialcmd("TaskValueSet 1,1,5022")
|
||||
node[0].serialcmd("TaskValueSet 1,2,5023")
|
||||
node[0].serialcmd("TaskValueSet 1,3,5024")
|
||||
results=controller_recv(SENSOR_TYPE_WIND,5000)
|
||||
espeasy[0].device_p033(index=1, TDID1=5110, plugin_033_sensortype=SENSOR_TYPE_WIND)
|
||||
results=controller_recv(SENSOR_TYPE_WIND,5110)
|
||||
test_is(results, [ 5022, 5023, 5024 ])
|
||||
|
||||
Reference in New Issue
Block a user