From 921b230d234198eccb747dd218ce290105bf5e09 Mon Sep 17 00:00:00 2001 From: lboue Date: Mon, 4 Feb 2019 23:07:10 +0100 Subject: [PATCH] Handle boilerStatus Examle: Success with message (for boilerStatus) --- netatmo2MQTT.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/netatmo2MQTT.py b/netatmo2MQTT.py index f97fb72..05c3000 100755 --- a/netatmo2MQTT.py +++ b/netatmo2MQTT.py @@ -79,7 +79,8 @@ def getNetAtmoThermostat(naClientId, naClientSecret, naRefreshToken): return (False, {"time": tstamp, "message": "Netatmo data not well formed"}, {}) newObject = {"time": tstamp, "temp": homeData['body']['home']['rooms'][0]['therm_measured_temperature']} newObjectSetpoint = {"time": tstamp, "temp": homeData['body']['home']['rooms'][0]['therm_setpoint_temperature']} - return (status, newObject, newObjectSetpoint) + boilerStatus = {"time": tstamp, "boilerStatus": homeData['body']['home']['modules'][1]['boiler_status']} + return (status, newObject, newObjectSetpoint, boilerStatus) except requests.exceptions.RequestException as e: return (False, {"time": tstamp, "message": "NetAtmo not available : " + str(e)}, {}) @@ -108,17 +109,20 @@ def getNetAtmoThermostat(naClientId, naClientSecret, naRefreshToken): args = parser.parse_args() verbose = args.verbose -status, data, dataSetpoint = getNetAtmoThermostat(args.naClientId, args.naClientSecret, args.naRefreshToken) +status, data, dataSetpoint, boilerStatus = getNetAtmoThermostat(args.naClientId, args.naClientSecret, args.naRefreshToken) if status: jsonString = json.dumps(data) jsonStringSetpoint = json.dumps(dataSetpoint) + jsonStringBoiler = json.dumps(boilerStatus) debug("Success with message (for current temperature) <{0}>".format(jsonString)) debug("Success with message (for setpoint temperature) <{0}>".format(jsonStringSetpoint)) + debug("Success with message (for boilerStatus) <{0} ; boilerStatus={1}>".format(date_setpoint, boilerStatus["boilerStatus"]) if not args.dryRun: publish.single(args.topic, jsonString, hostname=args.host) publish.single(args.topicSetpoint, jsonStringSetpoint, hostname=args.host) + publish.single(args.topicBoiler, jsonStringBoiler, hostname=args.host) else: jsonString = json.dumps(data) debug("Failure with message <{0}>".format(jsonString))