Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Z-Wave setpoint incorrectly reports temperature out of range #124471

Closed
alex3305 opened this issue Aug 23, 2024 · 5 comments
Closed

Z-Wave setpoint incorrectly reports temperature out of range #124471

alex3305 opened this issue Aug 23, 2024 · 5 comments

Comments

@alex3305
Copy link
Contributor

The problem

When setting a target setpoint for my Z-Wave thermostats I get the error message that the temperature is out of range. Setting a temperature outside of the default range yields the error Provided temperature 5.0 is not valid. Accepted range is 7 to 35. and the temperature not being set.

However I have adjusted the min_temp and max_temp's for my devices because they don't reflect reality:

homeassistant:
  customize:
    climate.office:
      min_temp: 4
      max_temp: 28

image
image

This has worked for me since at least October 2019 because that's when I created the file according to version control 😛.

What version of Home Assistant Core has the issue?

core-2024.8.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Z-Wave

Link to integration documentation on our website

https://www.home-assistant.io/integrations/zwave_js/

Diagnostics information

No response

Example YAML snippet

action: climate.set_temperature
data:
  temperature: 5
target:
  entity_id: climate.office

Anything in the logs that might be useful for us?

2024-08-23 10:39:17.450 ERROR (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Error executing script. Error for call_service at pos 1: Provided temperature 5.0 is not valid. Accepted range is 7 to 35
2024-08-23 10:39:17.450 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [22702579087488] Provided temperature 5.0 is not valid. Accepted range is 7 to 35

Additional information

No response

@home-assistant
Copy link

Hey there @home-assistant/z-wave, mind taking a look at this issue as it has been labeled with an integration (zwave_js) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of zwave_js can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign zwave_js Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


zwave_js documentation
zwave_js source
(message by IssueLinks)

@alex3305 alex3305 changed the title Z-Wave Incorrectly reports temperature out of range Z-Wave setpoint incorrectly reports temperature out of range Aug 23, 2024
@alex3305
Copy link
Contributor Author

Probably related to #118649.

It looks to me that the Z-Wave integration doesn't pick up the customized attributes. But I'm at a loss why that is. Everything still works perfectly with the Generic Thermostat integration. Also reporting the correct range when setting an 'invalid' temperature.

@kpine
Copy link
Contributor

kpine commented Aug 23, 2024

Duplicate of #123612

It works with the Generic Thermostat because the values are set in the YAML configuration, or if unset defers back to the climate integration base class. Z-Wave JS hard-codes it to a default value when the device doesn't report it.

@kpine
Copy link
Contributor

kpine commented Aug 24, 2024

This seems like a pretty simple fix, although I haven't tested it myself. The Z-Wave integration hard-codes the min/max temps when a device doesn't support it. Now you should just be able to defer to the super class, which will lookup the customized attributes.

I don't have time at the moment to make a PR (add tests, etc.), but here's what I'd try with the least amount of changes needed:

diff --git a/homeassistant/components/zwave_js/climate.py b/homeassistant/components/zwave_js/climate.py
index 14a3fe579c..8755dc4dcb 100644
--- a/homeassistant/components/zwave_js/climate.py
+++ b/homeassistant/components/zwave_js/climate.py
@@ -24,8 +24,6 @@ from homeassistant.components.climate import (
     ATTR_HVAC_MODE,
     ATTR_TARGET_TEMP_HIGH,
     ATTR_TARGET_TEMP_LOW,
-    DEFAULT_MAX_TEMP,
-    DEFAULT_MIN_TEMP,
     DOMAIN as CLIMATE_DOMAIN,
     PRESET_NONE,
     ClimateEntity,
@@ -421,34 +419,32 @@ class ZWaveClimate(ZWaveBaseEntity, ClimateEntity):
     @property
     def min_temp(self) -> float:
         """Return the minimum temperature."""
-        min_temp = DEFAULT_MIN_TEMP
-        base_unit: str = UnitOfTemperature.CELSIUS
         try:
             temp = self._setpoint_value_or_raise(self._current_mode_setpoint_enums[0])
             if temp.metadata.min:
-                min_temp = temp.metadata.min
-                base_unit = self.temperature_unit
+                return TemperatureConverter.convert(
+                    temp.metadata.min, self.temperature_unit, self.temperature_unit
+                )
         # In case of any error, we fallback to the default
         except (IndexError, ValueError, TypeError):
             pass
 
-        return TemperatureConverter.convert(min_temp, base_unit, self.temperature_unit)
+        return super().min_temp
 
     @property
     def max_temp(self) -> float:
         """Return the maximum temperature."""
-        max_temp = DEFAULT_MAX_TEMP
-        base_unit: str = UnitOfTemperature.CELSIUS
         try:
             temp = self._setpoint_value_or_raise(self._current_mode_setpoint_enums[0])
             if temp.metadata.max:
-                max_temp = temp.metadata.max
-                base_unit = self.temperature_unit
+                return TemperatureConverter.convert(
+                    temp.metadata.max, self.temperature_unit, self.temperature_unit
+                )
         # In case of any error, we fallback to the default
         except (IndexError, ValueError, TypeError):
             pass
 
-        return TemperatureConverter.convert(max_temp, base_unit, self.temperature_unit)
+        return super().max_temp
 
     async def async_set_fan_mode(self, fan_mode: str) -> None:
         """Set new target fan mode."""

@alex3305
Copy link
Contributor Author

Thanks for the input @kpine, great stuff! Not sure how I missed the dupe tho 🤦.

Anyway. Let's continue in #123612

@alex3305 alex3305 closed this as not planned Won't fix, can't repro, duplicate, stale Aug 24, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Sep 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants