Files
ESPEasy/test/test002
T

30 lines
1.2 KiB
Python
Executable File

#!/usr/bin/env python2
from esptest import *
#node0 has 2x ds18b20
#values are send to domoticz via http
#values are send to domoticz via mqtt
### config mqtt and the 2 devices
espeasy[0].controller_domoticz_http(index=1, controllerip=config.http_server, controllerport=config.http_port)
espeasy[0].device_p004(index=1, taskdevicepin1=2, plugin_004_dev=0, plugin_004_res=9, TDID1=1417)
espeasy[0].device_p004(index=2, taskdevicepin1=2, plugin_004_dev=1, plugin_004_res=9, TDID1=1418)
#wait for request
temp1=http_expect_request("/json.html", { 'idx': 1417 }, timeout=10)
temp2=http_expect_request("/json.html", { 'idx': 1418 }, timeout=10)
if not ( float(temp1.params['svalue'])>0 and float(temp1.params['svalue'])<40 and float(temp2.params['svalue'])>0 and float(temp2.params['svalue'])<40):
raise(Exception("Wrong results"))
### reconfig for mqtt and expect results
espeasy[0].controller_domoticz_mqtt(index=1, controllerip=config.mqtt_broker)
temp1=mqtt_expect_json("domoticz/in", { 'idx': 1417 }, timeout=10)
temp2=mqtt_expect_json("domoticz/in", { 'idx': 1418 }, timeout=10)
if not ( float(temp1['svalue'])>0 and float(temp1['svalue'])<40 and float(temp2['svalue'])>0 and float(temp2['svalue'])<40):
raise(Exception("Wrong results"))