Skip to content

Commit

Permalink
Merge branch 'master' into fix/open-close_window
Browse files Browse the repository at this point in the history
  • Loading branch information
KartoffelToby authored Jan 3, 2025
2 parents 316a1da + 1f26dd2 commit 3189dd9
Show file tree
Hide file tree
Showing 42 changed files with 1,004 additions and 582 deletions.
60 changes: 47 additions & 13 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,10 @@ labels: new bug
assignees: kartoffeltoby
---

### Prerequisites

* [ ] Model name of your Devices
* [ ] Output from Home Assistant Developer Tools state e.g.
* [ ] Output from Home Assistant Device Diagnostic from BT

```json
{
YOUR DEVICE DIAGNOSTICS JSON OUTPUT HERE
}
```
<!--
Please take care to fill the data as complete as possible.
The more information you provide, the higher the chances are that we can reporoduce and fix the issue for you!
-->

### Description

Expand All @@ -35,9 +28,50 @@ assignees: kartoffeltoby

<!-- What happens -->

### Versions
### Versions and HW

<!-- Provide both, HA (Home Assistant) and BT (Better Thermostat) version -->
Home Assistant:
Better Thermostat:
<!-- Thermostat valve model(s) -->
TRV(s):

### Debug data

**diagnostic data**
<!--
IMPORTANT:
Download and paste the diagnostic data from your Better Thermostat Entity(s) below.
https://www.home-assistant.io/docs/configuration/troubleshooting/#download-diagnostics
-->

```json
{
YOUR DEVICE DIAGNOSTICS JSON OUTPUT HERE
}
```

**debug log**
<!--
Depending on how complicated you issue is, it might be necessary to enable debug logging for BT,
reproduce the issue, and then upload this logfile here.
https://www.home-assistant.io/docs/configuration/troubleshooting/#enabling-debug-logging
-->

<!--
Alternatively your Home Assistant system log might be needed - Download here (top right corner):
https://my.home-assistant.io/redirect/logs
-> This might contain sensitive data though, so it's highly adviced *NOT* to share this file publicly.
-->

<!-- Provide both, HA and BT version -->
**graphs**
<!--
For issues in regards to the calibration / control routines, it is very helpful to also
provide statistics graph screenshots from HA for the following entities (from the time you had issues):
- BT climate entity
- TRV climate entities controlled by BT
- (optional) Valve opening states
-->

### Additional Information

Expand Down
8 changes: 4 additions & 4 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## Related issue (check one):

- [ ] fixes #<issue number goes here>
- [ ] there is no related issue ticket
- [ ] There is no related issue ticket

## Checklist (check one):

Expand All @@ -14,17 +14,17 @@

## Test-Hardware list (for code changes)

<!-- Please specify your hardware/software which was used to test the code locally: -->
<!-- Please specify the hardware/software which was used to test the code locally: -->

HA Version:
Zigbee2MQTT Version:
TRV Hardware:

## New device mappings

<!-- If there was a new device mapping added, please make sure to fill in this checklist: -->
<!-- If a new device mapping has been added, please make sure to fill in this checklist: -->

- [ ] I avoided any changes to other device mappings
- [ ] There are no changes in `climate.py`

<!-- If you did change the `climate.py` please create a dedicated PR for this. -->
<!-- If you changed the `climate.py` please create a dedicated PR for this. -->
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ document in a pull request.

#### Nice to know

- Debuging is possible with the VSCode Debuger. Just run the HomeAssistant in Debugger and open browser on http://localhost:9123 (No task run needed)
- Debugging is possible with the VSCode Debugger. Just run the HomeAssistant in Debugger and open your browser to http://localhost:9123 (No task run needed)
- Update your local in devcontainer configuration.yaml to the current version of the repository to get the latest changes. -> Run "Sync configuration.yaml (Override local)" in Task Runner
- Test BT in a specific HA version -> Run "Install a specific version of Home Assistant" in Task Runner and the the version you want to test in the terminal promt.
- Test BT with the latest HA version -> Run "pgrade Home Assistant to latest dev" in Task Runner
- Test BT in a specific HA version -> Run "Install a specific version of Home Assistant" in Task Runner and the version you want to test in the terminal prompt.
- Test BT with the latest HA version -> Run "upgrade Home Assistant to latest dev" in Task Runner

## How Can I Contribute?

## New Adapter

If you want to add a new adapter, please create a new python file with the name of the adapter in the adapters folder. The file should contain all functions find in the generic.py. The if you adapter needs a special handling for one of the base functions, override it, if you can use generic functions, use them like:
If you want to add a new adapter, please create a new Python file with the name of the adapter in the adapters folder. The file should contain all functions found in the generic.py. If your adapter needs special handling for one of the base functions, override it, if you can use generic functions, use them like:

```python
async def set_temperature(self, entity_id, temperature):
Expand All @@ -55,4 +55,4 @@ https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_numpy.html

## Setup

Install the pip install pre-commit used for pre-commit hooks.
Install the pip install pre-commit used for pre-commit hooks.
15 changes: 10 additions & 5 deletions custom_components/better_thermostat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@
config_entry_update_listener_lock = Lock()


async def async_setup(hass: HomeAssistant, config: ConfigType):
"""Set up this integration using YAML is not supported."""
hass.data[DOMAIN] = {}
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up this integration using YAML."""
if DOMAIN in config:
hass.data.setdefault(DOMAIN, {})
return True


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
hass.data[DOMAIN] = {}
"""Set up entry."""
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.entry_id] = {}
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
entry.async_on_unload(entry.add_update_listener(config_entry_update_listener))
return True
Expand All @@ -44,9 +47,11 @@ async def config_entry_update_listener(hass: HomeAssistant, entry: ConfigEntry)
await hass.config_entries.async_reload(entry.entry_id)


async def async_unload_entry(hass, entry):
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
if unload_ok:
hass.data[DOMAIN].pop(entry.entry_id)
return unload_ok


Expand Down
12 changes: 5 additions & 7 deletions custom_components/better_thermostat/adapters/delegate.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,28 @@
async def load_adapter(self, integration, entity_id, get_name=False):
"""Load adapter."""
if get_name:
self.name = "-"
self.device_name = "-"

if integration == "generic_thermostat":
integration = "generic"

try:
self.adapter = await async_import_module(
self.hass,
"custom_components.better_thermostat.adapters." + integration,
self.hass, "custom_components.better_thermostat.adapters." + integration
)
_LOGGER.debug(
"better_thermostat %s: uses adapter %s for trv %s",
self.name,
self.device_name,
integration,
entity_id,
)
except Exception:
self.adapter = await async_import_module(
self.hass,
"custom_components.better_thermostat.adapters.generic",
self.hass, "custom_components.better_thermostat.adapters.generic"
)
_LOGGER.info(
"better_thermostat %s: integration: %s isn't native supported, feel free to open an issue, fallback adapter %s",
self.name,
self.device_name,
integration,
"generic",
)
Expand Down
6 changes: 3 additions & 3 deletions custom_components/better_thermostat/adapters/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async def init(self, entity_id):
)
_LOGGER.debug(
"better_thermostat %s: uses local calibration entity %s",
self.name,
self.device_name,
self.real_trvs[entity_id]["local_temperature_calibration_entity"],
)
# Wait for the entity to be available
Expand All @@ -39,7 +39,7 @@ async def init(self, entity_id):
).state in (STATE_UNAVAILABLE, STATE_UNKNOWN, None):
_LOGGER.info(
"better_thermostat %s: waiting for TRV/climate entity with id '%s' to become fully available...",
self.name,
self.device_name,
self.real_trvs[entity_id]["local_temperature_calibration_entity"],
)
await asyncio.sleep(5)
Expand Down Expand Up @@ -119,7 +119,7 @@ async def set_temperature(self, entity_id, temperature):

async def set_hvac_mode(self, entity_id, hvac_mode):
"""Set new target hvac mode."""
_LOGGER.debug("better_thermostat %s: set_hvac_mode %s", self.name, hvac_mode)
_LOGGER.debug("better_thermostat %s: set_hvac_mode %s", self.device_name, hvac_mode)
try:
await self.hass.services.async_call(
"climate",
Expand Down
6 changes: 3 additions & 3 deletions custom_components/better_thermostat/adapters/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async def init(self, entity_id):
)
_LOGGER.debug(
"better_thermostat %s: uses local calibration entity %s",
self.name,
self.device_name,
self.real_trvs[entity_id]["local_temperature_calibration_entity"],
)
# Wait for the entity to be available
Expand All @@ -47,7 +47,7 @@ async def init(self, entity_id):
).state in (STATE_UNAVAILABLE, STATE_UNKNOWN, None):
_LOGGER.info(
"better_thermostat %s: waiting for TRV/climate entity with id '%s' to become fully available...",
self.name,
self.device_name,
self.real_trvs[entity_id]["local_temperature_calibration_entity"],
)
await asyncio.sleep(5)
Expand Down Expand Up @@ -159,7 +159,7 @@ async def set_offset(self, entity_id, offset):
async def set_valve(self, entity_id, valve):
"""Set new target valve."""
_LOGGER.debug(
f"better_thermostat {self.name}: TO TRV {entity_id} set_valve: {valve}"
f"better_thermostat {self.device_name}: TO TRV {entity_id} set_valve: {valve}"
)
await self.hass.services.async_call(
"number",
Expand Down
Loading

0 comments on commit 3189dd9

Please sign in to comment.