Correct celcius to celsius (#1860)
This commit is contained in:
parent
9090672146
commit
2e79e9d5bb
43 changed files with 128 additions and 109 deletions
|
@ -7,7 +7,7 @@ homeassistant:
|
||||||
latitude: 32.87336
|
latitude: 32.87336
|
||||||
longitude: 117.22743
|
longitude: 117.22743
|
||||||
|
|
||||||
# C for Celcius, F for Fahrenheit
|
# C for Celsius, F for Fahrenheit
|
||||||
temperature_unit: C
|
temperature_unit: C
|
||||||
|
|
||||||
# Pick yours from here:
|
# Pick yours from here:
|
||||||
|
|
|
@ -21,7 +21,7 @@ import homeassistant.util.package as pkg_util
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_CUSTOMIZE, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME,
|
CONF_CUSTOMIZE, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME,
|
||||||
CONF_TEMPERATURE_UNIT, CONF_TIME_ZONE, EVENT_COMPONENT_LOADED,
|
CONF_TEMPERATURE_UNIT, CONF_TIME_ZONE, EVENT_COMPONENT_LOADED,
|
||||||
TEMP_CELCIUS, TEMP_FAHRENHEIT, PLATFORM_FORMAT, __version__)
|
TEMP_CELSIUS, TEMP_FAHRENHEIT, PLATFORM_FORMAT, __version__)
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers import (
|
from homeassistant.helpers import (
|
||||||
event_decorators, service, config_per_platform, extract_domain_configs)
|
event_decorators, service, config_per_platform, extract_domain_configs)
|
||||||
|
@ -440,7 +440,7 @@ def process_ha_core_config(hass, config):
|
||||||
if info.use_fahrenheit:
|
if info.use_fahrenheit:
|
||||||
hac.temperature_unit = TEMP_FAHRENHEIT
|
hac.temperature_unit = TEMP_FAHRENHEIT
|
||||||
else:
|
else:
|
||||||
hac.temperature_unit = TEMP_CELCIUS
|
hac.temperature_unit = TEMP_CELSIUS
|
||||||
|
|
||||||
if hac.location_name is None:
|
if hac.location_name is None:
|
||||||
hac.location_name = info.city
|
hac.location_name = info.city
|
||||||
|
|
|
@ -9,7 +9,7 @@ import logging
|
||||||
import homeassistant.bootstrap as bootstrap
|
import homeassistant.bootstrap as bootstrap
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_DISCOVERED, ATTR_SERVICE, EVENT_HOMEASSISTANT_START,
|
ATTR_DISCOVERED, ATTR_SERVICE, EVENT_HOMEASSISTANT_START,
|
||||||
EVENT_HOMEASSISTANT_STOP, EVENT_PLATFORM_DISCOVERED, TEMP_CELCIUS,
|
EVENT_HOMEASSISTANT_STOP, EVENT_PLATFORM_DISCOVERED, TEMP_CELSIUS,
|
||||||
CONF_OPTIMISTIC)
|
CONF_OPTIMISTIC)
|
||||||
from homeassistant.helpers import validate_config
|
from homeassistant.helpers import validate_config
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ def setup(hass, config):
|
||||||
import mysensors.mysensors as mysensors
|
import mysensors.mysensors as mysensors
|
||||||
|
|
||||||
version = str(config[DOMAIN].get(CONF_VERSION, DEFAULT_VERSION))
|
version = str(config[DOMAIN].get(CONF_VERSION, DEFAULT_VERSION))
|
||||||
is_metric = (hass.config.temperature_unit == TEMP_CELCIUS)
|
is_metric = (hass.config.temperature_unit == TEMP_CELSIUS)
|
||||||
|
|
||||||
def setup_gateway(port, persistence, persistence_file, version, baud_rate):
|
def setup_gateway(port, persistence, persistence_file, version, baud_rate):
|
||||||
"""Return gateway after setup of the gateway."""
|
"""Return gateway after setup of the gateway."""
|
||||||
|
|
|
@ -7,13 +7,13 @@ https://home-assistant.io/components/sensor.apcupsd/
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components import apcupsd
|
from homeassistant.components import apcupsd
|
||||||
from homeassistant.const import TEMP_CELCIUS
|
from homeassistant.const import TEMP_CELSIUS
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
DEPENDENCIES = [apcupsd.DOMAIN]
|
DEPENDENCIES = [apcupsd.DOMAIN]
|
||||||
DEFAULT_NAME = "UPS Status"
|
DEFAULT_NAME = "UPS Status"
|
||||||
SPECIFIC_UNITS = {
|
SPECIFIC_UNITS = {
|
||||||
"ITEMP": TEMP_CELCIUS
|
"ITEMP": TEMP_CELSIUS
|
||||||
}
|
}
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
|
@ -4,7 +4,7 @@ Demo platform that has a couple of fake sensors.
|
||||||
For more details about this platform, please refer to the documentation
|
For more details about this platform, please refer to the documentation
|
||||||
https://home-assistant.io/components/demo/
|
https://home-assistant.io/components/demo/
|
||||||
"""
|
"""
|
||||||
from homeassistant.const import ATTR_BATTERY_LEVEL, TEMP_CELCIUS
|
from homeassistant.const import ATTR_BATTERY_LEVEL, TEMP_CELSIUS
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ from homeassistant.helpers.entity import Entity
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
"""Setup the Demo sensors."""
|
"""Setup the Demo sensors."""
|
||||||
add_devices([
|
add_devices([
|
||||||
DemoSensor('Outside Temperature', 15.6, TEMP_CELCIUS, 12),
|
DemoSensor('Outside Temperature', 15.6, TEMP_CELSIUS, 12),
|
||||||
DemoSensor('Outside Humidity', 54, '%', None),
|
DemoSensor('Outside Humidity', 54, '%', None),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ https://home-assistant.io/components/sensor.forecast/
|
||||||
import logging
|
import logging
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
from homeassistant.const import CONF_API_KEY, TEMP_CELCIUS
|
from homeassistant.const import CONF_API_KEY, TEMP_CELSIUS
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.util import Throttle
|
from homeassistant.util import Throttle
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
|
|
||||||
if 'units' in config:
|
if 'units' in config:
|
||||||
units = config['units']
|
units = config['units']
|
||||||
elif hass.config.temperature_unit == TEMP_CELCIUS:
|
elif hass.config.temperature_unit == TEMP_CELSIUS:
|
||||||
units = 'si'
|
units = 'si'
|
||||||
else:
|
else:
|
||||||
units = 'us'
|
units = 'us'
|
||||||
|
|
|
@ -9,7 +9,7 @@ import logging
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from homeassistant.components.sensor import DOMAIN
|
from homeassistant.components.sensor import DOMAIN
|
||||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, TEMP_CELCIUS
|
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, TEMP_CELSIUS
|
||||||
from homeassistant.helpers import validate_config
|
from homeassistant.helpers import validate_config
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ class MfiSensor(Entity):
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
"""Return the unit of measurement of this entity, if any."""
|
"""Return the unit of measurement of this entity, if any."""
|
||||||
if self._port.tag == 'temperature':
|
if self._port.tag == 'temperature':
|
||||||
return TEMP_CELCIUS
|
return TEMP_CELSIUS
|
||||||
elif self._port.tag == 'active_pwr':
|
elif self._port.tag == 'active_pwr':
|
||||||
return 'Watts'
|
return 'Watts'
|
||||||
elif self._port.model == 'Input Digital':
|
elif self._port.model == 'Input Digital':
|
||||||
|
|
|
@ -8,7 +8,7 @@ import logging
|
||||||
|
|
||||||
import homeassistant.components.modbus as modbus
|
import homeassistant.components.modbus as modbus
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
STATE_OFF, STATE_ON, TEMP_CELCIUS, TEMP_FAHRENHEIT)
|
STATE_OFF, STATE_ON, TEMP_CELSIUS, TEMP_FAHRENHEIT)
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -97,7 +97,7 @@ class ModbusSensor(Entity):
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
"""Return the unit of measurement of this entity, if any."""
|
"""Return the unit of measurement of this entity, if any."""
|
||||||
if self._unit == "C":
|
if self._unit == "C":
|
||||||
return TEMP_CELCIUS
|
return TEMP_CELSIUS
|
||||||
elif self._unit == "F":
|
elif self._unit == "F":
|
||||||
return TEMP_FAHRENHEIT
|
return TEMP_FAHRENHEIT
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -7,7 +7,7 @@ https://home-assistant.io/components/sensor.mysensors/
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_BATTERY_LEVEL, STATE_OFF, STATE_ON, TEMP_CELCIUS, TEMP_FAHRENHEIT)
|
ATTR_BATTERY_LEVEL, STATE_OFF, STATE_ON, TEMP_CELSIUS, TEMP_FAHRENHEIT)
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.loader import get_component
|
from homeassistant.loader import get_component
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ class MySensorsSensor(Entity):
|
||||||
"""Return the unit of measurement of this entity."""
|
"""Return the unit of measurement of this entity."""
|
||||||
set_req = self.gateway.const.SetReq
|
set_req = self.gateway.const.SetReq
|
||||||
unit_map = {
|
unit_map = {
|
||||||
set_req.V_TEMP: (TEMP_CELCIUS
|
set_req.V_TEMP: (TEMP_CELSIUS
|
||||||
if self.gateway.metric else TEMP_FAHRENHEIT),
|
if self.gateway.metric else TEMP_FAHRENHEIT),
|
||||||
set_req.V_HUM: '%',
|
set_req.V_HUM: '%',
|
||||||
set_req.V_DIMMER: '%',
|
set_req.V_DIMMER: '%',
|
||||||
|
|
|
@ -9,7 +9,7 @@ import voluptuous as vol
|
||||||
import homeassistant.components.nest as nest
|
import homeassistant.components.nest as nest
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
TEMP_CELCIUS, CONF_PLATFORM, CONF_SCAN_INTERVAL, CONF_MONITORED_CONDITIONS
|
TEMP_CELSIUS, CONF_PLATFORM, CONF_SCAN_INTERVAL, CONF_MONITORED_CONDITIONS
|
||||||
)
|
)
|
||||||
|
|
||||||
DEPENDENCIES = ['nest']
|
DEPENDENCIES = ['nest']
|
||||||
|
@ -103,7 +103,7 @@ class NestTempSensor(NestSensor):
|
||||||
@property
|
@property
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
"""Return the unit the value is expressed in."""
|
"""Return the unit the value is expressed in."""
|
||||||
return TEMP_CELCIUS
|
return TEMP_CELSIUS
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
|
|
|
@ -9,7 +9,7 @@ from datetime import timedelta
|
||||||
|
|
||||||
from homeassistant.components.sensor import DOMAIN
|
from homeassistant.components.sensor import DOMAIN
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_API_KEY, CONF_PASSWORD, CONF_USERNAME, TEMP_CELCIUS)
|
CONF_API_KEY, CONF_PASSWORD, CONF_USERNAME, TEMP_CELSIUS)
|
||||||
from homeassistant.helpers import validate_config
|
from homeassistant.helpers import validate_config
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.util import Throttle
|
from homeassistant.util import Throttle
|
||||||
|
@ -22,7 +22,7 @@ REQUIREMENTS = [
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
SENSOR_TYPES = {
|
SENSOR_TYPES = {
|
||||||
'temperature': ['Temperature', TEMP_CELCIUS, 'mdi:thermometer'],
|
'temperature': ['Temperature', TEMP_CELSIUS, 'mdi:thermometer'],
|
||||||
'co2': ['CO2', 'ppm', 'mdi:cloud'],
|
'co2': ['CO2', 'ppm', 'mdi:cloud'],
|
||||||
'pressure': ['Pressure', 'mbar', 'mdi:gauge'],
|
'pressure': ['Pressure', 'mbar', 'mdi:gauge'],
|
||||||
'noise': ['Noise', 'dB', 'mdi:volume-high'],
|
'noise': ['Noise', 'dB', 'mdi:volume-high'],
|
||||||
|
|
|
@ -9,7 +9,7 @@ import os
|
||||||
import time
|
import time
|
||||||
from glob import glob
|
from glob import glob
|
||||||
|
|
||||||
from homeassistant.const import STATE_UNKNOWN, TEMP_CELCIUS
|
from homeassistant.const import STATE_UNKNOWN, TEMP_CELSIUS
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
BASE_DIR = '/sys/bus/w1/devices/'
|
BASE_DIR = '/sys/bus/w1/devices/'
|
||||||
|
@ -84,7 +84,7 @@ class OneWire(Entity):
|
||||||
@property
|
@property
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
"""Return the unit the value is expressed in."""
|
"""Return the unit the value is expressed in."""
|
||||||
return TEMP_CELCIUS
|
return TEMP_CELSIUS
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Get the latest data from the device."""
|
"""Get the latest data from the device."""
|
||||||
|
|
|
@ -7,7 +7,7 @@ https://home-assistant.io/components/sensor.openweathermap/
|
||||||
import logging
|
import logging
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
from homeassistant.const import CONF_API_KEY, TEMP_CELCIUS, TEMP_FAHRENHEIT
|
from homeassistant.const import CONF_API_KEY, TEMP_CELSIUS, TEMP_FAHRENHEIT
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.util import Throttle
|
from homeassistant.util import Throttle
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ class OpenWeatherMapSensor(Entity):
|
||||||
if self.type == 'weather':
|
if self.type == 'weather':
|
||||||
self._state = data.get_detailed_status()
|
self._state = data.get_detailed_status()
|
||||||
elif self.type == 'temperature':
|
elif self.type == 'temperature':
|
||||||
if self.temp_unit == TEMP_CELCIUS:
|
if self.temp_unit == TEMP_CELSIUS:
|
||||||
self._state = round(data.get_temperature('celsius')['temp'],
|
self._state = round(data.get_temperature('celsius')['temp'],
|
||||||
1)
|
1)
|
||||||
elif self.temp_unit == TEMP_FAHRENHEIT:
|
elif self.temp_unit == TEMP_FAHRENHEIT:
|
||||||
|
|
|
@ -9,7 +9,7 @@ from collections import OrderedDict
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
import homeassistant.components.rfxtrx as rfxtrx
|
import homeassistant.components.rfxtrx as rfxtrx
|
||||||
from homeassistant.const import TEMP_CELCIUS
|
from homeassistant.const import TEMP_CELSIUS
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.util import slugify
|
from homeassistant.util import slugify
|
||||||
|
@ -20,7 +20,7 @@ from homeassistant.components.rfxtrx import (
|
||||||
DEPENDENCIES = ['rfxtrx']
|
DEPENDENCIES = ['rfxtrx']
|
||||||
|
|
||||||
DATA_TYPES = OrderedDict([
|
DATA_TYPES = OrderedDict([
|
||||||
('Temperature', TEMP_CELCIUS),
|
('Temperature', TEMP_CELSIUS),
|
||||||
('Humidity', '%'),
|
('Humidity', '%'),
|
||||||
('Barometer', ''),
|
('Barometer', ''),
|
||||||
('Wind direction', ''),
|
('Wind direction', ''),
|
||||||
|
|
|
@ -10,7 +10,7 @@ from datetime import datetime
|
||||||
|
|
||||||
from homeassistant.components import tellduslive
|
from homeassistant.components import tellduslive
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_BATTERY_LEVEL, DEVICE_DEFAULT_NAME, TEMP_CELCIUS)
|
ATTR_BATTERY_LEVEL, DEVICE_DEFAULT_NAME, TEMP_CELSIUS)
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
ATTR_LAST_UPDATED = "time_last_updated"
|
ATTR_LAST_UPDATED = "time_last_updated"
|
||||||
|
@ -27,7 +27,7 @@ SENSOR_TYPE_WINDGUST = "wgust"
|
||||||
SENSOR_TYPE_WATT = "watt"
|
SENSOR_TYPE_WATT = "watt"
|
||||||
|
|
||||||
SENSOR_TYPES = {
|
SENSOR_TYPES = {
|
||||||
SENSOR_TYPE_TEMP: ['Temperature', TEMP_CELCIUS, "mdi:thermometer"],
|
SENSOR_TYPE_TEMP: ['Temperature', TEMP_CELSIUS, "mdi:thermometer"],
|
||||||
SENSOR_TYPE_HUMIDITY: ['Humidity', '%', "mdi:water"],
|
SENSOR_TYPE_HUMIDITY: ['Humidity', '%', "mdi:water"],
|
||||||
SENSOR_TYPE_RAINRATE: ['Rain rate', 'mm', "mdi:water"],
|
SENSOR_TYPE_RAINRATE: ['Rain rate', 'mm', "mdi:water"],
|
||||||
SENSOR_TYPE_RAINTOTAL: ['Rain total', 'mm', "mdi:water"],
|
SENSOR_TYPE_RAINTOTAL: ['Rain total', 'mm', "mdi:water"],
|
||||||
|
|
|
@ -8,7 +8,7 @@ import logging
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
import homeassistant.util as util
|
import homeassistant.util as util
|
||||||
from homeassistant.const import TEMP_CELCIUS
|
from homeassistant.const import TEMP_CELSIUS
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
DatatypeDescription = namedtuple("DatatypeDescription", ['name', 'unit'])
|
DatatypeDescription = namedtuple("DatatypeDescription", ['name', 'unit'])
|
||||||
|
@ -25,7 +25,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
sensor_value_descriptions = {
|
sensor_value_descriptions = {
|
||||||
tellcore_constants.TELLSTICK_TEMPERATURE:
|
tellcore_constants.TELLSTICK_TEMPERATURE:
|
||||||
DatatypeDescription(
|
DatatypeDescription(
|
||||||
'temperature', config.get('temperature_scale', TEMP_CELCIUS)),
|
'temperature', config.get('temperature_scale', TEMP_CELSIUS)),
|
||||||
|
|
||||||
tellcore_constants.TELLSTICK_HUMIDITY:
|
tellcore_constants.TELLSTICK_HUMIDITY:
|
||||||
DatatypeDescription('humidity', '%'),
|
DatatypeDescription('humidity', '%'),
|
||||||
|
|
|
@ -9,7 +9,7 @@ import logging
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ARMED, ATTR_BATTERY_LEVEL, ATTR_LAST_TRIP_TIME, ATTR_TRIPPED,
|
ATTR_ARMED, ATTR_BATTERY_LEVEL, ATTR_LAST_TRIP_TIME, ATTR_TRIPPED,
|
||||||
TEMP_CELCIUS, TEMP_FAHRENHEIT)
|
TEMP_CELSIUS, TEMP_FAHRENHEIT)
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.components.vera import (
|
from homeassistant.components.vera import (
|
||||||
VeraDevice, VERA_DEVICES, VERA_CONTROLLER)
|
VeraDevice, VERA_DEVICES, VERA_CONTROLLER)
|
||||||
|
@ -84,7 +84,7 @@ class VeraSensor(VeraDevice, Entity):
|
||||||
if vera_temp_units == 'F':
|
if vera_temp_units == 'F':
|
||||||
self._temperature_units = TEMP_FAHRENHEIT
|
self._temperature_units = TEMP_FAHRENHEIT
|
||||||
else:
|
else:
|
||||||
self._temperature_units = TEMP_CELCIUS
|
self._temperature_units = TEMP_CELSIUS
|
||||||
|
|
||||||
if self.hass:
|
if self.hass:
|
||||||
temp = self.hass.config.temperature(
|
temp = self.hass.config.temperature(
|
||||||
|
|
|
@ -7,7 +7,7 @@ documentation at https://home-assistant.io/components/verisure/
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.verisure import HUB as hub
|
from homeassistant.components.verisure import HUB as hub
|
||||||
from homeassistant.const import TEMP_CELCIUS
|
from homeassistant.const import TEMP_CELSIUS
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -68,7 +68,7 @@ class VerisureThermometer(Entity):
|
||||||
@property
|
@property
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
"""Return the unit of measurement of this entity."""
|
"""Return the unit of measurement of this entity."""
|
||||||
return TEMP_CELCIUS
|
return TEMP_CELSIUS
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Update the sensor."""
|
"""Update the sensor."""
|
||||||
|
|
|
@ -7,7 +7,7 @@ at https://home-assistant.io/components/sensor.wink/
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.const import (CONF_ACCESS_TOKEN, STATE_CLOSED,
|
from homeassistant.const import (CONF_ACCESS_TOKEN, STATE_CLOSED,
|
||||||
STATE_OPEN, TEMP_CELCIUS)
|
STATE_OPEN, TEMP_CELSIUS)
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
REQUIREMENTS = ['python-wink==0.7.4']
|
REQUIREMENTS = ['python-wink==0.7.4']
|
||||||
|
@ -45,7 +45,7 @@ class WinkSensorDevice(Entity):
|
||||||
self.wink = wink
|
self.wink = wink
|
||||||
self.capability = self.wink.capability()
|
self.capability = self.wink.capability()
|
||||||
if self.wink.UNIT == "°":
|
if self.wink.UNIT == "°":
|
||||||
self._unit_of_measurement = TEMP_CELCIUS
|
self._unit_of_measurement = TEMP_CELSIUS
|
||||||
else:
|
else:
|
||||||
self._unit_of_measurement = self.wink.UNIT
|
self._unit_of_measurement = self.wink.UNIT
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import logging
|
||||||
from binascii import hexlify
|
from binascii import hexlify
|
||||||
|
|
||||||
from homeassistant.components import zigbee
|
from homeassistant.components import zigbee
|
||||||
from homeassistant.const import TEMP_CELCIUS
|
from homeassistant.const import TEMP_CELSIUS
|
||||||
from homeassistant.core import JobPriority
|
from homeassistant.core import JobPriority
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ class ZigBeeTemperatureSensor(Entity):
|
||||||
@property
|
@property
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
"""Unit the value is expressed in."""
|
"""Unit the value is expressed in."""
|
||||||
return TEMP_CELCIUS
|
return TEMP_CELSIUS
|
||||||
|
|
||||||
def update(self, *args):
|
def update(self, *args):
|
||||||
"""Get the latest data."""
|
"""Get the latest data."""
|
||||||
|
|
|
@ -8,7 +8,7 @@ at https://home-assistant.io/components/sensor.zwave/
|
||||||
# pylint: disable=import-error
|
# pylint: disable=import-error
|
||||||
from homeassistant.components.sensor import DOMAIN
|
from homeassistant.components.sensor import DOMAIN
|
||||||
from homeassistant.components import zwave
|
from homeassistant.components import zwave
|
||||||
from homeassistant.const import (TEMP_CELCIUS, TEMP_FAHRENHEIT)
|
from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ class ZWaveMultilevelSensor(ZWaveSensor):
|
||||||
unit = self._value.units
|
unit = self._value.units
|
||||||
|
|
||||||
if unit == 'C':
|
if unit == 'C':
|
||||||
return TEMP_CELCIUS
|
return TEMP_CELSIUS
|
||||||
elif unit == 'F':
|
elif unit == 'F':
|
||||||
return TEMP_FAHRENHEIT
|
return TEMP_FAHRENHEIT
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -19,7 +19,7 @@ from homeassistant.components import (ecobee, zwave)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ENTITY_ID, ATTR_TEMPERATURE, STATE_ON, STATE_OFF, STATE_UNKNOWN,
|
ATTR_ENTITY_ID, ATTR_TEMPERATURE, STATE_ON, STATE_OFF, STATE_UNKNOWN,
|
||||||
TEMP_CELCIUS)
|
TEMP_CELSIUS)
|
||||||
|
|
||||||
DOMAIN = "thermostat"
|
DOMAIN = "thermostat"
|
||||||
|
|
||||||
|
@ -269,12 +269,12 @@ class ThermostatDevice(Entity):
|
||||||
@property
|
@property
|
||||||
def min_temp(self):
|
def min_temp(self):
|
||||||
"""Return the minimum temperature."""
|
"""Return the minimum temperature."""
|
||||||
return convert(7, TEMP_CELCIUS, self.unit_of_measurement)
|
return convert(7, TEMP_CELSIUS, self.unit_of_measurement)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def max_temp(self):
|
def max_temp(self):
|
||||||
"""Return the maximum temperature."""
|
"""Return the maximum temperature."""
|
||||||
return convert(35, TEMP_CELCIUS, self.unit_of_measurement)
|
return convert(35, TEMP_CELSIUS, self.unit_of_measurement)
|
||||||
|
|
||||||
def _convert_for_display(self, temp):
|
def _convert_for_display(self, temp):
|
||||||
"""Convert temperature into preferred units for display purposes."""
|
"""Convert temperature into preferred units for display purposes."""
|
||||||
|
@ -284,7 +284,7 @@ class ThermostatDevice(Entity):
|
||||||
value = convert(temp, self.unit_of_measurement,
|
value = convert(temp, self.unit_of_measurement,
|
||||||
self.hass.config.temperature_unit)
|
self.hass.config.temperature_unit)
|
||||||
|
|
||||||
if self.hass.config.temperature_unit is TEMP_CELCIUS:
|
if self.hass.config.temperature_unit is TEMP_CELSIUS:
|
||||||
decimal_count = 1
|
decimal_count = 1
|
||||||
else:
|
else:
|
||||||
# Users of fahrenheit generally expect integer units.
|
# Users of fahrenheit generally expect integer units.
|
||||||
|
|
|
@ -5,13 +5,13 @@ For more details about this platform, please refer to the documentation
|
||||||
https://home-assistant.io/components/demo/
|
https://home-assistant.io/components/demo/
|
||||||
"""
|
"""
|
||||||
from homeassistant.components.thermostat import ThermostatDevice
|
from homeassistant.components.thermostat import ThermostatDevice
|
||||||
from homeassistant.const import TEMP_CELCIUS, TEMP_FAHRENHEIT
|
from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
"""Setup the Demo thermostats."""
|
"""Setup the Demo thermostats."""
|
||||||
add_devices([
|
add_devices([
|
||||||
DemoThermostat("Nest", 21, TEMP_CELCIUS, False, 19, False),
|
DemoThermostat("Nest", 21, TEMP_CELSIUS, False, 19, False),
|
||||||
DemoThermostat("Thermostat", 68, TEMP_FAHRENHEIT, True, 77, True),
|
DemoThermostat("Thermostat", 68, TEMP_FAHRENHEIT, True, 77, True),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ from homeassistant.components import switch
|
||||||
from homeassistant.components.thermostat import (
|
from homeassistant.components.thermostat import (
|
||||||
STATE_HEAT, STATE_IDLE, ThermostatDevice)
|
STATE_HEAT, STATE_IDLE, ThermostatDevice)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_UNIT_OF_MEASUREMENT, TEMP_CELCIUS, TEMP_FAHRENHEIT)
|
ATTR_UNIT_OF_MEASUREMENT, TEMP_CELSIUS, TEMP_FAHRENHEIT)
|
||||||
from homeassistant.helpers.event import track_state_change
|
from homeassistant.helpers.event import track_state_change
|
||||||
|
|
||||||
DEPENDENCIES = ['switch', 'sensor']
|
DEPENDENCIES = ['switch', 'sensor']
|
||||||
|
@ -142,11 +142,11 @@ class HeatControl(ThermostatDevice):
|
||||||
"""Update thermostat with latest state from sensor."""
|
"""Update thermostat with latest state from sensor."""
|
||||||
unit = state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
unit = state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
||||||
|
|
||||||
if unit not in (TEMP_CELCIUS, TEMP_FAHRENHEIT):
|
if unit not in (TEMP_CELSIUS, TEMP_FAHRENHEIT):
|
||||||
self._cur_temp = None
|
self._cur_temp = None
|
||||||
self._unit = None
|
self._unit = None
|
||||||
_LOGGER.error('Sensor has unsupported unit: %s (allowed: %s, %s)',
|
_LOGGER.error('Sensor has unsupported unit: %s (allowed: %s, %s)',
|
||||||
unit, TEMP_CELCIUS, TEMP_FAHRENHEIT)
|
unit, TEMP_CELSIUS, TEMP_FAHRENHEIT)
|
||||||
return
|
return
|
||||||
|
|
||||||
temp = util.convert(state.state, float)
|
temp = util.convert(state.state, float)
|
||||||
|
|
|
@ -10,7 +10,7 @@ https://home-assistant.io/components/thermostat.heatmiser/
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.thermostat import ThermostatDevice
|
from homeassistant.components.thermostat import ThermostatDevice
|
||||||
from homeassistant.const import TEMP_CELCIUS
|
from homeassistant.const import TEMP_CELSIUS
|
||||||
|
|
||||||
CONF_IPADDRESS = 'ipaddress'
|
CONF_IPADDRESS = 'ipaddress'
|
||||||
CONF_PORT = 'port'
|
CONF_PORT = 'port'
|
||||||
|
@ -79,7 +79,7 @@ class HeatmiserV3Thermostat(ThermostatDevice):
|
||||||
@property
|
@property
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
"""Return the unit of measurement which this thermostat uses."""
|
"""Return the unit of measurement which this thermostat uses."""
|
||||||
return TEMP_CELCIUS
|
return TEMP_CELSIUS
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_temperature(self):
|
def current_temperature(self):
|
||||||
|
|
|
@ -11,7 +11,7 @@ from xmlrpc.client import Error
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
from homeassistant.components.thermostat import ThermostatDevice
|
from homeassistant.components.thermostat import ThermostatDevice
|
||||||
from homeassistant.const import TEMP_CELCIUS
|
from homeassistant.const import TEMP_CELSIUS
|
||||||
from homeassistant.helpers.temperature import convert
|
from homeassistant.helpers.temperature import convert
|
||||||
|
|
||||||
REQUIREMENTS = []
|
REQUIREMENTS = []
|
||||||
|
@ -120,7 +120,7 @@ class HomematicThermostat(ThermostatDevice):
|
||||||
@property
|
@property
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
"""Return the unit of measurement that is used."""
|
"""Return the unit of measurement that is used."""
|
||||||
return TEMP_CELCIUS
|
return TEMP_CELSIUS
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_temperature(self):
|
def current_temperature(self):
|
||||||
|
@ -149,12 +149,12 @@ class HomematicThermostat(ThermostatDevice):
|
||||||
@property
|
@property
|
||||||
def min_temp(self):
|
def min_temp(self):
|
||||||
"""Return the minimum temperature - 4.5 means off."""
|
"""Return the minimum temperature - 4.5 means off."""
|
||||||
return convert(4.5, TEMP_CELCIUS, self.unit_of_measurement)
|
return convert(4.5, TEMP_CELSIUS, self.unit_of_measurement)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def max_temp(self):
|
def max_temp(self):
|
||||||
"""Return the maximum temperature - 30.5 means on."""
|
"""Return the maximum temperature - 30.5 means on."""
|
||||||
return convert(30.5, TEMP_CELCIUS, self.unit_of_measurement)
|
return convert(30.5, TEMP_CELSIUS, self.unit_of_measurement)
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Update the data from the thermostat."""
|
"""Update the data from the thermostat."""
|
||||||
|
|
|
@ -9,7 +9,7 @@ import socket
|
||||||
|
|
||||||
from homeassistant.components.thermostat import ThermostatDevice
|
from homeassistant.components.thermostat import ThermostatDevice
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_PASSWORD, CONF_USERNAME, TEMP_CELCIUS, TEMP_FAHRENHEIT)
|
CONF_PASSWORD, CONF_USERNAME, TEMP_CELSIUS, TEMP_FAHRENHEIT)
|
||||||
|
|
||||||
REQUIREMENTS = ['evohomeclient==0.2.4',
|
REQUIREMENTS = ['evohomeclient==0.2.4',
|
||||||
'somecomfort==0.2.1']
|
'somecomfort==0.2.1']
|
||||||
|
@ -120,7 +120,7 @@ class RoundThermostat(ThermostatDevice):
|
||||||
@property
|
@property
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
"""Return the unit of measurement."""
|
"""Return the unit of measurement."""
|
||||||
return TEMP_CELCIUS
|
return TEMP_CELSIUS
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_temperature(self):
|
def current_temperature(self):
|
||||||
|
@ -203,7 +203,7 @@ class HoneywellUSThermostat(ThermostatDevice):
|
||||||
@property
|
@property
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
"""Return the unit of measurement."""
|
"""Return the unit of measurement."""
|
||||||
return (TEMP_CELCIUS if self._device.temperature_unit == 'C'
|
return (TEMP_CELSIUS if self._device.temperature_unit == 'C'
|
||||||
else TEMP_FAHRENHEIT)
|
else TEMP_FAHRENHEIT)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -9,7 +9,7 @@ import voluptuous as vol
|
||||||
import homeassistant.components.nest as nest
|
import homeassistant.components.nest as nest
|
||||||
from homeassistant.components.thermostat import (
|
from homeassistant.components.thermostat import (
|
||||||
STATE_COOL, STATE_HEAT, STATE_IDLE, ThermostatDevice)
|
STATE_COOL, STATE_HEAT, STATE_IDLE, ThermostatDevice)
|
||||||
from homeassistant.const import TEMP_CELCIUS, CONF_PLATFORM, CONF_SCAN_INTERVAL
|
from homeassistant.const import TEMP_CELSIUS, CONF_PLATFORM, CONF_SCAN_INTERVAL
|
||||||
|
|
||||||
DEPENDENCIES = ['nest']
|
DEPENDENCIES = ['nest']
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ class NestThermostat(ThermostatDevice):
|
||||||
@property
|
@property
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
"""Return the unit of measurement."""
|
"""Return the unit of measurement."""
|
||||||
return TEMP_CELCIUS
|
return TEMP_CELSIUS
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
|
|
|
@ -7,7 +7,7 @@ from homeassistant.components.thermostat import (
|
||||||
ThermostatDevice,
|
ThermostatDevice,
|
||||||
STATE_IDLE)
|
STATE_IDLE)
|
||||||
from homeassistant.components import zwave
|
from homeassistant.components import zwave
|
||||||
from homeassistant.const import (TEMP_FAHRENHEIT, TEMP_CELCIUS)
|
from homeassistant.const import TEMP_FAHRENHEIT, TEMP_CELSIUS
|
||||||
|
|
||||||
CONF_NAME = 'name'
|
CONF_NAME = 'name'
|
||||||
DEFAULT_NAME = 'ZWave Thermostat'
|
DEFAULT_NAME = 'ZWave Thermostat'
|
||||||
|
@ -82,7 +82,7 @@ class ZWaveThermostat(zwave.ZWaveDeviceEntity, ThermostatDevice):
|
||||||
"""Return the unit of measurement."""
|
"""Return the unit of measurement."""
|
||||||
unit = self._unit
|
unit = self._unit
|
||||||
if unit == 'C':
|
if unit == 'C':
|
||||||
return TEMP_CELCIUS
|
return TEMP_CELSIUS
|
||||||
elif unit == 'F':
|
elif unit == 'F':
|
||||||
return TEMP_FAHRENHEIT
|
return TEMP_FAHRENHEIT
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -26,7 +26,7 @@ DEFAULT_CONFIG = (
|
||||||
(CONF_LATITUDE, None, 'latitude', 'Location required to calculate the time'
|
(CONF_LATITUDE, None, 'latitude', 'Location required to calculate the time'
|
||||||
' the sun rises and sets'),
|
' the sun rises and sets'),
|
||||||
(CONF_LONGITUDE, None, 'longitude', None),
|
(CONF_LONGITUDE, None, 'longitude', None),
|
||||||
(CONF_TEMPERATURE_UNIT, 'C', None, 'C for Celcius, F for Fahrenheit'),
|
(CONF_TEMPERATURE_UNIT, 'C', None, 'C for Celsius, F for Fahrenheit'),
|
||||||
(CONF_TIME_ZONE, 'UTC', 'time_zone', 'Pick yours from here: http://en.wiki'
|
(CONF_TIME_ZONE, 'UTC', 'time_zone', 'Pick yours from here: http://en.wiki'
|
||||||
'pedia.org/wiki/List_of_tz_database_time_zones'),
|
'pedia.org/wiki/List_of_tz_database_time_zones'),
|
||||||
)
|
)
|
||||||
|
|
|
@ -98,6 +98,7 @@ ATTR_UNIT_OF_MEASUREMENT = "unit_of_measurement"
|
||||||
# Temperature attribute
|
# Temperature attribute
|
||||||
ATTR_TEMPERATURE = "temperature"
|
ATTR_TEMPERATURE = "temperature"
|
||||||
TEMP_CELCIUS = "°C"
|
TEMP_CELCIUS = "°C"
|
||||||
|
TEMP_CELSIUS = "°C"
|
||||||
TEMP_FAHRENHEIT = "°F"
|
TEMP_FAHRENHEIT = "°F"
|
||||||
|
|
||||||
# Contains the information that is discovered
|
# Contains the information that is discovered
|
||||||
|
|
|
@ -27,7 +27,7 @@ from homeassistant.const import (
|
||||||
EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP,
|
EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP,
|
||||||
EVENT_SERVICE_EXECUTED, EVENT_SERVICE_REGISTERED, EVENT_STATE_CHANGED,
|
EVENT_SERVICE_EXECUTED, EVENT_SERVICE_REGISTERED, EVENT_STATE_CHANGED,
|
||||||
EVENT_TIME_CHANGED, MATCH_ALL, RESTART_EXIT_CODE,
|
EVENT_TIME_CHANGED, MATCH_ALL, RESTART_EXIT_CODE,
|
||||||
SERVICE_HOMEASSISTANT_RESTART, SERVICE_HOMEASSISTANT_STOP, TEMP_CELCIUS,
|
SERVICE_HOMEASSISTANT_RESTART, SERVICE_HOMEASSISTANT_STOP, TEMP_CELSIUS,
|
||||||
TEMP_FAHRENHEIT, __version__)
|
TEMP_FAHRENHEIT, __version__)
|
||||||
from homeassistant.exceptions import (
|
from homeassistant.exceptions import (
|
||||||
HomeAssistantError, InvalidEntityFormatError)
|
HomeAssistantError, InvalidEntityFormatError)
|
||||||
|
@ -698,7 +698,7 @@ class Config(object):
|
||||||
|
|
||||||
def temperature(self, value, unit):
|
def temperature(self, value, unit):
|
||||||
"""Convert temperature to user preferred unit if set."""
|
"""Convert temperature to user preferred unit if set."""
|
||||||
if not (unit in (TEMP_CELCIUS, TEMP_FAHRENHEIT) and
|
if not (unit in (TEMP_CELSIUS, TEMP_FAHRENHEIT) and
|
||||||
self.temperature_unit and unit != self.temperature_unit):
|
self.temperature_unit and unit != self.temperature_unit):
|
||||||
return value, unit
|
return value, unit
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.loader import get_platform
|
from homeassistant.loader import get_platform
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_PLATFORM, CONF_SCAN_INTERVAL, TEMP_CELCIUS, TEMP_FAHRENHEIT)
|
CONF_PLATFORM, CONF_SCAN_INTERVAL, TEMP_CELSIUS, TEMP_FAHRENHEIT)
|
||||||
from homeassistant.helpers.entity import valid_entity_id
|
from homeassistant.helpers.entity import valid_entity_id
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
from homeassistant.util import slugify
|
from homeassistant.util import slugify
|
||||||
|
@ -156,7 +156,7 @@ def temperature_unit(value):
|
||||||
"""Validate and transform temperature unit."""
|
"""Validate and transform temperature unit."""
|
||||||
value = str(value).upper()
|
value = str(value).upper()
|
||||||
if value == 'C':
|
if value == 'C':
|
||||||
return TEMP_CELCIUS
|
return TEMP_CELSIUS
|
||||||
elif value == 'F':
|
elif value == 'F':
|
||||||
return TEMP_FAHRENHEIT
|
return TEMP_FAHRENHEIT
|
||||||
raise vol.Invalid('invalid temperature unit (expected C or F)')
|
raise vol.Invalid('invalid temperature unit (expected C or F)')
|
||||||
|
|
|
@ -5,7 +5,7 @@ from collections import defaultdict
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ASSUMED_STATE, ATTR_FRIENDLY_NAME, ATTR_HIDDEN, ATTR_ICON,
|
ATTR_ASSUMED_STATE, ATTR_FRIENDLY_NAME, ATTR_HIDDEN, ATTR_ICON,
|
||||||
ATTR_UNIT_OF_MEASUREMENT, DEVICE_DEFAULT_NAME, STATE_OFF, STATE_ON,
|
ATTR_UNIT_OF_MEASUREMENT, DEVICE_DEFAULT_NAME, STATE_OFF, STATE_ON,
|
||||||
STATE_UNAVAILABLE, STATE_UNKNOWN, TEMP_CELCIUS, TEMP_FAHRENHEIT,
|
STATE_UNAVAILABLE, STATE_UNKNOWN, TEMP_CELSIUS, TEMP_FAHRENHEIT,
|
||||||
ATTR_ENTITY_PICTURE)
|
ATTR_ENTITY_PICTURE)
|
||||||
from homeassistant.exceptions import NoEntitySpecifiedError
|
from homeassistant.exceptions import NoEntitySpecifiedError
|
||||||
from homeassistant.util import ensure_unique_string, slugify
|
from homeassistant.util import ensure_unique_string, slugify
|
||||||
|
@ -173,7 +173,7 @@ class Entity(object):
|
||||||
attr.pop(ATTR_HIDDEN)
|
attr.pop(ATTR_HIDDEN)
|
||||||
|
|
||||||
# Convert temperature if we detect one
|
# Convert temperature if we detect one
|
||||||
if attr.get(ATTR_UNIT_OF_MEASUREMENT) in (TEMP_CELCIUS,
|
if attr.get(ATTR_UNIT_OF_MEASUREMENT) in (TEMP_CELSIUS,
|
||||||
TEMP_FAHRENHEIT):
|
TEMP_FAHRENHEIT):
|
||||||
|
|
||||||
state, attr[ATTR_UNIT_OF_MEASUREMENT] = \
|
state, attr[ATTR_UNIT_OF_MEASUREMENT] = \
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
"""Methods to help handle temperature in Home Assistant."""
|
"""Methods to help handle temperature in Home Assistant."""
|
||||||
import homeassistant.util.temperature as temp_util
|
import homeassistant.util.temperature as temp_util
|
||||||
from homeassistant.const import TEMP_CELCIUS
|
from homeassistant.const import TEMP_CELSIUS
|
||||||
|
|
||||||
|
|
||||||
def convert(temperature, unit, to_unit):
|
def convert(temperature, unit, to_unit):
|
||||||
"""Convert temperature to correct unit."""
|
"""Convert temperature to correct unit."""
|
||||||
if unit == to_unit or unit is None or to_unit is None:
|
if unit == to_unit or unit is None or to_unit is None:
|
||||||
return temperature
|
return temperature
|
||||||
elif unit == TEMP_CELCIUS:
|
elif unit == TEMP_CELSIUS:
|
||||||
return temp_util.celcius_to_fahrenheit(temperature)
|
return temp_util.celsius_to_fahrenheit(temperature)
|
||||||
|
|
||||||
return temp_util.fahrenheit_to_celcius(temperature)
|
return temp_util.fahrenheit_to_celsius(temperature)
|
||||||
|
|
|
@ -1,11 +1,29 @@
|
||||||
"""Temperature util functions."""
|
"""Temperature util functions."""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
|
||||||
def fahrenheit_to_celcius(fahrenheit):
|
def fahrenheit_to_celcius(fahrenheit):
|
||||||
|
"""**DEPRECATED** Convert a Fahrenheit temperature to Celsius."""
|
||||||
|
logging.getLogger(__name__).warning(
|
||||||
|
'fahrenheit_to_celcius is now fahrenheit_to_celsius '
|
||||||
|
'correcting a spelling mistake')
|
||||||
|
return fahrenheit_to_celsius(fahrenheit)
|
||||||
|
|
||||||
|
|
||||||
|
def fahrenheit_to_celsius(fahrenheit):
|
||||||
"""Convert a Fahrenheit temperature to Celsius."""
|
"""Convert a Fahrenheit temperature to Celsius."""
|
||||||
return (fahrenheit - 32.0) / 1.8
|
return (fahrenheit - 32.0) / 1.8
|
||||||
|
|
||||||
|
|
||||||
def celcius_to_fahrenheit(celcius):
|
def celcius_to_fahrenheit(celcius):
|
||||||
|
"""**DEPRECATED** Convert a Celsius temperature to Fahrenheit."""
|
||||||
|
logging.getLogger(__name__).warning(
|
||||||
|
'celcius_to_fahrenheit is now celsius_to_fahrenheit correcting '
|
||||||
|
'a spelling mistake')
|
||||||
|
return celsius_to_fahrenheit(celcius)
|
||||||
|
|
||||||
|
|
||||||
|
def celsius_to_fahrenheit(celsius):
|
||||||
"""Convert a Celsius temperature to Fahrenheit."""
|
"""Convert a Celsius temperature to Fahrenheit."""
|
||||||
return celcius * 1.8 + 32.0
|
return celsius * 1.8 + 32.0
|
||||||
|
|
|
@ -10,7 +10,7 @@ import homeassistant.util.dt as date_util
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
STATE_ON, STATE_OFF, DEVICE_DEFAULT_NAME, EVENT_TIME_CHANGED,
|
STATE_ON, STATE_OFF, DEVICE_DEFAULT_NAME, EVENT_TIME_CHANGED,
|
||||||
EVENT_STATE_CHANGED, EVENT_PLATFORM_DISCOVERED, ATTR_SERVICE,
|
EVENT_STATE_CHANGED, EVENT_PLATFORM_DISCOVERED, ATTR_SERVICE,
|
||||||
ATTR_DISCOVERED, SERVER_PORT, TEMP_CELCIUS)
|
ATTR_DISCOVERED, SERVER_PORT, TEMP_CELSIUS)
|
||||||
from homeassistant.components import sun, mqtt
|
from homeassistant.components import sun, mqtt
|
||||||
|
|
||||||
_TEST_INSTANCE_PORT = SERVER_PORT
|
_TEST_INSTANCE_PORT = SERVER_PORT
|
||||||
|
@ -36,7 +36,7 @@ def get_test_home_assistant(num_threads=None):
|
||||||
hass.config.latitude = 32.87336
|
hass.config.latitude = 32.87336
|
||||||
hass.config.longitude = -117.22743
|
hass.config.longitude = -117.22743
|
||||||
hass.config.time_zone = date_util.get_time_zone('US/Pacific')
|
hass.config.time_zone = date_util.get_time_zone('US/Pacific')
|
||||||
hass.config.temperature_unit = TEMP_CELCIUS
|
hass.config.temperature_unit = TEMP_CELSIUS
|
||||||
|
|
||||||
if 'custom_components.test' not in loader.AVAILABLE_COMPONENTS:
|
if 'custom_components.test' not in loader.AVAILABLE_COMPONENTS:
|
||||||
loader.prepare(hass)
|
loader.prepare(hass)
|
||||||
|
|
|
@ -6,7 +6,7 @@ import requests
|
||||||
|
|
||||||
import homeassistant.components.sensor as sensor
|
import homeassistant.components.sensor as sensor
|
||||||
import homeassistant.components.sensor.mfi as mfi
|
import homeassistant.components.sensor.mfi as mfi
|
||||||
from homeassistant.const import TEMP_CELCIUS
|
from homeassistant.const import TEMP_CELSIUS
|
||||||
|
|
||||||
from tests.common import get_test_home_assistant
|
from tests.common import get_test_home_assistant
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ class TestMfiSensor(unittest.TestCase):
|
||||||
def test_uom_temp(self):
|
def test_uom_temp(self):
|
||||||
"""Test the UOM temperature."""
|
"""Test the UOM temperature."""
|
||||||
self.port.tag = 'temperature'
|
self.port.tag = 'temperature'
|
||||||
self.assertEqual(TEMP_CELCIUS, self.sensor.unit_of_measurement)
|
self.assertEqual(TEMP_CELSIUS, self.sensor.unit_of_measurement)
|
||||||
|
|
||||||
def test_uom_power(self):
|
def test_uom_power(self):
|
||||||
"""Test the UOEM power."""
|
"""Test the UOEM power."""
|
||||||
|
|
|
@ -3,7 +3,7 @@ import unittest
|
||||||
|
|
||||||
from homeassistant.bootstrap import _setup_component
|
from homeassistant.bootstrap import _setup_component
|
||||||
from homeassistant.components import rfxtrx as rfxtrx_core
|
from homeassistant.components import rfxtrx as rfxtrx_core
|
||||||
from homeassistant.const import TEMP_CELCIUS
|
from homeassistant.const import TEMP_CELSIUS
|
||||||
|
|
||||||
from tests.common import get_test_home_assistant
|
from tests.common import get_test_home_assistant
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ class TestSensorRfxtrx(unittest.TestCase):
|
||||||
print(rfxtrx_core.RFX_DEVICES)
|
print(rfxtrx_core.RFX_DEVICES)
|
||||||
entity = rfxtrx_core.RFX_DEVICES['sensor_0502']
|
entity = rfxtrx_core.RFX_DEVICES['sensor_0502']
|
||||||
self.assertEqual('Test', entity.name)
|
self.assertEqual('Test', entity.name)
|
||||||
self.assertEqual(TEMP_CELCIUS, entity.unit_of_measurement)
|
self.assertEqual(TEMP_CELSIUS, entity.unit_of_measurement)
|
||||||
self.assertEqual(14.9, entity.state)
|
self.assertEqual(14.9, entity.state)
|
||||||
self.assertEqual({'Humidity status': 'normal', 'Temperature': 14.9,
|
self.assertEqual({'Humidity status': 'normal', 'Temperature': 14.9,
|
||||||
'Rssi numeric': 6, 'Humidity': 34,
|
'Rssi numeric': 6, 'Humidity': 34,
|
||||||
|
@ -85,7 +85,7 @@ class TestSensorRfxtrx(unittest.TestCase):
|
||||||
self.assertEqual('Bath_Humidity', entity.__str__())
|
self.assertEqual('Bath_Humidity', entity.__str__())
|
||||||
elif entity.name == 'Bath':
|
elif entity.name == 'Bath':
|
||||||
device_num = device_num + 1
|
device_num = device_num + 1
|
||||||
self.assertEqual(TEMP_CELCIUS, entity.unit_of_measurement)
|
self.assertEqual(TEMP_CELSIUS, entity.unit_of_measurement)
|
||||||
self.assertEqual(25.5, entity.state)
|
self.assertEqual(25.5, entity.state)
|
||||||
self.assertEqual({'Battery numeric': 9, 'Temperature': 25.5,
|
self.assertEqual({'Battery numeric': 9, 'Temperature': 25.5,
|
||||||
'Humidity': 14, 'Humidity status': 'normal',
|
'Humidity': 14, 'Humidity status': 'normal',
|
||||||
|
@ -95,7 +95,7 @@ class TestSensorRfxtrx(unittest.TestCase):
|
||||||
self.assertEqual('Bath', entity.__str__())
|
self.assertEqual('Bath', entity.__str__())
|
||||||
elif entity.name == 'Test':
|
elif entity.name == 'Test':
|
||||||
device_num = device_num + 1
|
device_num = device_num + 1
|
||||||
self.assertEqual(TEMP_CELCIUS, entity.unit_of_measurement)
|
self.assertEqual(TEMP_CELSIUS, entity.unit_of_measurement)
|
||||||
self.assertEqual(14.9, entity.state)
|
self.assertEqual(14.9, entity.state)
|
||||||
self.assertEqual({'Humidity status': 'normal',
|
self.assertEqual({'Humidity status': 'normal',
|
||||||
'Temperature': 14.9,
|
'Temperature': 14.9,
|
||||||
|
@ -226,7 +226,7 @@ class TestSensorRfxtrx(unittest.TestCase):
|
||||||
self.assertEqual('Bath_Humidity', entity.__str__())
|
self.assertEqual('Bath_Humidity', entity.__str__())
|
||||||
elif entity.name == 'Bath':
|
elif entity.name == 'Bath':
|
||||||
device_num = device_num + 1
|
device_num = device_num + 1
|
||||||
self.assertEqual(TEMP_CELCIUS, entity.unit_of_measurement)
|
self.assertEqual(TEMP_CELSIUS, entity.unit_of_measurement)
|
||||||
self.assertEqual(25.5, entity.state)
|
self.assertEqual(25.5, entity.state)
|
||||||
self.assertEqual({'Battery numeric': 9, 'Temperature': 25.5,
|
self.assertEqual({'Battery numeric': 9, 'Temperature': 25.5,
|
||||||
'Humidity': 14, 'Humidity status': 'normal',
|
'Humidity': 14, 'Humidity status': 'normal',
|
||||||
|
@ -236,7 +236,7 @@ class TestSensorRfxtrx(unittest.TestCase):
|
||||||
self.assertEqual('Bath', entity.__str__())
|
self.assertEqual('Bath', entity.__str__())
|
||||||
elif entity.name == 'Test':
|
elif entity.name == 'Test':
|
||||||
device_num = device_num + 1
|
device_num = device_num + 1
|
||||||
self.assertEqual(TEMP_CELCIUS, entity.unit_of_measurement)
|
self.assertEqual(TEMP_CELSIUS, entity.unit_of_measurement)
|
||||||
self.assertEqual(14.9, entity.state)
|
self.assertEqual(14.9, entity.state)
|
||||||
self.assertEqual({'Humidity status': 'normal',
|
self.assertEqual({'Humidity status': 'normal',
|
||||||
'Temperature': 14.9,
|
'Temperature': 14.9,
|
||||||
|
@ -274,7 +274,7 @@ class TestSensorRfxtrx(unittest.TestCase):
|
||||||
self.assertEqual('Bath_Humidity', entity.__str__())
|
self.assertEqual('Bath_Humidity', entity.__str__())
|
||||||
elif entity.name == 'Bath':
|
elif entity.name == 'Bath':
|
||||||
device_num = device_num + 1
|
device_num = device_num + 1
|
||||||
self.assertEqual(TEMP_CELCIUS, entity.unit_of_measurement)
|
self.assertEqual(TEMP_CELSIUS, entity.unit_of_measurement)
|
||||||
self.assertEqual(51.1, entity.state)
|
self.assertEqual(51.1, entity.state)
|
||||||
self.assertEqual({'Battery numeric': 9, 'Temperature': 51.1,
|
self.assertEqual({'Battery numeric': 9, 'Temperature': 51.1,
|
||||||
'Humidity': 15, 'Humidity status': 'normal',
|
'Humidity': 15, 'Humidity status': 'normal',
|
||||||
|
@ -284,7 +284,7 @@ class TestSensorRfxtrx(unittest.TestCase):
|
||||||
self.assertEqual('Bath', entity.__str__())
|
self.assertEqual('Bath', entity.__str__())
|
||||||
elif entity.name == 'Test':
|
elif entity.name == 'Test':
|
||||||
device_num = device_num + 1
|
device_num = device_num + 1
|
||||||
self.assertEqual(TEMP_CELCIUS, entity.unit_of_measurement)
|
self.assertEqual(TEMP_CELSIUS, entity.unit_of_measurement)
|
||||||
self.assertEqual(13.3, entity.state)
|
self.assertEqual(13.3, entity.state)
|
||||||
self.assertEqual({'Humidity status': 'normal',
|
self.assertEqual({'Humidity status': 'normal',
|
||||||
'Temperature': 13.3,
|
'Temperature': 13.3,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
TEMP_CELCIUS,
|
TEMP_CELSIUS,
|
||||||
)
|
)
|
||||||
from homeassistant.components import thermostat
|
from homeassistant.components import thermostat
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ class TestDemoThermostat(unittest.TestCase):
|
||||||
def setUp(self): # pylint: disable=invalid-name
|
def setUp(self): # pylint: disable=invalid-name
|
||||||
"""Setup things to be run when tests are started."""
|
"""Setup things to be run when tests are started."""
|
||||||
self.hass = get_test_home_assistant()
|
self.hass = get_test_home_assistant()
|
||||||
self.hass.config.temperature_unit = TEMP_CELCIUS
|
self.hass.config.temperature_unit = TEMP_CELSIUS
|
||||||
self.assertTrue(thermostat.setup(self.hass, {'thermostat': {
|
self.assertTrue(thermostat.setup(self.hass, {'thermostat': {
|
||||||
'platform': 'demo',
|
'platform': 'demo',
|
||||||
}}))
|
}}))
|
||||||
|
|
|
@ -8,7 +8,7 @@ from homeassistant.const import (
|
||||||
SERVICE_TURN_ON,
|
SERVICE_TURN_ON,
|
||||||
STATE_ON,
|
STATE_ON,
|
||||||
STATE_OFF,
|
STATE_OFF,
|
||||||
TEMP_CELCIUS,
|
TEMP_CELSIUS,
|
||||||
)
|
)
|
||||||
from homeassistant.components import thermostat
|
from homeassistant.components import thermostat
|
||||||
import homeassistant.components.thermostat.heat_control as heat_control
|
import homeassistant.components.thermostat.heat_control as heat_control
|
||||||
|
@ -48,7 +48,7 @@ class TestSetupThermostatHeatControl(unittest.TestCase):
|
||||||
def test_setup_with_sensor(self):
|
def test_setup_with_sensor(self):
|
||||||
"""Test set up heat_control with sensor to trigger update at init."""
|
"""Test set up heat_control with sensor to trigger update at init."""
|
||||||
self.hass.states.set(ENT_SENSOR, 22.0, {
|
self.hass.states.set(ENT_SENSOR, 22.0, {
|
||||||
ATTR_UNIT_OF_MEASUREMENT: TEMP_CELCIUS
|
ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS
|
||||||
})
|
})
|
||||||
thermostat.setup(self.hass, {'thermostat': {
|
thermostat.setup(self.hass, {'thermostat': {
|
||||||
'platform': 'heat_control',
|
'platform': 'heat_control',
|
||||||
|
@ -58,7 +58,7 @@ class TestSetupThermostatHeatControl(unittest.TestCase):
|
||||||
}})
|
}})
|
||||||
state = self.hass.states.get(ENTITY)
|
state = self.hass.states.get(ENTITY)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
TEMP_CELCIUS, state.attributes.get('unit_of_measurement'))
|
TEMP_CELSIUS, state.attributes.get('unit_of_measurement'))
|
||||||
self.assertEqual(22.0, state.attributes.get('current_temperature'))
|
self.assertEqual(22.0, state.attributes.get('current_temperature'))
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ class TestThermostatHeatControl(unittest.TestCase):
|
||||||
def setUp(self): # pylint: disable=invalid-name
|
def setUp(self): # pylint: disable=invalid-name
|
||||||
"""Setup things to be run when tests are started."""
|
"""Setup things to be run when tests are started."""
|
||||||
self.hass = get_test_home_assistant()
|
self.hass = get_test_home_assistant()
|
||||||
self.hass.config.temperature_unit = TEMP_CELCIUS
|
self.hass.config.temperature_unit = TEMP_CELSIUS
|
||||||
thermostat.setup(self.hass, {'thermostat': {
|
thermostat.setup(self.hass, {'thermostat': {
|
||||||
'platform': 'heat_control',
|
'platform': 'heat_control',
|
||||||
'name': 'test',
|
'name': 'test',
|
||||||
|
@ -182,7 +182,7 @@ class TestThermostatHeatControl(unittest.TestCase):
|
||||||
self.assertEqual(SERVICE_TURN_OFF, call.service)
|
self.assertEqual(SERVICE_TURN_OFF, call.service)
|
||||||
self.assertEqual(ENT_SWITCH, call.data['entity_id'])
|
self.assertEqual(ENT_SWITCH, call.data['entity_id'])
|
||||||
|
|
||||||
def _setup_sensor(self, temp, unit=TEMP_CELCIUS):
|
def _setup_sensor(self, temp, unit=TEMP_CELSIUS):
|
||||||
"""Setup the test sensor."""
|
"""Setup the test sensor."""
|
||||||
self.hass.states.set(ENT_SENSOR, temp, {
|
self.hass.states.set(ENT_SENSOR, temp, {
|
||||||
ATTR_UNIT_OF_MEASUREMENT: unit
|
ATTR_UNIT_OF_MEASUREMENT: unit
|
||||||
|
|
|
@ -6,7 +6,7 @@ from unittest import mock
|
||||||
import somecomfort
|
import somecomfort
|
||||||
|
|
||||||
from homeassistant.const import (CONF_USERNAME, CONF_PASSWORD,
|
from homeassistant.const import (CONF_USERNAME, CONF_PASSWORD,
|
||||||
TEMP_CELCIUS, TEMP_FAHRENHEIT)
|
TEMP_CELSIUS, TEMP_FAHRENHEIT)
|
||||||
import homeassistant.components.thermostat.honeywell as honeywell
|
import homeassistant.components.thermostat.honeywell as honeywell
|
||||||
|
|
||||||
|
|
||||||
|
@ -249,13 +249,13 @@ class TestHoneywellRound(unittest.TestCase):
|
||||||
def test_attributes(self):
|
def test_attributes(self):
|
||||||
"""Test the attributes."""
|
"""Test the attributes."""
|
||||||
self.assertEqual('House', self.round1.name)
|
self.assertEqual('House', self.round1.name)
|
||||||
self.assertEqual(TEMP_CELCIUS, self.round1.unit_of_measurement)
|
self.assertEqual(TEMP_CELSIUS, self.round1.unit_of_measurement)
|
||||||
self.assertEqual(20, self.round1.current_temperature)
|
self.assertEqual(20, self.round1.current_temperature)
|
||||||
self.assertEqual(21, self.round1.target_temperature)
|
self.assertEqual(21, self.round1.target_temperature)
|
||||||
self.assertFalse(self.round1.is_away_mode_on)
|
self.assertFalse(self.round1.is_away_mode_on)
|
||||||
|
|
||||||
self.assertEqual('Hot Water', self.round2.name)
|
self.assertEqual('Hot Water', self.round2.name)
|
||||||
self.assertEqual(TEMP_CELCIUS, self.round2.unit_of_measurement)
|
self.assertEqual(TEMP_CELSIUS, self.round2.unit_of_measurement)
|
||||||
self.assertEqual(21, self.round2.current_temperature)
|
self.assertEqual(21, self.round2.current_temperature)
|
||||||
self.assertEqual(None, self.round2.target_temperature)
|
self.assertEqual(None, self.round2.target_temperature)
|
||||||
self.assertFalse(self.round2.is_away_mode_on)
|
self.assertFalse(self.round2.is_away_mode_on)
|
||||||
|
@ -307,7 +307,7 @@ class TestHoneywellUS(unittest.TestCase):
|
||||||
"""Test the unit of measurement."""
|
"""Test the unit of measurement."""
|
||||||
self.assertEqual(TEMP_FAHRENHEIT, self.honeywell.unit_of_measurement)
|
self.assertEqual(TEMP_FAHRENHEIT, self.honeywell.unit_of_measurement)
|
||||||
self.device.temperature_unit = 'C'
|
self.device.temperature_unit = 'C'
|
||||||
self.assertEqual(TEMP_CELCIUS, self.honeywell.unit_of_measurement)
|
self.assertEqual(TEMP_CELSIUS, self.honeywell.unit_of_measurement)
|
||||||
|
|
||||||
def test_target_temp(self):
|
def test_target_temp(self):
|
||||||
"""Test the target temperature."""
|
"""Test the target temperature."""
|
||||||
|
|
|
@ -17,7 +17,7 @@ from homeassistant.exceptions import (
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
__version__, EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP,
|
__version__, EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP,
|
||||||
EVENT_STATE_CHANGED, ATTR_FRIENDLY_NAME, TEMP_CELCIUS,
|
EVENT_STATE_CHANGED, ATTR_FRIENDLY_NAME, TEMP_CELSIUS,
|
||||||
TEMP_FAHRENHEIT)
|
TEMP_FAHRENHEIT)
|
||||||
|
|
||||||
from tests.common import get_test_home_assistant
|
from tests.common import get_test_home_assistant
|
||||||
|
@ -448,8 +448,8 @@ class TestConfig(unittest.TestCase):
|
||||||
def test_temperature_not_convert_if_no_preference(self):
|
def test_temperature_not_convert_if_no_preference(self):
|
||||||
"""No unit conversion to happen if no preference."""
|
"""No unit conversion to happen if no preference."""
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
(25, TEMP_CELCIUS),
|
(25, TEMP_CELSIUS),
|
||||||
self.config.temperature(25, TEMP_CELCIUS))
|
self.config.temperature(25, TEMP_CELSIUS))
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
(80, TEMP_FAHRENHEIT),
|
(80, TEMP_FAHRENHEIT),
|
||||||
self.config.temperature(80, TEMP_FAHRENHEIT))
|
self.config.temperature(80, TEMP_FAHRENHEIT))
|
||||||
|
@ -458,8 +458,8 @@ class TestConfig(unittest.TestCase):
|
||||||
"""No unit conversion to happen if no preference."""
|
"""No unit conversion to happen if no preference."""
|
||||||
self.config.temperature_unit = TEMP_FAHRENHEIT
|
self.config.temperature_unit = TEMP_FAHRENHEIT
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
('25a', TEMP_CELCIUS),
|
('25a', TEMP_CELSIUS),
|
||||||
self.config.temperature('25a', TEMP_CELCIUS))
|
self.config.temperature('25a', TEMP_CELSIUS))
|
||||||
|
|
||||||
def test_temperature_not_convert_if_invalid_unit(self):
|
def test_temperature_not_convert_if_invalid_unit(self):
|
||||||
"""No unit conversion to happen if no preference."""
|
"""No unit conversion to happen if no preference."""
|
||||||
|
@ -467,15 +467,15 @@ class TestConfig(unittest.TestCase):
|
||||||
(25, 'Invalid unit'),
|
(25, 'Invalid unit'),
|
||||||
self.config.temperature(25, 'Invalid unit'))
|
self.config.temperature(25, 'Invalid unit'))
|
||||||
|
|
||||||
def test_temperature_to_convert_to_celcius(self):
|
def test_temperature_to_convert_to_celsius(self):
|
||||||
"""Test temperature conversion to celsius."""
|
"""Test temperature conversion to celsius."""
|
||||||
self.config.temperature_unit = TEMP_CELCIUS
|
self.config.temperature_unit = TEMP_CELSIUS
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
(25, TEMP_CELCIUS),
|
(25, TEMP_CELSIUS),
|
||||||
self.config.temperature(25, TEMP_CELCIUS))
|
self.config.temperature(25, TEMP_CELSIUS))
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
(26.7, TEMP_CELCIUS),
|
(26.7, TEMP_CELSIUS),
|
||||||
self.config.temperature(80, TEMP_FAHRENHEIT))
|
self.config.temperature(80, TEMP_FAHRENHEIT))
|
||||||
|
|
||||||
def test_temperature_to_convert_to_fahrenheit(self):
|
def test_temperature_to_convert_to_fahrenheit(self):
|
||||||
|
@ -484,7 +484,7 @@ class TestConfig(unittest.TestCase):
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
(77, TEMP_FAHRENHEIT),
|
(77, TEMP_FAHRENHEIT),
|
||||||
self.config.temperature(25, TEMP_CELCIUS))
|
self.config.temperature(25, TEMP_CELSIUS))
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
(80, TEMP_FAHRENHEIT),
|
(80, TEMP_FAHRENHEIT),
|
||||||
self.config.temperature(80, TEMP_FAHRENHEIT))
|
self.config.temperature(80, TEMP_FAHRENHEIT))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue