Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions netatmo2MQTT.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)}, {})

Expand Down Expand Up @@ -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))
Expand Down