mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 22:07:10 +00:00
set name of device through hass config
This commit is contained in:
parent
4ac9e9fc4c
commit
e5d68d8a1e
@ -27,6 +27,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
return
|
return
|
||||||
|
|
||||||
host = config.get(CONF_HOST)
|
host = config.get(CONF_HOST)
|
||||||
|
name = config.get(CONF_NAME)
|
||||||
if host is None:
|
if host is None:
|
||||||
logger.error("host not defined in config.")
|
logger.error("host not defined in config.")
|
||||||
return
|
return
|
||||||
@ -38,7 +39,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
"Unable to connect to Radio Thermostat")
|
"Unable to connect to Radio Thermostat")
|
||||||
return
|
return
|
||||||
|
|
||||||
add_devices([RadioThermostat(tstat)])
|
add_devices([RadioThermostat(tstat, name)])
|
||||||
|
|
||||||
|
|
||||||
class RadioThermostat(ThermostatDevice):
|
class RadioThermostat(ThermostatDevice):
|
||||||
@ -46,13 +47,13 @@ class RadioThermostat(ThermostatDevice):
|
|||||||
|
|
||||||
def __init__(self, device, name=None):
|
def __init__(self, device, name=None):
|
||||||
self.device = device
|
self.device = device
|
||||||
self._name = name
|
if name:
|
||||||
|
self.set_name(name)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
""" Returns the name of the Radio Thermostat. """
|
""" Returns the name of the Radio Thermostat. """
|
||||||
return 'radiothermostat'
|
return self.device.name['raw']
|
||||||
#return self.device.name
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
@ -98,12 +99,16 @@ class RadioThermostat(ThermostatDevice):
|
|||||||
return round(temp, 1)
|
return round(temp, 1)
|
||||||
|
|
||||||
|
|
||||||
def set_temperate(self, temperature):
|
def set_temperature(self, temperature):
|
||||||
""" Set new target temperature """
|
""" Set new target temperature """
|
||||||
if self.operation == STATE_COOL:
|
if self.operation == STATE_COOL:
|
||||||
self.device.t_cool = temperature
|
self.device.t_cool = temperature
|
||||||
elif self.operation == STATE_HEAT:
|
elif self.operation == STATE_HEAT:
|
||||||
self.device.t_heat
|
self.device.t_heat
|
||||||
|
|
||||||
|
def set_name(self, name):
|
||||||
|
""" Set thermostat name """
|
||||||
|
self.device.name = name
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user