diff --git a/README.md b/README.md index 304a53a..a5adb02 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ TinyTuya has a built-in setup Wizard that uses the Tuya IoT Cloud Platform to ge 1. Pick the correct Data Center "Region" for your location (check [HERE](https://developer.tuya.com/en/docs/iot/oem-app-data-center-distributed?id=Kafi0ku9l07qb#title-3-Western%20America%20Data%20Center) to find your Region). This will be used by TinyTuya Wizard ([screenshot](https://user-images.githubusercontent.com/836718/138598647-c9657e49-1a89-4ed6-8105-ceee95d9513f.png)). 2. Skip the configuration wizard but remember the Authorization Key: *API ID* and *Secret* for below ([screenshot](https://user-images.githubusercontent.com/836718/138598788-f74d2fe8-57fa-439c-8003-18735a44e7e5.png)). * Click on "Cloud" icon -> Select your project -> **Devices** -> **Link Tuya App Account** ([see screenshot](https://user-images.githubusercontent.com/836718/155827671-44d5fce4-0119-4d0e-a224-ef3715fafc24.png)) - * Click **Add App Account** ([screenshot](https://user-images.githubusercontent.com/836718/273364035-0fd133b7-4e9e-4a6d-900e-efe63d69f1a0.png)) and it will pop-up a "Link Tuya App Account" dialog, chose "Automatic" and "Read Only Status" (it will still alow commands). Click OK and it will display a QR code. Scan the QR code with the *Smart Life app* on your Phone (see step 1 above) by going to the "Me" tab in the *Smart Life app* and clicking on the QR code button `[..]` in the upper right hand corner of the app. When you scan the QR code, it will link all of the devices registered in your *Smart Life app* into your Tuya IoT project. + * Click **Add App Account** ([screenshot](https://user-images.githubusercontent.com/836718/273364035-0fd133b7-4e9e-4a6d-900e-efe63d69f1a0.png)) and it will pop-up a "Link Tuya App Account" dialog, chose "Automatic" and "Read Only Status" (it will still alow commands). Click OK and it will display a QR code. Scan the QR code with the *Smart Life app* on your Phone (see step 1 above) by going to the "Me" tab in the *Smart Life app* and clicking on the QR code button `[..]` in the upper right hand corner of the app. When you scan the QR code, it will link all of the devices registered in your *Smart Life app* into your Tuya IoT project. If the QR code will not scan then make sure to disable any browser theming plug-ins (such as Dark Reader) and try again. * **NO DEVICES?** If no devices show up after scanning the QR code, you will need to select a different data center and edit your project (or create a new one) until you see your paired devices from the *Smart Life App* show up. ([screenshot](https://user-images.githubusercontent.com/35581194/148679597-391adecb-a271-453b-90c0-c64cdfad42e4.png)). The data center may not be the most logical. As an example, some in the UK have reported needing to select "Central Europe" instead of "Western Europe". * **SERVICE API:** Under "Service API" ensure these APIs are listed: `IoT Core` and `Authorization`. To be sure, click subscribe again on every service. Very important: **disable popup blockers** otherwise subscribing won't work without providing any indication of a failure. Make sure you authorize your Project to use those APIs: - Click "Service API" tab diff --git a/RELEASE.md b/RELEASE.md index e07118a..78e2e14 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,5 +1,10 @@ # RELEASE NOTES +## v1.13.2 - Contrib Updates + +* Makes some tweaks to the recently-added Contrib/PresenceDetectorDevice by @mrioan and Deprecates Contrib/__init__.py by @uzlonewolf in https://github.com/jasonacox/tinytuya/pull/466 +* And adds a note about QR code scanning with Dark Reader to the README. #463 + ## v1.13.1 - Cryptography Version * PyPI 1.13.1 diff --git a/examples/Contrib/PresenceDetectorDevice-example.py b/examples/Contrib/PresenceDetectorDevice-example.py new file mode 100644 index 0000000..d95ec62 --- /dev/null +++ b/examples/Contrib/PresenceDetectorDevice-example.py @@ -0,0 +1,36 @@ +from tinytuya.Contrib import PresenceDetectorDevice +#from tinytuya import core +import time +import logging +import requests + +log = logging.getLogger(__name__) +device_id = 'XXXX' +device_ip = 'YYYY' +local_key = 'ZZZZ' +iftt_url = "https://maker.ifttt.com/trigger/{webhook_name_here}/json/with/key/{key_here}" + +def main(): + setup() + run() + +def setup(): + global device + device = PresenceDetectorDevice.PresenceDetectorDevice(device_id, address=device_ip, local_key=local_key, version=3.3) + +def run(): + log.info(" >>>> Begin Monitor Loop <<<< ") + while(True): + presence = device.get_presence_state() + if (presence == 'presence'): + log.info('ALERT! Presence detected!') + presence_detected_steps() + else: + log.debug('no presence, sleep...') + time.sleep(20) + +def presence_detected_steps(): + requests.post(iftt_url, json={}) + +if __name__ == "__main__": + main() diff --git a/tinytuya/Contrib/PresenceDetectorDevice.py b/tinytuya/Contrib/PresenceDetectorDevice.py index c56b7e1..35e5635 100644 --- a/tinytuya/Contrib/PresenceDetectorDevice.py +++ b/tinytuya/Contrib/PresenceDetectorDevice.py @@ -1,4 +1,4 @@ -from tinytuya.core import Device +from ..core import Device import time import json @@ -130,4 +130,4 @@ def get_target_distance(self): status = self.status() if "Error" in status: return satus - return status[self.DPS_KEY][self.TARGET_DISTANCE_KEY] \ No newline at end of file + return status[self.DPS_KEY][self.TARGET_DISTANCE_KEY] diff --git a/tinytuya/Contrib/README.md b/tinytuya/Contrib/README.md index 59ed089..0c40ff8 100644 --- a/tinytuya/Contrib/README.md +++ b/tinytuya/Contrib/README.md @@ -129,46 +129,25 @@ In addition to the built-in `OutletDevice`, `BulbDevice` and `CoverDevice` devic ```python from tinytuya.Contrib import PresenceDetectorDevice - from tinytuya import core import time - import logging - import requests - log = logging.getLogger(__name__) device_id = 'XXXX' device_ip = 'YYYY' local_key = 'ZZZZ' - iftt_url = "https://maker.ifttt.com/trigger/{webhook_name_here}/json/with/key/{key_here}" - - def main(): - setup() - run() - - def setup(): - global device - device = PresenceDetectorDevice(device_id, address=device_ip, local_key=local_key) - device.set_version(3.3) - - def run(): - log.info(" >>>> Begin Monitor Loop <<<< ") - while(True): - presence = device.get_presence_state() - if (presence == 'presence'): - log.info('ALERT! Presence detected!') - presence_detected_steps() - else: - log.debug('no presence, sleep...') - time.sleep(20) - - def presence_detected_steps(): - requests.post(iftt_url, json={}) - - if __name__ == "__main__": - main() + + device = PresenceDetectorDevice.PresenceDetectorDevice(device_id, address=device_ip, local_key=local_key) + + print(" >>>> Begin Monitor Loop <<<< ") + while(True): + presence = device.get_presence_state() + if (presence == 'presence'): + print('Presence detected!') + else: + print('no presence, sleep...') + time.sleep(20) ``` ## Submit Your Device * We welcome new device modules! * Follow the template example in [ThermostatDevice.py](ThermostatDevice.py) to add your device. -* Add your module to the [__init__.py](__init__.py) file. diff --git a/tinytuya/Contrib/__init__.py b/tinytuya/Contrib/__init__.py index bdb4245..48b9706 100644 --- a/tinytuya/Contrib/__init__.py +++ b/tinytuya/Contrib/__init__.py @@ -1,3 +1,8 @@ +# +# Note: This file has been deprecated, please do not add new modules to it. +# Instead, import new modules with `from tinytuya.Contrib import YourNewModule` +# and call with `YourNewModule.YourNewModule(...)` +# from .ThermostatDevice import ThermostatDevice from .IRRemoteControlDevice import IRRemoteControlDevice @@ -6,6 +11,5 @@ from .ClimateDevice import ClimateDevice from .AtorchTemperatureControllerDevice import AtorchTemperatureControllerDevice from .InverterHeatPumpDevice import InverterHeatPumpDevice, TemperatureUnit, InverterHeatPumpMode, InverterHeatPumpFault -from .PresenceDetectorDevice import PresenceDetectorDevice -DeviceTypes = ["ThermostatDevice", "IRRemoteControlDevice", "SocketDevice", "DoorbellDevice", "ClimateDevice", "AtorchTemperatureControllerDevice", "InverterHeatPumpDevice", "PresenceDetectorDevice"] +DeviceTypes = ["ThermostatDevice", "IRRemoteControlDevice", "SocketDevice", "DoorbellDevice", "ClimateDevice", "AtorchTemperatureControllerDevice", "InverterHeatPumpDevice"] diff --git a/tinytuya/core.py b/tinytuya/core.py index 586b45b..7bc31d6 100644 --- a/tinytuya/core.py +++ b/tinytuya/core.py @@ -123,7 +123,7 @@ # Colorama terminal color capability for all platforms init() -version_tuple = (1, 13, 1) +version_tuple = (1, 13, 2) version = __version__ = "%d.%d.%d" % version_tuple __author__ = "jasonacox"