mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Merge pull request #1339 from MartinHjelmare/fix-mysensors-temp
Fix temperature unit
This commit is contained in:
commit
4128d083e6
@ -158,7 +158,7 @@ def pf_callback_factory(map_sv_types, devices, add_devices, entity_class):
|
|||||||
|
|
||||||
|
|
||||||
class GatewayWrapper(object):
|
class GatewayWrapper(object):
|
||||||
"""Gateway wrapper class, by subclassing serial gateway."""
|
"""Gateway wrapper class."""
|
||||||
|
|
||||||
def __init__(self, gateway, version, optimistic):
|
def __init__(self, gateway, version, optimistic):
|
||||||
"""Setup class attributes on instantiation.
|
"""Setup class attributes on instantiation.
|
||||||
@ -173,6 +173,7 @@ class GatewayWrapper(object):
|
|||||||
version (str): Version of mysensors API.
|
version (str): Version of mysensors API.
|
||||||
platform_callbacks (list): Callback functions, one per platform.
|
platform_callbacks (list): Callback functions, one per platform.
|
||||||
const (module): Mysensors API constants.
|
const (module): Mysensors API constants.
|
||||||
|
optimistic (bool): Send values to actuators without feedback state.
|
||||||
__initialised (bool): True if GatewayWrapper is initialised.
|
__initialised (bool): True if GatewayWrapper is initialised.
|
||||||
"""
|
"""
|
||||||
self._wrapped_gateway = gateway
|
self._wrapped_gateway = gateway
|
||||||
|
@ -8,7 +8,7 @@ import logging
|
|||||||
|
|
||||||
import homeassistant.components.mysensors as mysensors
|
import homeassistant.components.mysensors as mysensors
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_BATTERY_LEVEL, STATE_OFF, STATE_ON, TEMP_CELCIUS)
|
ATTR_BATTERY_LEVEL, STATE_OFF, STATE_ON, TEMP_CELCIUS, TEMP_FAHRENHEIT)
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@ -129,27 +129,28 @@ class MySensorsSensor(Entity):
|
|||||||
@property
|
@property
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
"""Unit of measurement of this entity."""
|
"""Unit of measurement of this entity."""
|
||||||
# HA will convert to degrees F if needed
|
set_req = self.gateway.const.SetReq
|
||||||
unit_map = {
|
unit_map = {
|
||||||
self.gateway.const.SetReq.V_TEMP: TEMP_CELCIUS,
|
set_req.V_TEMP: (TEMP_CELCIUS
|
||||||
self.gateway.const.SetReq.V_HUM: '%',
|
if self.gateway.metric else TEMP_FAHRENHEIT),
|
||||||
self.gateway.const.SetReq.V_DIMMER: '%',
|
set_req.V_HUM: '%',
|
||||||
self.gateway.const.SetReq.V_LIGHT_LEVEL: '%',
|
set_req.V_DIMMER: '%',
|
||||||
self.gateway.const.SetReq.V_WEIGHT: 'kg',
|
set_req.V_LIGHT_LEVEL: '%',
|
||||||
self.gateway.const.SetReq.V_DISTANCE: 'm',
|
set_req.V_WEIGHT: 'kg',
|
||||||
self.gateway.const.SetReq.V_IMPEDANCE: 'ohm',
|
set_req.V_DISTANCE: 'm',
|
||||||
self.gateway.const.SetReq.V_WATT: 'W',
|
set_req.V_IMPEDANCE: 'ohm',
|
||||||
self.gateway.const.SetReq.V_KWH: 'kWh',
|
set_req.V_WATT: 'W',
|
||||||
self.gateway.const.SetReq.V_FLOW: 'm',
|
set_req.V_KWH: 'kWh',
|
||||||
self.gateway.const.SetReq.V_VOLUME: 'm3',
|
set_req.V_FLOW: 'm',
|
||||||
self.gateway.const.SetReq.V_VOLTAGE: 'V',
|
set_req.V_VOLUME: 'm3',
|
||||||
self.gateway.const.SetReq.V_CURRENT: 'A',
|
set_req.V_VOLTAGE: 'V',
|
||||||
|
set_req.V_CURRENT: 'A',
|
||||||
}
|
}
|
||||||
if float(self.gateway.version) >= 1.5:
|
if float(self.gateway.version) >= 1.5:
|
||||||
if self.gateway.const.SetReq.V_UNIT_PREFIX in self._values:
|
if set_req.V_UNIT_PREFIX in self._values:
|
||||||
return self._values[
|
return self._values[
|
||||||
self.gateway.const.SetReq.V_UNIT_PREFIX]
|
set_req.V_UNIT_PREFIX]
|
||||||
unit_map.update({self.gateway.const.SetReq.V_PERCENTAGE: '%'})
|
unit_map.update({set_req.V_PERCENTAGE: '%'})
|
||||||
return unit_map.get(self.value_type)
|
return unit_map.get(self.value_type)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user