Skip to content

Commit 6efb37d

Browse files
committed
Address doc gen errors
1 parent ec1f319 commit 6efb37d

8 files changed

Lines changed: 54 additions & 39 deletions

File tree

docs/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ BUILDDIR = build
88
help:
99
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
1010

11-
.PHONY: help Makefile
11+
.PHONY: help Makefile clean
1212

1313
%: Makefile
1414
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
15+
16+
clean:
17+
-rm -rf "$(BUILDDIR)" "$(SOURCEDIR)/submodules"

docs/source/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
submodules

docs/source/api.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,7 @@ __________
1313
:toctree: submodules
1414
:recursive:
1515

16-
devices
17-
listener
16+
devices
17+
plug_api
18+
virtual_household
19+
xlatemsg

src/powersensor_local/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
a household view is available in VirtualHousehold.
2323
2424
Quick overview:
25-
PlugApi is the recommended API layer
26-
PlugListenerUdp is the UDP lower-level abstraction used by PlugApi
27-
PlugListenerTcp is the TCP lower-level abstraction used by PlugApi
28-
PowersensorDevices is the legacy main API layer
29-
LegacyDiscovery provides access to the legacy discovery mechanism
30-
VirtualHousehold can be used to translate events into a household view
25+
- PlugApi is the recommended API layer
26+
- PlugListenerUdp is the UDP lower-level abstraction used by PlugApi
27+
- PlugListenerTcp is the TCP lower-level abstraction used by PlugApi
28+
- PowersensorDevices is the legacy main API layer
29+
- LegacyDiscovery provides access to the legacy discovery mechanism
30+
- VirtualHousehold can be used to translate events into a household view
3131
3232
The 'plugevents' and 'rawplug' modules are helper utilities provided as
3333
debug aids, which get installed under the names ps-plugevents and ps-rawplug

src/powersensor_local/devices.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@ async def start(self, async_event_cb):
3333
of the local network to discover present devices. The callback is
3434
of the form
3535
36-
async def yourcallback(event: dict)
36+
async def yourcallback(event: dict) -> None
3737
3838
Known events:
3939
40-
scan_complete:
40+
**scan_complete**
4141
Indicates the discovery of Powersensor devices has completed.
4242
Emitted in response to start() and rescan() calls.
4343
The number of found gateways (plugs) is reported.
4444
4545
{ event: "scan_complete", gateway_count: N }
4646
47-
device_found:
47+
**device_found**
4848
A new device found on the network.
4949
The order found devices are announced is not fixed.
5050
@@ -53,16 +53,14 @@ async def yourcallback(event: dict)
5353
mac: "...",
5454
}
5555
56-
device_lost:
56+
**device_lost**
5757
A device appears to no longer be present on the network.
5858
5959
{ event: "device_lost", mac: "..." }
6060
61-
6261
Additionally, all events described in xlatemsg.translate_raw_message
6362
may be issued. The event name is inserted into the field 'event'.
6463
65-
6664
The start function returns the number of found gateway plugs.
6765
Powersensor devices aren't found directly as they are typically not
6866
on the network, but are instead detected when they relay data through

src/powersensor_local/plug_listener_tcp.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""An interface for accessing the event stream from a Powersensor plug."""
1+
"""Internal helper for accessing the event stream from a Powersensor plug."""
22
import asyncio
33
import json
44

@@ -12,18 +12,19 @@
1212
from powersensor_local.async_event_emitter import AsyncEventEmitter
1313

1414
class PlugListenerTcp(AsyncEventEmitter):
15-
"""An interface class for accessing the event stream from a single plug.
15+
"""Internal helper for accessing the event stream from a Powersensor plug.
16+
1617
The following events may be emitted:
1718
- ("connecting") Whenever a connection attempt is made.
1819
- ("connected") When a connection is successful.
1920
- ("disconnected") When a connection is dropped, be it intentional or not.
2021
- ("message",{...}) For each event message received from the plug. The
21-
plug's JSON message is decoded into a dict which is passed as the second
22-
argument to the registered event handler(s).
22+
plug's JSON message is decoded into a dict which is passed as the second
23+
argument to the registered event handler(s).
2324
- ("malformed",line) If JSON decoding of a message fails. The raw line
24-
is included (as a byte string).
25+
is included (as a byte string).
2526
26-
The event handlers must be async.
27+
The event handlers must be async.
2728
"""
2829

2930
def __init__(self, ip, port=49476):

src/powersensor_local/plug_listener_udp.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""An interface for accessing the event stream from a Powersensor plug."""
1+
"""Internal helper for accessing the event stream from a Powersensor plug."""
22
import asyncio
33
import json
44
import socket
@@ -15,18 +15,19 @@
1515
# pylint: disable=R0902
1616
# @todo: dream up a base class for PlugListener that TCP/UDP subclass
1717
class PlugListenerUdp(AsyncEventEmitter, asyncio.DatagramProtocol):
18-
"""An interface class for accessing the event stream from a single plug.
18+
"""Internal helper for accessing the event stream from a Powersensor plug.
19+
1920
The following events may be emitted:
2021
- ("connecting") Whenever a connection attempt is made.
2122
- ("connected") When a connection is successful.
2223
- ("disconnected") When a connection is dropped, be it intentional or not.
2324
- ("message",{...}) For each event message received from the plug. The
24-
plug's JSON message is decoded into a dict which is passed as the second
25-
argument to the registered event handler(s).
25+
plug's JSON message is decoded into a dict which is passed as the
26+
second argument to the registered event handler(s).
2627
- ("malformed",line) If JSON decoding of a message fails. The raw line
27-
is included (as a byte string).
28+
is included (as a byte string).
2829
29-
The event handlers must be async.
30+
The event handlers must be async.
3031
"""
3132

3233
def __init__(self, ip, port=49476):

src/powersensor_local/xlatemsg.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -128,21 +128,24 @@ def translate_raw_message(message: dict, relay_mac: str):
128128
Translates raw messages from the plug API into stable, documented events.
129129
130130
Args:
131-
- message: The raw message (decoded into a dict)
132-
- relay_mac: The id (MAC address) of the plug the message was received
131+
message: The raw message (decoded into a dict)
132+
relay_mac: The id (MAC address) of the plug the message was received
133133
through. When the message origin is not the plug, the events returned
134134
from this function will have "via": relay_mac added to denote what
135135
plug is acting as the relay for them.
136136
137137
Returns:
138+
138139
A dictionary of events, quite possibly empty. The key is the event
139140
name that the event should be emitted under, with the value being
140141
the event data itself (a dict).
141142
142143
Possible events returned:
144+
143145
- "average_power": An event denoting the average power seen over a
144146
short duration, such as 1 or 30 seconds typically. Both plugs and
145147
powersensors may originate these. The event data comprises:
148+
146149
- "mac": The MAC address of the device.
147150
- "role": The assigned role of the device, if known.
148151
- "via": The id of the relaying plug, if from a sensor.
@@ -155,6 +158,7 @@ def translate_raw_message(message: dict, relay_mac: str):
155158
information on the power components feeding into the power measurement.
156159
To be read in conjunction with the "average_power" message with the
157160
same starttime_utc value. Comprises:
161+
158162
- "mac": The MAC address of the device.
159163
- "role": The assigned role of the device, if known.
160164
- "starttime_utc": Seconds since the Unix Epoch, in UTC.
@@ -165,6 +169,7 @@ def translate_raw_message(message: dict, relay_mac: str):
165169
166170
- "summation_energy": An event reporting an energy summation value.
167171
Issued for both plugs and sensors. Comprises:
172+
168173
- "mac": The MAC address of the device.
169174
- "role": The assigned role of the device, if known.
170175
- "via": The id of the relaying plug, if from a sensor.
@@ -184,6 +189,7 @@ def translate_raw_message(message: dict, relay_mac: str):
184189
- "average_flow": An event denoting the average flow rate seen over a
185190
short duration, such as 1 or 30 seconds typically. Only originated by
186191
water sensors. The event data comprises:
192+
187193
- "mac": The MAC address of the device.
188194
- "role": The assigned role of the device, if known.
189195
- "via": The id of the relaying plug.
@@ -193,6 +199,7 @@ def translate_raw_message(message: dict, relay_mac: str):
193199
194200
- "summation_volume": An event reporting a volume summation value.
195201
Issued only for water sensors. Comprises:
202+
196203
- "mac": The MAC address of the device.
197204
- "role": The assigned role of the device, if known.
198205
- "via": The id of the relaying plug.
@@ -209,33 +216,36 @@ def translate_raw_message(message: dict, relay_mac: str):
209216
unknown unit, for an average over a short duration, such as 1 or 30
210217
seconds typically. Issued by powersensors, prior to calibration.
211218
The event data comprises:
219+
212220
- "mac": The MAC address of the device.
213221
- "role": The assigned role of the device, if known.
214222
- "via": The id of the relaying plug.
215223
- "starttime_utc": Seconds since the Unix Epoch, in UTC.
216224
- "duration_s": The number of seconds the reading is calculated over.
217225
- "value": The value, in unspecified units. The only valid thing
218-
to use this value for is display it relative to other uncalibrated
219-
values from the same device. The magnitude of the value is an
220-
indication of the strength of the signal seen by the sensor, but
221-
the unit is most definitely NOT in Watts. For most purposes, this
222-
event can (and should be) ignored. Once the backend has successfully
223-
calibrated the sensor against one or more plugs, these events
224-
will be replaced by "average_power" events instead.
226+
to use this value for is display it relative to other uncalibrated
227+
values from the same device. The magnitude of the value is an
228+
indication of the strength of the signal seen by the sensor, but
229+
the unit is most definitely NOT in Watts. For most purposes, this
230+
event can (and should be) ignored. Once the backend has successfully
231+
calibrated the sensor against one or more plugs, these events
232+
will be replaced by "average_power" events instead.
225233
226234
- "battery_level": An event reporting the battery level of a sensor.
227235
The event data comprises:
236+
228237
- "mac": The MAC address of the device.
229238
- "role": The assigned role of the device, if known.
230239
- "via": The id of the relaying plug.
231240
- "starttime_utc": Seconds since the Unix Epoch, in UTC.
232241
- "volts": The current battery level, in Volts. Sensors operate
233-
on 3.7V nominally, with a fully charged battery at around 4.2V.
234-
Precise battery curves vary individually.
242+
on 3.7V nominally, with a fully charged battery at around 4.2V.
243+
Precise battery curves vary individually.
235244
236245
- "radio_signal_quality": An event reporting radio signal quality for
237246
a sensor. Note that this is for the long-range radio comms with the
238247
plug, not for the WiFi signal. The event comprises:
248+
239249
- "mac": The MAC address of the device.
240250
- "role": The assigned role of the device, if known.
241251
- "via": The id of the relaying plug.
@@ -245,7 +255,6 @@ def translate_raw_message(message: dict, relay_mac: str):
245255
during the reporting window. Values below -90 are considered poor
246256
reception.
247257
- "last_rssi": The most recent RSSI value.
248-
249258
"""
250259
evs: dict = {}
251260
typ = message['type']

0 commit comments

Comments
 (0)