Skip to content

Commit

Permalink
[TASK] add notify
Browse files Browse the repository at this point in the history
  • Loading branch information
KartoffelToby committed Nov 8, 2024
1 parent afe3110 commit 1641f4a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
19 changes: 19 additions & 0 deletions custom_components/better_thermostat/events/temperature.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from custom_components.better_thermostat.utils.const import CONF_HOMATICIP
from ..utils.helpers import convert_to_float
from datetime import datetime
from homeassistant.helpers import issue_registry as ir

from homeassistant.const import STATE_UNAVAILABLE, STATE_UNKNOWN
from homeassistant.core import callback
Expand Down Expand Up @@ -45,6 +46,24 @@ async def trigger_temperature_change(self, event):
except KeyError:
pass

if _incoming_temperature is None or _incoming_temperature < -50:
# raise a ha repair notication
_LOGGER.error(
"better_thermostat %s: external_temperature is not a valid number: %s",
self.device_name,
new_state.state,
)
ir.async_create_issue(
hass=self.hass,
issue_id=f"missing_entity_{self.device_name}",
issue_title=f"better_thermostat {self.device_name} has invalid external_temperature value",
issue_severity="error",
issue_description=f"better_thermostat {self.device_name} has invalid external_temperature: {new_state.state}",
issue_category="config",
issue_suggested_action="Please check the external_temperature sensor",
)
return

if (
_incoming_temperature != self.cur_temp
and (datetime.now() - self.last_external_sensor_change).total_seconds()
Expand Down
12 changes: 12 additions & 0 deletions custom_components/better_thermostat/events/window.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import asyncio
import logging

from custom_components.better_thermostat import DOMAIN
from homeassistant.core import callback
from homeassistant.const import STATE_OFF
from homeassistant.helpers import issue_registry as ir

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -49,6 +51,16 @@ async def trigger_window_change(self, event) -> None:
_LOGGER.error(
f"better_thermostat {self.device_name}: New window sensor state '{new_state}' not recognized"
)
ir.async_create_issue(
hass=self.hass,
domain=DOMAIN,
issue_id=f"missing_entity_{self.device_name}",
issue_title=f"better_thermostat {self.device_name} has invalid window sensor state",
issue_severity="error",
issue_description=f"better_thermostat {self.device_name} has invalid window sensor state: {new_state}",
issue_category="config",
issue_suggested_action="Please check the window sensor",
)
return

# make sure to skip events which do not change the saved window state:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/better_thermostat/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
"iot_class": "local_push",
"issue_tracker": "https://github.com/KartoffelToby/better_thermostat/issues",
"requirements": [],
"version": "1.6.2-dev"
"version": "1.7.0-beta1"
}

0 comments on commit 1641f4a

Please sign in to comment.