"""
Support for eq3 Bluetooth Smart thermostats.

For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/climate.eq3btsmart/
"""
import logging

from homeassistant.components.climate import ClimateDevice
from homeassistant.const import TEMP_CELSIUS, CONF_DEVICES, ATTR_TEMPERATURE
from homeassistant.util.temperature import convert

REQUIREMENTS = ['bluepy_devices==0.2.0']

CONF_MAC = 'mac'

_LOGGER = logging.getLogger(__name__)


def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup the eq3 BLE thermostats."""
    devices = []

    for name, device_cfg in config[CONF_DEVICES].items():
        mac = device_cfg[CONF_MAC]
        devices.append(EQ3BTSmartThermostat(mac, name))

    add_devices(devices)


# pylint: disable=too-many-instance-attributes, import-error, abstract-method
class EQ3BTSmartThermostat(ClimateDevice):
    """Representation of a EQ3 Bluetooth Smart thermostat."""

    def __init__(self, _mac, _name):
        """Initialize the thermostat."""
        from bluepy_devices.devices import eq3btsmart

        self._name = _name

        self._thermostat = eq3btsmart.EQ3BTSmartThermostat(_mac)

    @property
    def name(self):
        """Return the name of the device."""
        return self._name

    @property
    def temperature_unit(self):
        """Return the unit of measurement that is used."""
        return TEMP_CELSIUS

    @property
    def current_temperature(self):
        """Can not report temperature, so return target_temperature."""
        return self.target_temperature

    @property
    def target_temperature(self):
        """Return the temperature we try to reach."""
        return self._thermostat.target_temperature

    def set_temperature(self, **kwargs):
        """Set new target temperature."""
        temperature = kwargs.get(ATTR_TEMPERATURE)
        if temperature is None:
            return
        self._thermostat.target_temperature = temperature

    @property
    def device_state_attributes(self):
        """Return the device specific state attributes."""
        return {"mode": self._thermostat.mode,
                "mode_readable": self._thermostat.mode_readable}

    @property
    def min_temp(self):
        """Return the minimum temperature."""
        return convert(self._thermostat.min_temp, TEMP_CELSIUS,
                       self.unit_of_measurement)

    @property
    def max_temp(self):
        """Return the maximum temperature."""
        return convert(self._thermostat.max_temp, TEMP_CELSIUS,
                       self.unit_of_measurement)

    def update(self):
        """Update the data from the thermostat."""
        self._thermostat.update()

@@ -10,17 +10,18 @@
 rt for e
-q
+Q-
 3 Blueto
@@ -196,16 +196,42 @@
 ogging%0A%0A
+import voluptuous as vol%0A%0A
 from hom
@@ -280,16 +280,33 @@
 teDevice
+, PLATFORM_SCHEMA
 %0Afrom ho
@@ -329,16 +329,32 @@
 t import
+ (%0A    CONF_MAC,
  TEMP_CE
@@ -390,16 +390,17 @@
 PERATURE
+)
 %0Afrom ho
@@ -442,16 +442,69 @@
  convert
+%0Aimport homeassistant.helpers.config_validation as cv
 %0A%0AREQUIR
@@ -543,26 +543,8 @@
 '%5D%0A%0A
-CONF_MAC = 'mac'%0A%0A
 _LOG
@@ -578,16 +578,272 @@
 ame__)%0A%0A
+ATTR_MODE = 'mode'%0AATTR_MODE_READABLE = 'mode_readable'%0A%0ADEVICE_SCHEMA = vol.Schema(%7B%0A    vol.Required(CONF_MAC): cv.string,%0A%7D)%0A%0APLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(%7B%0A    vol.Required(CONF_DEVICES):%0A        vol.Schema(%7Bcv.string: DEVICE_SCHEMA%7D),%0A%7D)%0A%0A
 %0Adef set
@@ -921,17 +921,18 @@
 up the e
-q
+Q-
 3 BLE th
@@ -1288,18 +1288,19 @@
 on of a 
-EQ
+eQ-
 3 Blueto
@@ -1481,25 +1481,24 @@
 ame = _name%0A
-%0A
         self
@@ -2482,14 +2482,30 @@
 rn %7B
-%22mode%22
+%0A            ATTR_MODE
 : se
@@ -2541,27 +2541,26 @@
     
-    %22mode_readable%22
+ATTR_MODE_READABLE
 : se
@@ -2587,16 +2587,26 @@
 readable
+,%0A        
 %7D%0A%0A    @

Use voluptuous for eQ-3 thermostat (#3729)