mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Use voluptuous for eQ-3 thermostat (#3729)
* Migrate to voluptuous * Fix requirement and typo
This commit is contained in:
parent
a8cdf36d5c
commit
d4dc2707a1
@ -1,24 +1,38 @@
|
|||||||
"""
|
"""
|
||||||
Support for eq3 Bluetooth Smart thermostats.
|
Support for eQ-3 Bluetooth Smart thermostats.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
https://home-assistant.io/components/climate.eq3btsmart/
|
https://home-assistant.io/components/climate.eq3btsmart/
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.climate import ClimateDevice
|
import voluptuous as vol
|
||||||
from homeassistant.const import TEMP_CELSIUS, CONF_DEVICES, ATTR_TEMPERATURE
|
|
||||||
|
from homeassistant.components.climate import ClimateDevice, PLATFORM_SCHEMA
|
||||||
|
from homeassistant.const import (
|
||||||
|
CONF_MAC, TEMP_CELSIUS, CONF_DEVICES, ATTR_TEMPERATURE)
|
||||||
from homeassistant.util.temperature import convert
|
from homeassistant.util.temperature import convert
|
||||||
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
REQUIREMENTS = ['bluepy_devices==0.2.0']
|
REQUIREMENTS = ['bluepy_devices==0.2.0']
|
||||||
|
|
||||||
CONF_MAC = 'mac'
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
ATTR_MODE = 'mode'
|
||||||
|
ATTR_MODE_READABLE = 'mode_readable'
|
||||||
|
|
||||||
|
DEVICE_SCHEMA = vol.Schema({
|
||||||
|
vol.Required(CONF_MAC): cv.string,
|
||||||
|
})
|
||||||
|
|
||||||
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
|
vol.Required(CONF_DEVICES):
|
||||||
|
vol.Schema({cv.string: DEVICE_SCHEMA}),
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
"""Setup the eq3 BLE thermostats."""
|
"""Setup the eQ-3 BLE thermostats."""
|
||||||
devices = []
|
devices = []
|
||||||
|
|
||||||
for name, device_cfg in config[CONF_DEVICES].items():
|
for name, device_cfg in config[CONF_DEVICES].items():
|
||||||
@ -30,14 +44,13 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
|
|
||||||
# pylint: disable=too-many-instance-attributes, import-error, abstract-method
|
# pylint: disable=too-many-instance-attributes, import-error, abstract-method
|
||||||
class EQ3BTSmartThermostat(ClimateDevice):
|
class EQ3BTSmartThermostat(ClimateDevice):
|
||||||
"""Representation of a EQ3 Bluetooth Smart thermostat."""
|
"""Representation of a eQ-3 Bluetooth Smart thermostat."""
|
||||||
|
|
||||||
def __init__(self, _mac, _name):
|
def __init__(self, _mac, _name):
|
||||||
"""Initialize the thermostat."""
|
"""Initialize the thermostat."""
|
||||||
from bluepy_devices.devices import eq3btsmart
|
from bluepy_devices.devices import eq3btsmart
|
||||||
|
|
||||||
self._name = _name
|
self._name = _name
|
||||||
|
|
||||||
self._thermostat = eq3btsmart.EQ3BTSmartThermostat(_mac)
|
self._thermostat = eq3btsmart.EQ3BTSmartThermostat(_mac)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -70,8 +83,10 @@ class EQ3BTSmartThermostat(ClimateDevice):
|
|||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
"""Return the device specific state attributes."""
|
"""Return the device specific state attributes."""
|
||||||
return {"mode": self._thermostat.mode,
|
return {
|
||||||
"mode_readable": self._thermostat.mode_readable}
|
ATTR_MODE: self._thermostat.mode,
|
||||||
|
ATTR_MODE_READABLE: self._thermostat.mode_readable,
|
||||||
|
}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def min_temp(self):
|
def min_temp(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user