Closed rmertz3282 closed 4 years ago
I'm having exactly the same issue. Did you manage to find a fix or workaround?
I think I've found the problem. It's this commit in infinitude https://github.com/nebulous/infinitude/commit/a0c3b7a58c1c3535a0811001bcfed2c43c672906 It prevents the GET operation from applying the changes
In homeassistant extension
request.urlopen(req)
is used with the params being just added as a string at the end:
if params is not None:
query = parse.urlencode(params)
url = "{}?{}".format(url, query)
According to the docs: https://docs.python.org/3/howto/urllib2.html This makes a GET operation. In order for it to be a POST we have to send parameters through a second argument of urlopen.
Long story short, this is my solution (works fine for me):
if params is not None:
requestData = parse.urlencode(params)
_LOGGER.debug(requestData)
requestData = requestData.encode('ascii')
req = request.Request(url, requestData)
else:
req = request.Request(url)
with request.urlopen(req) as response:
data = json.loads(response.read().decode())
_LOGGER.debug(data)
return data
instead of:
if params is not None:
query = parse.urlencode(params)
url = "{}?{}".format(url, query)
_LOGGER.debug(url)
req = request.Request(url)
with request.urlopen(req) as response:
data = json.loads(response.read().decode())
_LOGGER.debug(data)
return data
(starting at line 116)
Good catch. I haven’t updated my instance of Infinitude in ages. Others may be in the same boat, which could explain such little feedback about this behavior.
I need to set up a new dev environment to implement this change, and look into some other issues. Will try to address this soon.
I'll have to setup one myself. Then I could post a pull request for that. I'll try to find a minute over the weekend...
I hadn't had a chance to look into this since I last posted. I just implemented your suggestion and it works perfectly. I'll give it 24hrs before closing.
This is fixed in release 0.7
I successfully installed this component and the infinitude proxy. If I navigate to the http://:[port] of the proxy server I see valid data coming from my system, which is reflected in my HA thermostat card.
If I try to change a setting from the HA thermostat card, say fan to high. I can see the change is made on the Infinitude "Comfort Profiles" page but the action never makes it to my actual thermostat unless I hit the "save" button on that Infinitude page. It seems to me the api call from HA isn't complete or isn't posting. The only infinitude/api/ instances I find in my logger, related to a specific change are:
Note: (the repeating dots are placeholders for actual data returned).
2020-03-08 09:43:45 DEBUG (SyncWorker_7) [custom_components.infinitude.climate] http://x.x.x.x:x/api/status 2020-03-08 09:43:45 DEBUG (SyncWorker_7) [custom_components.infinitude.climate] {'cfgem'..................
2020-03-08 09:43:45 DEBUG (SyncWorker_7) [custom_components.infinitude.climate] http://x.x.x.x:x/api/config 2020-03-08 09:43:45 DEBUG (SyncWorker_7) [custom_components.infinitude.climate] {'data'..................................'status':'success'}
Is this normal? Am I missing something?