From 744fa4998ec2ead88958dfc6f4e5a299abaa36f2 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 6 Feb 2022 19:58:53 +0300 Subject: [PATCH 1/2] README.md Update install info and remove wait_for_notice --- README.md | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index f9f273a..d20199d 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ I finally came across Peter's work written in python and it was exactly what I w Use pip or easy_install -> pip install sonoff-python +> pip install git+https://github.com/Baton34/sonoff-python The requirements are requests and websocket-client, see _requirements.txt_ @@ -38,38 +38,19 @@ Here's a really simple example of how you can use this library. ``` import sonoff -import json -import signal -import sys -import requests device_name = 'SonoffBridge' sensor_name = 'Motion sensor 1' -def signal_handler(signal, frame): - sys.exit(0) - -def on_message(*args): - data = json.loads(args[-1]) - print(data) - -def on_error(*args): - print(args[-1]) - def main(): - signal.signal(signal.SIGINT, signal_handler) - - connection = sonoff.Sonoff( - 'username', - 'password', - 'eu' - ) + connection = sonoff.Sonoff('username', 'password', 'eu') for device in connection.get_devices(): + print(device['name']) + if device['name'] == device_name: device_data = connection.get_device(device['deviceid']) - connection.wait_for_notice(device['deviceid'], on_message, on_error) - break + print(device_data) if __name__ == '__main__': main() From ce042d4818f4edc294410edd06ac6bf4aed2f810 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 6 Feb 2022 20:05:06 +0300 Subject: [PATCH 2/2] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index d20199d..48bb962 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,6 @@ Here's a really simple example of how you can use this library. import sonoff device_name = 'SonoffBridge' -sensor_name = 'Motion sensor 1' def main(): connection = sonoff.Sonoff('username', 'password', 'eu')