From ddb0d13be6f5cd4b42ab598b5eeda061ed80d3f6 Mon Sep 17 00:00:00 2001 From: Tilman Date: Thu, 20 May 2021 09:08:00 +0200 Subject: [PATCH] fine tuning --- garage/garage.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/garage/garage.py b/garage/garage.py index f6e5fe0..164758a 100644 --- a/garage/garage.py +++ b/garage/garage.py @@ -55,24 +55,26 @@ def mower_safety(): response = requests.get("http://192.168.178.54/json?cmd=status&user=lewe&pass=nFdcX3sMD115WAap") #response = '{"name": "Rasi", "id": "C7697E", "status": {"status": 17, "distance": 0, "stopped": false, "duration": 4290, "mode": 2, "battery": 100, "hours": 90}, "timer": {"status": 0}, "wlan": {"signal": -86}, "health": {"temperature": 23, "humidity": 25}, "clock": {"date": "2021-05-13", "time": "14:23:27", "unix": 1620915807}, "successful": true}' except requests.exceptions.RequestException as e: - #logger.warning("couldn't reach mower") pushover("couldn't reach mower (retrieving status)") return None status = json.loads(response.text) #status = json.loads(jsonstr) if (status["status"]["status"] in [2, 3, 5]): - pushover("mower, run for your life") - try: - #response = requests.get("http://192.168.178.54/json?cmd=mode&mode=job&remotestart=2&user=lewe&pass=nFdcX3sMD115WAap") - response = requests.get("http://192.168.178.54/json?cmd=stop&user=lewe&pass=nFdcX3sMD115WAap") - except requests.exceptions.RequestException as e: - pushover("couldn't reach mower (retrieving status)") + if (status["status"]["distance"] < 20): + pushover("mower, freeze") + try: + #response = requests.get("http://192.168.178.54/json?cmd=mode&mode=job&remotestart=2&user=lewe&pass=nFdcX3sMD115WAap") + response = requests.get("http://192.168.178.54/json?cmd=stop&user=lewe&pass=nFdcX3sMD115WAap") + except requests.exceptions.RequestException as e: + pushover("couldn't reach mower (freeze)") + else: + pushover("mower in the back yard, keep going") else: pushover("lock mower in garage") try: response = requests.get("http://192.168.178.54/json?cmd=mode&mode=home&user=lewe&pass=nFdcX3sMD115WAap") except requests.exceptions.RequestException as e: - pushover("couldn't reach mower (retrieving status)") + pushover("couldn't reach mower (lock)") # robomower back to auto mode after gate has been closed @@ -81,8 +83,7 @@ def mower_auto(): try: response = requests.get("http://192.168.178.54/json?cmd=mode&mode=auto&user=lewe&pass=nFdcX3sMD115WAap") except requests.exceptions.RequestException as e: - #logger.warning("couldn't reach mower") - pushover("couldn't reach mower (setting auto mode)") + pushover("couldn't reach mower (auto mode)") return None def garage_button(channel):