powersensor_local.plug_api

Interface abstraction for Powersensor plugs.

Classes

PlugApi(mac, ip[, port, proto])

The primary interface to access the interpreted event stream from a plug.

class powersensor_local.plug_api.PlugApi(mac, ip, port=49476, proto='udp')[source]

Bases: AsyncEventEmitter

The primary interface to access the interpreted event stream from a plug.

The plug may be relaying messages from one or more sensors, in addition to its own reports.

Acts as an AsyncEventEmitter. Events which can be registered for are documented in xlatemsg.translate_raw_message.

connect()[source]

Initiates a connection to the plug.

Will automatically retry on failure or if the connection is lost, until such a time disconnect() is called.

async disconnect()[source]

Disconnects from the plug and stops further connection attempts.

property ip_address

Return the IP address provided on construction.

Returns:

The IP address configured for the listener.

Return type:

str

property port

Return the port number provided on construction.

Returns:

The TCP/UDP port configured for the listener.

Return type:

int