forked from labgrid-project/labgrid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request labgrid-project#1030 from userid0x0/gude8225
driver/power: add support for Gude Expert Power Control 8225
- Loading branch information
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import requests | ||
|
||
# Driver has been tested with: | ||
# Gude Expert Power Control 8225-1 - v1.0.6 | ||
|
||
# HTTP-GET API is defined in the Gude EPC-HTTP-Interface specification: | ||
# https://wiki.gude.info/EPC_HTTP_Interface | ||
|
||
PORT = 80 | ||
|
||
|
||
def power_set(host, port, index, value): | ||
index = int(index) | ||
assert 1 <= index <= 12 | ||
|
||
value = 1 if value else 0 | ||
r = requests.get( | ||
f"https://{host}:{port}/ov.html?cmd=1&p={index}&s={value}" | ||
) | ||
r.raise_for_status() | ||
|
||
|
||
def power_get(host, port, index): | ||
index = int(index) | ||
assert 1 <= index <= 12 | ||
|
||
r = requests.get(f"https://{host}:{port}/statusjsn.js?components=1") | ||
r.raise_for_status() | ||
|
||
state = r.json()['outputs'][index - 1]['state'] | ||
|
||
return state |