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 diff --git a/usage_example.py b/usage_example.py index 267dc5c..5bd0641 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('your_config_file.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()) - - - -