1 """Support for the PRT Heatmiser thermostats using the V3 protocol."""
3 from __future__
import annotations
8 from heatmiserv3
import connection, heatmiser
9 import voluptuous
as vol
12 PLATFORM_SCHEMA
as CLIMATE_PLATFORM_SCHEMA,
30 _LOGGER = logging.getLogger(__name__)
32 CONF_THERMOSTATS =
"tstats"
34 TSTATS_SCHEMA = vol.Schema(
37 [{vol.Required(CONF_ID): cv.positive_int, vol.Required(CONF_NAME): cv.string}],
41 PLATFORM_SCHEMA = CLIMATE_PLATFORM_SCHEMA.extend(
43 vol.Required(CONF_HOST): cv.string,
44 vol.Required(CONF_PORT): cv.string,
45 vol.Optional(CONF_THERMOSTATS, default=[]): TSTATS_SCHEMA,
53 add_entities: AddEntitiesCallback,
54 discovery_info: DiscoveryInfoType |
None =
None,
56 """Set up the heatmiser thermostat."""
58 heatmiser_v3_thermostat = heatmiser.HeatmiserThermostat
60 host = config[CONF_HOST]
61 port = config[CONF_PORT]
63 thermostats = config[CONF_THERMOSTATS]
65 uh1_hub = connection.HeatmiserUH1(host, port)
70 for thermostat
in thermostats
77 """Representation of a HeatmiserV3 thermostat."""
79 _attr_hvac_modes = [HVACMode.HEAT, HVACMode.OFF]
80 _attr_supported_features = (
81 ClimateEntityFeature.TARGET_TEMPERATURE
82 | ClimateEntityFeature.TURN_OFF
83 | ClimateEntityFeature.TURN_ON
85 _enable_turn_on_off_backwards_compatibility =
False
88 """Initialize the thermostat."""
91 self.
_name_name = device[CONF_NAME]
100 """Return the name of the thermostat, if any."""
101 return self.
_name_name
105 """Return the current temperature."""
110 """Return the temperature we try to reach."""
114 """Set new target temperature."""
115 if (temperature := kwargs.get(ATTR_TEMPERATURE))
is None:
121 """Get the latest data."""
123 if not self.
uh1uh1.status:
124 _LOGGER.error(
"Failed to update device %s", self.
_name_name)
126 self.
dcbdcb = self.
thermtherm.read_dcb()
128 UnitOfTemperature.CELSIUS
129 if (self.
thermtherm.get_temperature_format() ==
"C")
130 else UnitOfTemperature.FAHRENHEIT
136 if (
int(self.
thermtherm.get_current_state()) == 0)
def current_temperature(self)
None set_temperature(self, **Any kwargs)
def target_temperature(self)
def __init__(self, therm, device, uh1)
None add_entities(AsusWrtRouter router, AddEntitiesCallback async_add_entities, set[str] tracked)
None setup_platform(HomeAssistant hass, ConfigType config, AddEntitiesCallback add_entities, DiscoveryInfoType|None discovery_info=None)