Skip to content

Commit

Permalink
Add humidity information
Browse files Browse the repository at this point in the history
  • Loading branch information
cyr-ius committed Dec 3, 2024
1 parent 42d50b7 commit 2c0d9e3
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 138 deletions.
97 changes: 45 additions & 52 deletions custom_components/heatzy/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

from __future__ import annotations

import logging
from collections.abc import Callable
from dataclasses import dataclass
import logging
from typing import Any, Final

from heatzypy.exception import HeatzyException
import voluptuous as vol

from heatzypy.exception import HeatzyException
from homeassistant.components.climate import (
ATTR_TARGET_TEMP_HIGH,
ATTR_TARGET_TEMP_LOW,
Expand All @@ -25,8 +24,9 @@
HVACMode,
)
from homeassistant.const import CONF_DELAY, UnitOfTemperature
from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv, entity_platform
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers import entity_platform
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import HeatzyConfigEntry, HeatzyDataUpdateCoordinator
Expand All @@ -42,6 +42,7 @@
CONF_DEROG_TIME,
CONF_ECO_TEMP,
CONF_HEATING_STATE,
CONF_HUMIDITY,
CONF_IS_ONLINE,
CONF_MODE,
CONF_ON_OFF,
Expand Down Expand Up @@ -223,7 +224,7 @@ class HeatzyClimateEntityDescription(ClimateEntityDescription):
temperature_low=CFT_TEMP_L,
eco_temperature_high=ECO_TEMP_H,
eco_temperature_low=ECO_TEMP_L,
target_temperature_step=1,
target_temperature_step=0.1,
),
HeatzyClimateEntityDescription(
key="bloom",
Expand Down Expand Up @@ -261,6 +262,7 @@ class HeatzyClimateEntityDescription(ClimateEntityDescription):
current_temperature=CONF_CUR_TEMP,
temperature_high=CONF_CFT_TEMP,
temperature_low=CONF_ECO_TEMP,
target_temperature_step=0.1,
),
HeatzyClimateEntityDescription(
key="pilotepro_v1",
Expand Down Expand Up @@ -301,7 +303,7 @@ class HeatzyClimateEntityDescription(ClimateEntityDescription):
current_temperature=CONF_CUR_TEMP,
temperature_high=CONF_CFT_TEMP,
temperature_low=CONF_ECO_TEMP,
target_temperature_step=1,
target_temperature_step=0.1,
),
)

Expand Down Expand Up @@ -351,21 +353,19 @@ def __init__(

@property
def hvac_action(self) -> HVACAction:
"""Return hvac action ie. heat, cool mode."""
mode = self._attrs.get(CONF_MODE)
return (
HVACAction.OFF
if mode == self.entity_description.stop
else HVACAction.HEATING
)
"""Return hvac action ie. heating, off mode."""
if self._attrs.get(CONF_TIMER_SWITCH) == 1:
return HVACMode.AUTO
if self._attrs.get(CONF_MODE) == self.entity_description.stop:
return HVACAction.OFF

return HVACAction.HEATING

@property
def hvac_mode(self) -> HVACMode:
"""Return hvac operation ie. heat, cool mode."""
"""Return hvac mode ie. heat, auto, off."""
if self._attrs.get(CONF_TIMER_SWITCH) == 1:
return HVACMode.AUTO

# If preset mode is NONE set HVAC Mode to OFF
if self._attrs.get(CONF_MODE) == self.entity_description.stop:
return HVACMode.OFF
# otherwise set HVAC Mode to HEAT
Expand Down Expand Up @@ -418,7 +418,7 @@ async def async_presence_detection(self) -> None:
"""Presence detection derog."""
raise NotImplementedError

# @callback
@callback
def _handle_coordinator_update(self) -> None:
"""Handle updated data from the coordinator."""
self._attrs = self.coordinator.data.get(self.unique_id, {}).get(CONF_ATTRS, {})
Expand Down Expand Up @@ -622,7 +622,7 @@ class HeatzyPiloteV3Thermostat(HeatzyPiloteV2Thermostat):
"""Pilote_Soc_C3, Elec_Pro_Ble, Sauter."""


class Glowv1Thermostat(HeatzyPiloteV2Thermostat):
class Glowv1Thermostat(HeatzyPiloteV3Thermostat):
"""Glow."""

@property
Expand All @@ -647,15 +647,26 @@ def target_temperature_low(self) -> float:
eco_tempL = self._attrs.get(self.entity_description.eco_temperature_low, 0)
return (eco_tempL + (eco_tempH * 256)) / 10

@property
def hvac_action(self) -> HVACAction:
"""Return hvac action ie. heating, off mode."""
if self._attrs.get(CONF_TIMER_SWITCH) == 1:
return HVACMode.AUTO
if self.hvac_mode == HVACMode.OFF:
return HVACAction.OFF
if self.target_temperature and (
self.current_temperature > self.target_temperature
):
return HVACAction.OFF
return HVACAction.HEATING

@property
def hvac_mode(self) -> HVACMode:
"""Return hvac operation ie. heat, cool mode."""
if self._attrs.get(CONF_TIMER_SWITCH) == 1:
return HVACMode.AUTO

if self._attrs.get(CONF_ON_OFF) == 0:
return HVACMode.OFF
# Otherwise set HVAC Mode to HEAT
return HVACMode.HEAT

@property
Expand All @@ -672,22 +683,6 @@ def target_temperature(self) -> float | None:
return FROST_TEMP
return None

@property
def hvac_action(self) -> HVACAction:
"""Return hvac action ie. heat, cool mode."""
if self._attrs.get(CONF_TIMER_SWITCH) == 1:
return HVACMode.AUTO
if self.hvac_mode == HVACMode.OFF:
return HVACAction.OFF

# If Target temp is higher than current temp then set HVAC Action to HEATING
if self.target_temperature and (
self.current_temperature < self.target_temperature
):
return HVACAction.HEATING
# Otherwise set to IDLE
return HVACAction.IDLE

@property
def preset_mode(self) -> str | None:
"""Return the current preset mode, e.g., home, away, temp."""
Expand Down Expand Up @@ -819,14 +814,11 @@ def hvac_action(self) -> HVACAction:
return HVACMode.AUTO
if self.hvac_mode == HVACMode.OFF:
return HVACAction.OFF

# If Target temp is higher than current temp then set HVAC Action to HEATING
if self.target_temperature and (
self.current_temperature < self.target_temperature
self.current_temperature > self.target_temperature
):
return HVACAction.HEATING
# Otherwise set to IDLE
return HVACAction.IDLE
return HVACAction.OFF
return HVACAction.HEATING

async def async_set_temperature(self, **kwargs: Any) -> None:
"""Set new target temperature."""
Expand All @@ -853,6 +845,11 @@ async def async_set_temperature(self, **kwargs: Any) -> None:
class HeatzyPiloteProV1(HeatzyPiloteV3Thermostat):
"""Heatzy Pilote Pro."""

@property
def current_humidity(self) -> float:
"""Return current humidity."""
return self._attrs.get(CONF_HUMIDITY)

@property
def current_temperature(self) -> float:
"""Return current temperature."""
Expand Down Expand Up @@ -883,22 +880,18 @@ def target_temperature(self) -> float | None:

@property
def hvac_action(self) -> HVACAction:
"""Return hvac action ie. heat, cool mode."""
"""Return hvac action ie. heating, off mode."""
if self._attrs.get(CONF_TIMER_SWITCH) == 1:
return HVACMode.AUTO
if self.hvac_mode == HVACMode.OFF:
return HVACAction.OFF

# if Target tem is reached
if self._attrs.get(CONF_HEATING_STATE) == 1:
return HVACAction.IDLE
# If Target temp is higher than current temp then set HVAC Action to HEATING
return HVACAction.OFF
if self.target_temperature and (
self.current_temperature < self.target_temperature
self.current_temperature > self.target_temperature
):
return HVACAction.HEATING
# Otherwise set to IDLE
return HVACAction.IDLE
return HVACAction.OFF
return HVACAction.HEATING

async def async_set_preset_mode(self, preset_mode: str) -> None:
"""Set new preset mode."""
Expand Down
2 changes: 1 addition & 1 deletion custom_components/heatzy/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
ECO_TEMP_H = "eco_tempH"
ECO_TEMP_L = "eco_tempL"
FROST_TEMP = 7
PLATFORMS = ["climate", "switch", "sensor", "number"]
PLATFORMS = ["climate", "switch", "number"]
PRESET_COMFORT_1 = "Comfort 1"
PRESET_COMFORT_2 = "Comfort 2"
PRESET_PRESENCE_DETECT = "Presence detection"
Expand Down
85 changes: 0 additions & 85 deletions custom_components/heatzy/sensor.py

This file was deleted.

0 comments on commit 2c0d9e3

Please sign in to comment.