Skip to content

Commit b8b1a08

Browse files
committed
make port and ip publicly accessible (if read only). this will be required for HA integration
1 parent b1ca625 commit b8b1a08

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

src/powersensor_local/plug_api.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,7 @@ async def _on_exception(self, _, e):
8888
@property
8989
def ip_address(self):
9090
return self._listener.ip
91+
92+
@property
93+
def port(self):
94+
return self._listener.port

src/powersensor_local/plug_listener_tcp.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ async def _send_subscribe(writer):
116116
writer.write(b'subscribe(60)\n')
117117
await writer.drain()
118118

119+
@property
120+
def port(self):
121+
return self._port
122+
119123
@property
120124
def ip(self):
121125
return self._ip

src/powersensor_local/plug_listener_udp.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from powersensor_local.async_event_emitter import AsyncEventEmitter
1212

13+
# @todo: dream up a base class for PlugListener that TCP/UDP subclass
1314
class PlugListenerUdp(AsyncEventEmitter, asyncio.DatagramProtocol):
1415
"""An interface class for accessing the event stream from a single plug.
1516
The following events may be emitted:
@@ -146,3 +147,11 @@ def error_received(self, exc):
146147
def connection_lost(self, exc):
147148
if self._transport is not None:
148149
asyncio.create_task(self._close_connection(False))
150+
151+
@property
152+
def port(self):
153+
return self._port
154+
155+
@property
156+
def ip(self):
157+
return self._ip

0 commit comments

Comments
 (0)