Welcome to hut2’s documentation!¶
Contents:
hut2.protocol
module¶
-
class
hut2.protocol.
HUT2
(user=b'admin', password=b'anel')[source]¶ ANEL HUT2 Driver
Power relay switch with 8 channels, and 8 channels general purpose IO.
Relay and IO indices start with 1.
- Commands tend to keep the device busy for a while.
Pace them, read back the status after a while and retry them.
- Some commands sometimes return a status update. Since they are UDP,
neither commands nor replies are guaranteed to arrive.
- Parameters
user – Device user name (bytes)
password – Device password (bytes)
-
classmethod
connect
(host, port=7500, local_addr=('255.255.255.255', 7700), loop=None, **kwargs)[source]¶ Connect to a Anel HUT2 via UDP
- Parameters
host – IO or host name of the device
port – UDP port on the device. Default is 7500 (unprivileged) as opposed to 75 (privileged). Ensure this is set correctly in the web interface.
local_addr – Tuple of local address (or hostname) and UDP port. Default is (“255.255.255.255”, 7500) (broadcast, unprivileged). The device default is to reply to port 75 (privileged). Ensure this is set correctly in the web interface.
- Returns
HUT2 instance connected to the device
-
connection_lost
(exc)[source]¶ Called when the connection is lost or closed.
The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed).
-
connection_made
(transport)[source]¶ Called when a connection is made.
The argument is the transport representing the pipe connection. To receive data, wait for data_received() calls. When the connection is closed, connection_lost() is called.
-
get_status
()[source]¶ Get a status update.
This is a coroutine that performs the status query and returns the result.
- Returns
Status
with the parsed fields