-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #466 from uzlonewolf/misc-20240222
Misc 2024-02-22
- Loading branch information
Showing
7 changed files
with
62 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters