Repository: home-assistant/core
Pull request: Fix Livisi climate min/max temperature
<!--
  You are amazing! Thanks for contributing to our project!
  Please, DO NOT DELETE ANY TEXT from this template! (unless instructed).
-->
## Breaking change
<!--
  If your PR contains a breaking change for existing users, it is important
  to tell them what breaks, how to make it work again and why we did this.
  This piece of text is published with the release notes, so it helps if you
  write it towards our users, not us.
  Note: Remove this section if this PR is NOT a breaking change.
-->


## Proposed change
<!--
  Describe the big picture of your changes here to communicate to the
  maintainers why we should accept this pull request. If it fixes a bug
  or resolves a feature request, be sure to link to that issue in the
  additional information section.
-->

The min and max temperature is currently set completely wrong, via _atttr_target_temperature_(high|low), which defines the target temperature range for thermostats that support it (this one doesn't). Correct is _attr_temp_(min|max) which defines the min max temperature. Additionally, this temp should not be fixed to 6/30 but can be loaded from the config.

## Type of change
<!--
  What type of change does your PR introduce to Home Assistant?
  NOTE: Please, check only 1! box!
  If your PR requires multiple boxes to be checked, you'll most likely need to
  split it into multiple PRs. This makes things easier and faster to code review.
-->

- [ ] Dependency upgrade
- [x] Bugfix (non-breaking change which fixes an issue)
- [ ] New integration (thank you!)
- [ ] New feature (which adds functionality to an existing integration)
- [ ] Deprecation (breaking change to happen in the future)
- [ ] Breaking change (fix/feature causing existing functionality to break)
- [ ] Code quality improvements to existing code or addition of tests

## Additional information
<!--
  Details are important, and help maintainers processing your PR.
  Please be sure to fill out additional details, if applicable.
-->

- This PR fixes or closes issue: fixes #90630
- This PR is related to issue: 
- Link to documentation pull request: 

## Checklist
<!--
  Put an `x` in the boxes that apply. You can also fill these out after
  creating the PR. If you're unsure about any of them, don't hesitate to ask.
  We're here to help! This is simply a reminder of what we are going to look
  for before merging your code.
-->

- [x] The code change is tested and works locally.
- [x] Local tests pass. **Your PR cannot be merged unless tests pass**
- [x] There is no commented out code in this PR.
- [x] I have followed the [development checklist][dev-checklist]
- [x] I have followed the [perfect PR recommendations][perfect-pr]
- [x] The code has been formatted using Black (`black --fast homeassistant tests`)
- [ ] Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

- [ ] Documentation added/updated for [www.home-assistant.io][docs-repository]

If the code communicates with devices, web services, or third-party tools:

- [ ] The [manifest file][manifest-docs] has all fields filled out correctly.  
      Updated and included derived files by running: `python3 -m script.hassfest`.
- [ ] New or updated dependencies have been added to `requirements_all.txt`.  
      Updated by running `python3 -m script.gen_requirements_all`.
- [ ] For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
- [ ] Untested files have been added to `.coveragerc`.

<!--
  This project is very active and we have a high turnover of pull requests.

  Unfortunately, the number of incoming pull requests is higher than what our
  reviewers can review and merge so there is a long backlog of pull requests
  waiting for review. You can help here!
  
  By reviewing another pull request, you will help raise the code quality of
  that pull request and the final review will be faster. This way the general
  pace of pull request reviews will go up and your wait time will go down.
  
  When picking a pull request to review, try to choose one that hasn't yet
  been reviewed.

  Thanks for helping out!
-->

To help with the load of incoming pull requests:

- [ ] I have reviewed two other [open pull requests][prs] in this repository.

[prs]: https://github.com/home-assistant/core/pulls?q=is%3Aopen+is%3Apr+-author%3A%40me+-draft%3Atrue+-label%3Awaiting-for-upstream+sort%3Acreated-desc+review%3Anone+-status%3Afailure

<!--
  Thank you for contributing <3

  Below, some useful links you could explore:
-->
[dev-checklist]: https://developers.home-assistant.io/docs/en/development_checklist.html
[manifest-docs]: https://developers.home-assistant.io/docs/en/creating_integration_manifest.html
[quality-scale]: https://developers.home-assistant.io/docs/en/next/integration_quality_scale_index.html
[docs-repository]: https://github.com/home-assistant/home-assistant.io
[perfect-pr]: https://developers.home-assistant.io/docs/review-process/#creating-the-perfect-pr


Problem statement:
Issue with livisi integration, climate devices, turn off and temp
### The problem

- The climate device support only the mode "heat" You canot turn off the climate device. The device itself has the ability to turn them of.
- The maximum temperature is: 30 
- The minimum temperature is: 6

### What version of Home Assistant Core has the issue?

2023.4.0b3

### What was the last working version of Home Assistant Core?

2023.3

### What type of installation are you running?

Home Assistant Core

### Integration causing the issue

livisi

### Link to integration documentation on our website

_No response_

### Diagnostics information

_No response_

### Example YAML snippet

```yaml
hvac_modes:
  - heat
min_temp: 7
max_temp: 35
current_temperature: 16.3
temperature: 7
current_humidity: 61.5
friendly_name: xxxxxxxxx
supported_features: 1
```


### Anything in the logs that might be useful for us?

_No response_

### Additional information

_No response_

Hints from issue discussion:
Hey there @stefaniacoblivisi, @planbnet, mind taking a look at this issue as it has been labeled with an integration (`livisi`) you are listed as a [code owner](https://github.com/home-assistant/core/blob/dev/CODEOWNERS#L663) for? Thanks!

<details>
<summary>Code owner commands</summary>


Code owners of `livisi` 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 livisi` Removes the current integration label and assignees on the issue, add the integration domain after the command.

</details>


<sub><sup>(message by CodeOwnersMention)</sup></sub>

---

[livisi documentation](https://www.home-assistant.io/integrations/livisi)
[livisi source](https://github.com/home-assistant/core/tree/dev/homeassistant/components/livisi)
<sub><sup>(message by IssueLinks)</sup></sub>
You are right, the min and max temperature can (and should) be read from the controller, but afaik there's no possibility to turn off a climate device. How would you do so in the Livisi web ui?
If I turn the temperature at the wall thermostat or heating thermostat completely down, "Off" is displayed and only the frost protection is activated in the background.
In the Livisi integration, the room climate is controlled, not a single thermostat (though even those don't seem to have an "off" property). I  guess it simply displays "off" if the temp equals the frost protection temp (which is 6°C by default)
Hi, we discussed the current tvr behaviour in more detail in the german livisi forum [#165](https://community.livisi.de/forum/thread/4836-wann-kommt-den-nun-die-heizungssteuerung/?postID=41191#post41191)

To me the discussed problems could be fixed by
a. implementing the HVACMode.OFF (that could be internally setting the set-temperature to min-temperature
b. implementing HVACAction.OFF, HVACAction.HEATING and HVACAction.IDLE to display the correct behavior in the lovelace card and diagrams. Also this could be achieved by internally comparing temperature to current_temperature and setting the HVACAction accordingly. 

for more detail https://developers.home-assistant.io/docs/core/entity/climate/

If i use a custom climate component i can achieve the desired behavior vs the current implemented as you can see in the screenshots.
<img width="533" alt="Bildschirmfoto 2023-03-30 um 20 28 17" src="https://user-images.githubusercontent.com/3471813/229465508-45044ce4-5d0e-4432-8024-e83cb1dc3f51.png">
<img width="543" alt="Bildschirmfoto 2023-03-30 um 20 28 04" src="https://user-images.githubusercontent.com/3471813/229465517-a2eabaf9-d083-4bca-89fd-6ba524bbd1a4.png">

Commit message: Correctly set livisi climate min/max temp

Patch to review:
diff --git a/homeassistant/components/livisi/climate.py b/homeassistant/components/livisi/climate.py
index 3a0a219d94340e..214cd54a93a500 100644
--- a/homeassistant/components/livisi/climate.py
+++ b/homeassistant/components/livisi/climate.py
@@ -3,9 +3,12 @@
 
 from typing import Any
 
+from aiolivisi.const import CAPABILITY_CONFIG
+
 from homeassistant.components.climate import (
     ClimateEntity,
     ClimateEntityFeature,
+    HVACAction,
     HVACMode,
 )
 from homeassistant.config_entries import ConfigEntry
@@ -65,8 +68,6 @@ class LivisiClimate(LivisiEntity, ClimateEntity):
     _attr_hvac_mode = HVACMode.HEAT
     _attr_temperature_unit = UnitOfTemperature.CELSIUS
     _attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
-    _attr_target_temperature_high = MAX_TEMPERATURE
-    _attr_target_temperature_low = MIN_TEMPERATURE
 
     def __init__(
         self,
@@ -83,6 +84,10 @@ def __init__(
         self._temperature_capability = self.capabilities["RoomTemperature"]
         self._humidity_capability = self.capabilities["RoomHumidity"]
 
+        config = device.get(CAPABILITY_CONFIG, {}).get("RoomSetpoint", {})
+        self._attr_max_temp = config.get("maxTemperature", MAX_TEMPERATURE)
+        self._attr_min_temp = config.get("minTemperature", MIN_TEMPERATURE)
+
     async def async_set_temperature(self, **kwargs: Any) -> None:
         """Set new target temperature."""
         response = await self.aio_livisi.async_vrcc_set_temperature(


Code review comments:
diff_hunk: @@ -3,9 +3,12 @@
 
 from typing import Any
 
+from aiolivisi.const import CAPABILITY_CONFIG
+
 from homeassistant.components.climate import (
     ClimateEntity,
     ClimateEntityFeature,
+    HVACAction,
path: homeassistant/components/livisi/climate.py
text: @user1:
```suggestion
```