Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/cbpowell/SenseLink
Browse files Browse the repository at this point in the history
  • Loading branch information
cbpowell committed Mar 2, 2022
2 parents 3790055 + 86a3e92 commit 73b727c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 5 additions & 11 deletions usage_example.py
Original file line number Diff line number Diff line change
@@ -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())




0 comments on commit 73b727c

Please sign in to comment.