New venstar climate component#11639
Conversation
|
|
||
| PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ | ||
| vol.Required(CONF_HOST): cv.string, | ||
| vol.Optional(CONF_USERNAME, default=None): cv.string, |
There was a problem hiding this comment.
I don't think you need to set default=None. That's the default's default.
| password=password, | ||
| proto=proto) | ||
|
|
||
| add_devices([VenstarThermostat(client)]) |
There was a problem hiding this comment.
If you call this with True as second parameter, it will schedule an update right after adding the device. That might be desirable?
| def __init__(self, client): | ||
| """Initialize the thermostat.""" | ||
| self._client = client | ||
| self._client.update_info() |
There was a problem hiding this comment.
I guess this does I/O? Please don't do that in the constructor. Instead, see above: call add_devices(…, True), and HA will call your update() method right after adding the entity.
| self._client.update_info() | ||
| self._client.update_sensors() | ||
| self._fan_list = [STATE_ON, STATE_AUTO] | ||
| self._operation_list = [STATE_HEAT, STATE_COOL, STATE_IDLE, STATE_AUTO] |
There was a problem hiding this comment.
For extra cleanliness, you could extract those two lists into a tuple constant somewhere at the start of this file.
| @property | ||
| def supported_features(self): | ||
| """Return the list of supported features.""" | ||
| if self._client.mode == self._client.MODE_AUTO: |
There was a problem hiding this comment.
What does this mean? When the device is in auto mode, it tries to stay between a min and max temperature? And otherwise… it doesn't?
There was a problem hiding this comment.
That's correct, yes - the thermostat physically has 4 modes:
- heat- you set a single temperature, and the thermostat will attempt to heat the house UP TO this temp.
-cool- you set a single temperature, and the thermostat will attempt to cool the house DOWN TO this temp
-auto- you set 2 temperatures, and the thermostat will automatically swap between heating and cooling depending upon the temperature of the house. It's essentially the heat/cool mode combined.
-off/idle - no hold at all, but reporting on temp
I don't expect to use the auto setting, but felt i needed to do something for it in case someone else did.
| return 60 | ||
|
|
||
| # Commands | ||
| def set_temperature(self, **kwargs): |
There was a problem hiding this comment.
The set_temperature method can also be called with an ATTR_OPERATION_MODE in the kwargs. The idea is that the thermostat should then first set the requested operation mode, and then the requested temperature. Please check here whether ATTR_OPERATION_MODE is in the kwargs and set the operation mode accordingly.
| temperature = kwargs.get(ATTR_TEMPERATURE) | ||
|
|
||
| if self._client.mode == self._client.MODE_HEAT: | ||
| _LOGGER.info("Currently operating in heat mode. " |
There was a problem hiding this comment.
That is a lot of logging… HA will automatically print a log line when your entity changes its state. So, I'd suggest removing this.
|
|
||
| def set_fan_mode(self, fan): | ||
| """Set new target fan mode.""" | ||
| _LOGGER.info("Contacting your thermostat to " |
There was a problem hiding this comment.
Again, I think that's too much logging.
|
|
||
| def set_operation_mode(self, operation_mode): | ||
| """Set new target operation mode.""" | ||
| _LOGGER.info("Contacting your thermostat to set " |
|
|
||
| def set_humidity(self, humidity): | ||
| """Set new target humidity.""" | ||
| _LOGGER.info("Contacting your thermostat to set it's " |
|
Thanks! I've made a few comments- otherwise i'll make the recommended changes and resubmit. |
|
Ok I think we’re about ready for another look when you get a chance- we had another tester come in and highlight a few additional items to resolve. Should be good to go! |
| def __init__(self, client): | ||
| """Initialize the thermostat.""" | ||
| self._client = client | ||
| self._fan_list = VALID_FAN_STATES |
There was a problem hiding this comment.
These variables are never modified, so you actually don't need them as members, do you? Just make the methods return VALID_FAN_STATES / VALID_THERMOSTAT_MODES.
There was a problem hiding this comment.
Heh- yeah you're right :). I'll get rid of the _fan_list and _operation_list and adjust the methods.
|
|
||
| def update(self): | ||
| """Update the data from the thermostat.""" | ||
| _LOGGER.info("Refreshing data from your Venstar Thermostat.") |
There was a problem hiding this comment.
HA will automatically log whenever the state of your device changes. I'd recommend to remove this logging to reduce the logspam.
There was a problem hiding this comment.
okay- missed that one. Will remove.
tinloaf
left a comment
There was a problem hiding this comment.
Still have some minor comments, but looks good to me!
| elif self._client.mode == self._client.MODE_AUTO: | ||
| return STATE_AUTO | ||
| else: | ||
| return STATE_IDLE |
There was a problem hiding this comment.
I'm not really sure what STATE_IDLE should mean for an operation mode. I guess STATE_OFF would be better here? Just so I understand this correctly: If the device is in this state, it won't start automatically because some temperature was over/undershot, right? So, basically, it's switched off?
There was a problem hiding this comment.
It's a little confusing because the thermostat is still "on". It's screen is on, it's still monitoring/reporting temperature/humidity, still responding to API calls, etc.
But your assumption is correct there- it will not turn on the air conditioner, nor the furnace to attempt to keep a certain temperature.
It looks like in the honeywell component they're referring to this state as "idle" (see line 286 from honeywel.py). Looks like nuheat is also.
There was a problem hiding this comment.
Okay… we should probably clean that up at some point, but for now this is probably fine. :)
There was a problem hiding this comment.
Oh- no problem if you'd rather use the "off" state to represent this. I'll go ahead and do that.
* upstream/master: (465 commits) Update pyhomematic to 0.1.38 (home-assistant#11936) Implement Alexa temperature sensors (home-assistant#11930) Fixed rfxtrx binary_sensor KeyError on missing optional device_class (home-assistant#11925) Allow setting climate devices to AUTO mode via Google Assistant (home-assistant#11923) fixes home-assistant#11848 (home-assistant#11915) Add "write" service to system_log (home-assistant#11901) Update frontend to 20180126.0 Version 0.62 Allow separate command and state OIDs and payloads in SNMP switch (home-assistant#11075) Add ERC20 tokens to etherscan.io sensor (home-assistant#11916) Report scripts and groups as scenes to Alexa (home-assistant#11900) Minor fix to configuration validation and related log line. (home-assistant#11898) Multi-Room Support for Greenwave Reality (home-assistant#11364) Added Xeoma camera platform (home-assistant#11619) Improve foscam library exception support (home-assistant#11701) Iota wallet (home-assistant#11398) New venstar climate component (home-assistant#11639) Update python-wink version and multiple wink fixes/updates. (home-assistant#11833) Use API to discover Hue if no bridges specified (home-assistant#11909) Clarify emulated hue warning (home-assistant#11910) ...
Description:
New climate platform for venstar wifi enabled thermostats.
Related issue (if applicable): fixes # None
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#4412
Example entry for
configuration.yaml(if applicable):Checklist:
If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
toxrun successfully. Your PR cannot be merged unless tests passREQUIREMENTSvariable (example).requirements_all.txtby runningscript/gen_requirements_all.py..coveragerc.If the code does not interact with devices:
toxrun successfully. Your PR cannot be merged unless tests pass