Skip to content

Commit 451cc12

Browse files
authored
Merge pull request #1405 from enkiusz/tinycontrol-ippower-6g10a-support
labgrid/driver/power: Backend for tinycontrol.eu IP Power Socket 6G10A v2
2 parents 1296989 + 95f8127 commit 451cc12

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

doc/configuration.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,11 @@ Currently available are:
231231
Controls *TP-Link power strips* via `python-kasa
232232
<https://github.com/python-kasa/python-kasa>`_.
233233

234+
``tinycontrol``
235+
Controls a tinycontrol.eu IP Power Socket via HTTP.
236+
It was tested on the *6G10A v2* model.
237+
`Manual <https://tinycontrol.pl/media/documents/manual_IP_Power_Socket__6G10A_v2_LANLIS-010-015_En-1.pdf>`__
238+
234239
``poe_mib``
235240
Controls PoE switches using the PoE SNMP administration MiBs.
236241

labgrid/driver/power/tinycontrol.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
""" A driver to control the Tinycontrol IP Power Socket 6G10A v2
2+
Reference: https://tinycontrol.pl/media/documents/manual_IP_Power_Socket__6G10A_v2_LANLIS-010-015_En-1.pdf
3+
4+
Example configuration to use port #3 on a device with URL 'http://172.17.180.53:9999/'
5+
6+
NetworkPowerPort:
7+
model: tinycontrol
8+
host: 'http://172.17.180.53:9999/'
9+
index: 3
10+
"""
11+
12+
import requests
13+
from urllib.parse import urljoin
14+
import xml.etree.ElementTree as ET
15+
16+
17+
def power_set(host, port, index, value):
18+
assert port is None
19+
20+
index = int(index)
21+
value = 1 if value else 0
22+
r = requests.get(urljoin(host, f"/outs.cgi?out{index}={value}"))
23+
r.raise_for_status()
24+
25+
26+
def power_get(host, port, index):
27+
assert port is None
28+
29+
index = int(index)
30+
r = requests.get(urljoin(host, "/st0.xml"))
31+
r.raise_for_status()
32+
root = ET.fromstring(r.text)
33+
output = root.find(f"out{index}")
34+
return output.text == '1'

0 commit comments

Comments
 (0)