mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-27 19:57:38 +00:00
working on test stuff
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
nodes=[
|
||||
{
|
||||
'node' : 1,
|
||||
'type' : 'wemos d1 mini v2.2.0',
|
||||
'port' : '/dev/serial/by-path/pci-0000:00:14.0-usb-0:3.1:1.0-port0',
|
||||
'ip' : '192.168.13.91',
|
||||
@@ -8,6 +9,7 @@ nodes=[
|
||||
},
|
||||
|
||||
{
|
||||
'node' : 2,
|
||||
'type' : 'nodemcu geekcreit ESP12E devkit v2',
|
||||
'port' : '/dev/serial/by-path/pci-0000:00:14.0-usb-0:3.2:1.0-port0',
|
||||
'ip' : '192.168.13.92',
|
||||
|
||||
@@ -16,13 +16,13 @@ def get_epilog():
|
||||
Examples:
|
||||
|
||||
Build, flash and connect to serial for node 2:
|
||||
./esptest node 2 bfs
|
||||
./espcli node 2 bfs
|
||||
|
||||
Reboot a node and configure wifi:
|
||||
./esptest node 1 wificonfig
|
||||
Configure wifi settings for node:
|
||||
./espcli node 1 wificonfig
|
||||
|
||||
Configure node 1, controller 1 as domoticz mqtt:
|
||||
./esptest espeasy 1 controller_domoticz_mqtt index=1 mqtt_broker=1.2.3.4
|
||||
./espcli espeasy 1 controller_domoticz_mqtt index=1 controllerip=1.2.3.4
|
||||
|
||||
"""
|
||||
return(docs)
|
||||
@@ -57,7 +57,6 @@ try:
|
||||
|
||||
node_index=args.node[0]-1
|
||||
|
||||
config.nodes[node_index]['node']=args.node[0]
|
||||
|
||||
#we always need a node instance
|
||||
node_instance=node.Node(config.nodes[node_index])
|
||||
+39
-3
@@ -9,6 +9,17 @@ class EspEasy:
|
||||
self._node=node
|
||||
|
||||
|
||||
def control(self, **kwargs):
|
||||
self._node.http_post(
|
||||
page="control",
|
||||
|
||||
params="""
|
||||
cmd:{cmd}
|
||||
""".format(**kwargs),
|
||||
|
||||
)
|
||||
|
||||
|
||||
def controller_domoticz_mqtt(self, **kwargs):
|
||||
"""config controller to use domoticz via mqtt"""
|
||||
|
||||
@@ -16,18 +27,43 @@ class EspEasy:
|
||||
page="controllers",
|
||||
|
||||
params="""
|
||||
index: {index}
|
||||
index:{index}
|
||||
""".format(**kwargs),
|
||||
|
||||
data="""
|
||||
protocol:2
|
||||
usedns:0
|
||||
controllerip:{mqtt_broker}
|
||||
controllerip:{controllerip}
|
||||
controllerport:1883
|
||||
controlleruser:
|
||||
controllerpassword: http://urltje
|
||||
controllerpassword:
|
||||
controllersubscribe:domoticz/out
|
||||
controllerpublish:domoticz/in
|
||||
controllerenabled:on
|
||||
""".format(**kwargs)
|
||||
)
|
||||
|
||||
|
||||
def device_p001(self, **kwargs):
|
||||
|
||||
self._node.http_post(
|
||||
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:1
|
||||
TDT:0
|
||||
TDVN1:Switch
|
||||
edit:1
|
||||
""".format(**kwargs)
|
||||
)
|
||||
|
||||
+10
-7
@@ -130,8 +130,8 @@ class Node():
|
||||
|
||||
|
||||
|
||||
def http_post(self, page, params, data):
|
||||
"""http post to espeasy webinterface"""
|
||||
def http_post(self, page, params, data=None):
|
||||
"""http post to espeasy webinterface. (GET if data is None)"""
|
||||
|
||||
# transform easy copy/pastable chromium data into a dict
|
||||
|
||||
@@ -141,11 +141,14 @@ class Node():
|
||||
if (m):
|
||||
params_dict[m.group(1)]=m.group(2)
|
||||
|
||||
data_dict={}
|
||||
for line in data.split("\n"):
|
||||
m=re.match(" *(.*?):(.*)",line)
|
||||
if (m):
|
||||
data_dict[m.group(1)]=m.group(2)
|
||||
if data:
|
||||
data_dict={}
|
||||
for line in data.split("\n"):
|
||||
m=re.match(" *(.*?):(.*)",line)
|
||||
if (m):
|
||||
data_dict[m.group(1)]=m.group(2)
|
||||
else:
|
||||
data_dict=None
|
||||
|
||||
|
||||
|
||||
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from espeasy import *
|
||||
from node import *
|
||||
import config
|
||||
import time
|
||||
|
||||
|
||||
espeasy1=EspEasy(Node(config.nodes[0]))
|
||||
espeasy2=EspEasy(Node(config.nodes[1]))
|
||||
|
||||
|
||||
espeasy2.controller_domoticz_mqtt(index=1, controllerip=config.mqtt_broker)
|
||||
espeasy2.device_p001(index=1, taskdevicepin1=12, plugin_001_type=1, plugin_001_button=0)
|
||||
|
||||
espeasy1.control(cmd="gpio,12,1")
|
||||
time.sleep(1)
|
||||
espeasy1.control(cmd="gpio,12,0")
|
||||
Reference in New Issue
Block a user