Skip to content

Commit

Permalink
Add support for StatelessExteriorHeating device. (#244)
Browse files Browse the repository at this point in the history
* Add support for StatelessExteriorHeating device.

* Add support for StatelessExteriorHeating device.

* Changed unknown property to None. Added SUPPORT_PRESET_MODE.

* Added services to services.yaml, removed up and down services. #211

* Fix temperature unit. #211

* Fix types. #211

* limit service my to supported devices. #211

* Added some debug logs.

* Merge master into branch.

* fixed wrong import
#211

* Add last ha action as preset and hvac mode state.
#211

* Renamed service.
#211

* Revert "Add last ha action as preset and hvac mode state."

This reverts commit bdfb6f3
#211

* improved debug logging.
#211

* improved debug logging.
#211

* fix possible circular import. #211

* Removed service

* Changed preset to my only

* Removed commented lines.

* Cleaned up code.

* Cleaned up code.

* Removed unwanted logging message.

#211

* Switch mode and preset back to None.

#211

* cleanup code.

#211
  • Loading branch information
vlebourl authored Sep 4, 2020
1 parent a95fb73 commit 34eeb61
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
4 changes: 4 additions & 0 deletions custom_components/tahoma/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@
from .climate_devices.atlantic_electrical_heater import AtlanticElectricalHeater
from .climate_devices.dimmer_exterior_heating import DimmerExteriorHeating
from .climate_devices.somfy_thermostat import SomfyThermostat
from .climate_devices.stateless_exterior_heating import StatelessExteriorHeating
from .const import DOMAIN

TYPE = {
"AtlanticElectricalHeater": AtlanticElectricalHeater,
"SomfyThermostat": SomfyThermostat,
"DimmerExteriorHeating": DimmerExteriorHeating,
"StatelessExteriorHeating": StatelessExteriorHeating,
}

SERVICE_CLIMATE_MY_POSITION = "set_climate_my_position"


async def async_setup_entry(hass, entry, async_add_entities):
"""Set up the TaHoma climate from a config entry."""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
"""Support for Stateless Exterior Heating device."""
import logging
from typing import List, Optional

from homeassistant.components.climate import ClimateEntity
from homeassistant.components.climate.const import (
HVAC_MODE_HEAT,
HVAC_MODE_OFF,
SUPPORT_PRESET_MODE,
)
from homeassistant.const import TEMP_CELSIUS

from ..tahoma_device import TahomaDevice

_LOGGER = logging.getLogger(__name__)

COMMAND_MY = "my"
COMMAND_OFF = "off"
COMMAND_ON = "on"

PRESET_MY = "My"


class StatelessExteriorHeating(TahomaDevice, ClimateEntity):
"""Representation of TaHoma Stateless Exterior Heating device."""

@property
def temperature_unit(self) -> Optional[str]:
"""Return the unit of measurement used by the platform."""
return TEMP_CELSIUS # Not used but climate devices need a recognized temperature unit...

@property
def supported_features(self) -> int:
"""Return the list of supported features."""
return SUPPORT_PRESET_MODE

@property
def preset_mode(self) -> Optional[str]:
"""Return the current preset mode, e.g., home, away, temp."""
return None

@property
def preset_modes(self) -> Optional[List[str]]:
"""Return a list of available preset modes."""
return [PRESET_MY]

async def async_set_preset_mode(self, preset_mode: str) -> None:
"""Set new preset mode."""
if preset_mode in PRESET_MY:
await self.async_execute_command(COMMAND_MY)
else:
_LOGGER.error(
"Invalid preset mode %s for device %s", preset_mode, self.name
)

@property
def hvac_mode(self) -> Optional[str]:
"""Return hvac operation ie. heat, cool mode."""
return None

@property
def hvac_modes(self) -> List[str]:
"""Return the list of available hvac operation modes."""
return [HVAC_MODE_OFF, HVAC_MODE_HEAT]

async def async_set_hvac_mode(self, hvac_mode: str) -> None:
"""Set new target hvac mode."""
if hvac_mode == HVAC_MODE_HEAT:
await self.async_execute_command(COMMAND_ON)
else:
await self.async_execute_command(COMMAND_OFF)
1 change: 1 addition & 0 deletions custom_components/tahoma/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"SirenStatus": BINARY_SENSOR, # widgetName, uiClass is Siren (switch)
"SmokeSensor": BINARY_SENSOR,
"SomfyThermostat": CLIMATE, # widgetName, uiClass is HeatingSystem (not supported)
"StatelessExteriorHeating": CLIMATE, # widgetName, uiClass is ExteriorHeatingSystem.
"SunIntensitySensor": SENSOR,
"SunSensor": SENSOR,
"SwimmingPool": SWITCH,
Expand Down

0 comments on commit 34eeb61

Please sign in to comment.