From 38749c5c8faa576b3f581d6f3edc968c29381a2b Mon Sep 17 00:00:00 2001 From: Charles Powell Date: Mon, 28 Feb 2022 17:59:21 -0700 Subject: [PATCH 1/3] Update usage_example with latest async approach --- usage_example.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/usage_example.py b/usage_example.py index 267dc5c..ecbe804 100644 --- a/usage_example.py +++ b/usage_example.py @@ -1,29 +1,23 @@ from SenseLink import * -import asyncio import logging import sys -import nest_asyncio -nest_asyncio.apply() root = logging.getLogger() root.setLevel(logging.DEBUG) handler = logging.StreamHandler(sys.stdout) -async def main(): +def main(): # Get config - config = open('config_example.yml', 'r') + config = open('config_private.yml', 'r') # Create controller, with config controller = SenseLink(config) # Start and run indefinitely + logging.info("Starting SenseLink controller") loop = asyncio.get_event_loop() - loop.create_task(controller.start()) - loop.run_forever() + tasks = asyncio.gather(*[controller.start()]) + loop.run_until_complete(tasks) if __name__ == "__main__": asyncio.run(main()) - - - - From 44c5337f9e5418067a29a48423e5e86ce4d96a5a Mon Sep 17 00:00:00 2001 From: Charles Powell Date: Mon, 28 Feb 2022 18:10:02 -0700 Subject: [PATCH 2/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2338665..404abdf 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ While Sense [doesn't currently](https://community.sense.com/t/smart-plugs-freque # Configuration -Configuration is defined through a YAML file, that should be passed in when creating an instance of the `SenseLink` class. See the [`config_example.yml`](https://github.com/cbpowell/SenseLink/blob/master/config_example.yml) file for a an example setup. +Configuration is defined through a YAML file, that should be passed in when creating an instance of the `SenseLink` class. See the [`config_example.yml`](https://github.com/cbpowell/SenseLink/blob/master/config_example.yml) file for an example setup. The YAML configuration file should start with a top level `sources` key, which defines an array of sources for power data. Each source then has a `plugs` key to define an array of individual emulated plugs, plugs other configuration details as needed for that particular source. The current supported sources types are: - `hass`: Home Assistant, via the Websockets API From 86a3e925ab3243418f6e82e609c678385d373c4a Mon Sep 17 00:00:00 2001 From: Charles Powell Date: Mon, 28 Feb 2022 21:16:50 -0700 Subject: [PATCH 3/3] Update usage_example.py --- usage_example.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usage_example.py b/usage_example.py index ecbe804..5bd0641 100644 --- a/usage_example.py +++ b/usage_example.py @@ -9,7 +9,7 @@ def main(): # Get config - config = open('config_private.yml', 'r') + config = open('your_config_file.yml', 'r') # Create controller, with config controller = SenseLink(config) # Start and run indefinitely