Skip to content

Commit

Permalink
Fix preset_modes type annotation (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewturner authored Mar 1, 2024
1 parent c6ec2cd commit 5fb9041
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions salusfy/thermostat_entity.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
import logging

from .web_client import (
MAX_TEMP,
MIN_TEMP
)

from homeassistant.components.climate.const import (
HVACAction,
HVACMode,
Expand All @@ -17,6 +10,11 @@
UnitOfTemperature,
)

from .web_client import (
MAX_TEMP,
MIN_TEMP
)

try:
from homeassistant.components.climate import ClimateEntity
except ImportError:
Expand All @@ -31,9 +29,10 @@ def __init__(self, name, client):
self._name = name
self._client = client

self._state = None

self._enable_turn_on_off_backwards_compatibility = False


@property
def supported_features(self) -> ClimateEntityFeature:
"""Return the list of supported features."""
Expand All @@ -43,7 +42,7 @@ def supported_features(self) -> ClimateEntityFeature:
def name(self) -> str:
"""Return the name of the thermostat."""
return self._name

@property
def unique_id(self) -> str:
"""Return the unique ID for this thermostat."""
Expand Down Expand Up @@ -86,7 +85,7 @@ def hvac_mode(self) -> HVACMode:

return self._state.mode


@property
def hvac_modes(self) -> list[HVACMode]:
"""HVAC modes."""
Expand All @@ -97,7 +96,7 @@ def hvac_modes(self) -> list[HVACMode]:
def hvac_action(self) -> HVACAction:
"""Return the current running hvac operation."""
return self._state.action


@property
def preset_mode(self) -> str:
Expand All @@ -106,32 +105,32 @@ def preset_mode(self) -> str:


@property
def preset_modes(self):
def preset_modes(self) -> list[str]:
"""Return a list of available preset modes."""
return ClimateEntityFeature.PRESET_MODE
return [PRESET_NONE]


async def async_set_temperature(self, **kwargs) -> None:
"""Set new target temperature."""

temperature = kwargs.get(ATTR_TEMPERATURE)

if temperature is None:
return

await self._client.set_temperature(temperature)

self._state.target_temperature = temperature


async def async_set_hvac_mode(self, hvac_mode : HVACMode) -> None:
"""Set HVAC mode, via URL commands."""

await self._client.set_hvac_mode(hvac_mode)

self._state.mode = hvac_mode


async def async_turn_off(self) -> None:
await self.async_set_hvac_mode(HVACMode.OFF)

Expand All @@ -142,4 +141,4 @@ async def async_turn_on(self) -> None:

async def async_update(self) -> None:
"""Retrieve latest state data."""
self._state = await self._client.get_state()
self._state = await self._client.get_state()

0 comments on commit 5fb9041

Please sign in to comment.