jabesq / netatmo-api-python

Simple API to access Netatmo weather station data from any python script (for Netatmo information, see www.netatmo.com)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Thermostat setpoint is read from the wrong property

orcinus opened this issue · comments

The library reads the Thermostat setpoint from:

self.setpoint_temp = self.modList[0]['measured']['setpoint_temp']

This is based on an incorrect assumption that this is always the actual setpoint temperature. This property only reflects the current scheduled temperature, not the actual setpoint. When the temperature is adjusted manually, the setpoint should be read from:

self.setpoint_temp = self.modList[0]['setpoint']['setpoint_temp']

Per the API documentation:

setpoint - setpoint_temp: For manual mode only. Value of the manual stepoint.

Since the whole point of using this fork is to manually adjust the setpoint from within Home Assistant - implying manual setpoint is kinda the main use case, this is (IMO) obviously a bug.

Proposed fix - make the ThermostatData constructor logic work like this:

  • obtain self.setpoint_mode first
  • if self.setpoint_mode == manual, read ['setpoint']['setpoint_temp'] into self.setpoint_temp
  • else read read ['measured']['setpoint_temp'] into self.setpoint_temp

Additionally, the whole Getthermostatsdata endpoint appears to be deprecated.

Should probably switch to using Getroommeasure instead. It accepts a type parameter, which seems to use the sp_temperature value to get the setpoint temperature for both manual and non-manual mode.

Obv. this will require multiple requests to the API to get the same info Getthermostatsdata provides, but if it's the only way forward...

PR here: #20