diff --git a/README.md b/README.md index 15449dc..e5f05dd 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,9 @@ https://gist.github.com/mbrownnycnyc/db3209a1045746f5e287ea6b6631e19c ## Local Device Emulation The SenseLink class emulates the energy monitoring functionality of TP-Link Kasa HS110 Smart Plugs and allows you to report "custom" power usage to your Sense Home Energy Monitor. This requires -enabling "TP-Link HS110/HS300 Smart Plug" in the Sense app +enabling "TP-Link HS110/HS300 Smart Plug" in the Sense app. + +Based off the work of https://github.com/cbpowell/SenseLink ### Contributors @@ -33,7 +35,7 @@ https://github.com/kbickar pip install sense_energy ``` -### Example Usage: +### Web API Example Usage: ```python sense = Senseable() sense.authenticate(username, password) @@ -56,3 +58,23 @@ and `get_realtime()` will retrieve the latest real time stats. The get_realtime() is by default rate limited to one call per 30 seconds. This can be modified by setting the Senseable object attribute `rate_limit` to a different value. + +### Local emulation Example Usage: +```python + async def test(): + import time + def test_devices(): + devices = [PlugInstance("lamp1", start_time=time()-20, alias="Lamp", power=10), + PlugInstance("fan1", start_time=time()-300, alias="Fan", power=140)] + for d in devices: + yield d + sl = SenseLink(test_devices) + await sl.start() + try: + await asyncio.sleep(180) # Serve for 3 minutes + finally: + await sl.stop() + + if __name__ == "__main__": + asyncio.run(test()) +``` \ No newline at end of file diff --git a/sense_energy/SenseLink.py b/sense_energy/SenseLink.py index 2a18042..2b6cfe0 100644 --- a/sense_energy/SenseLink.py +++ b/sense_energy/SenseLink.py @@ -83,20 +83,3 @@ async def start(self): async def stop(self): self.transport.close() - -async def test(): - import time - def test_devices(): - devices = [PlugInstance("lamp1", time()-20, alias="Lamp", power=10), - PlugInstance("fan1", time()-300, alias="Fan", power=140)] - for d in devices: - yield d - sl = SenseLink(test_devices) - await sl.start() - try: - await asyncio.sleep(180) # Serve for 3 minutes - finally: - await sl.stop() - -if __name__ == "__main__": - asyncio.run(test()) diff --git a/sense_energy/__init__.py b/sense_energy/__init__.py index b4dd72d..a843348 100644 --- a/sense_energy/__init__.py +++ b/sense_energy/__init__.py @@ -5,7 +5,7 @@ import sys if sys.version_info >= (3, 5): from .asyncsenseable import ASyncSenseable -from .PlugInstance import PlugInstance -from .SenseLink import SenseLink + from .PlugInstance import PlugInstance + from .SenseLink import SenseLink __version__ = "0.7.0"