Skip to content

Commit

Permalink
changed content-type for put-methods
Browse files Browse the repository at this point in the history
mytado excepts "text/plain" instead of json!
  • Loading branch information
Wolfgang Malgadey committed Jan 5, 2017
1 parent f61c964 commit ff4e535
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions PyTado/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@ def _mobile_apiCall(self, cmd):
return data

# 'Private' methods for use in class, Tado API V2.
def _apiCall(self, cmd, method="GET", data=None):
def _apiCall(self, cmd, method="GET", data=None, plain=False):
self._refreshToken()

headers = self.headers

if data is not None:
headers['Content-Type'] = 'application/json;charset=UTF-8'
if plain:
headers['Content-Type'] = 'text/plain;charset=UTF-8'
else:
headers['Content-Type'] = 'application/json;charset=UTF-8'
headers['Mime-Type'] = 'application/json;charset=UTF-8'
data=json.dumps(data).encode('utf8')

Expand Down Expand Up @@ -169,7 +172,7 @@ def getAppUsersRelativePositions(self):
def resetZoneOverlay(self, zone):
"""Delete current overlay"""
cmd = 'zones/%i/overlay' % zone
data = self._apiCall(cmd, "DELETE", {})
data = self._apiCall(cmd, "DELETE", {}, True)
return data

def setZoneOverlay(self, zone, overlayMode, setTemp=None, duration=None):
Expand Down Expand Up @@ -202,7 +205,7 @@ def setZoneOverlay(self, zone, overlayMode, setTemp=None, duration=None):
if duration is not None:
postData["termination"]["durationInSeconds"] = duration

data = self._apiCall(cmd, "PUT", postData)
data = self._apiCall(cmd, "PUT", postData, True)
return data

# Ctor
Expand Down

0 comments on commit ff4e535

Please sign in to comment.