Add mysensors support for metric/imperial units.

This commit is contained in:
Andrew Thigpen 2015-04-05 17:15:29 -05:00
parent 0e9d826d41
commit 4d47d313f9

View file

@ -16,7 +16,8 @@ import homeassistant.external.pymysensors.mysensors.mysensors as mysensors
import homeassistant.external.pymysensors.mysensors.const as const
from homeassistant.helpers.entity import Entity
from homeassistant.const import (ATTR_BATTERY_LEVEL, EVENT_HOMEASSISTANT_STOP)
from homeassistant.const import (
ATTR_BATTERY_LEVEL, EVENT_HOMEASSISTANT_STOP, TEMP_CELCIUS)
CONF_PORT = "port"
@ -51,6 +52,10 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
gateway = mysensors.SerialGateway(port, sensor_update)
gateway.start()
# Just assume celcius means that the user wants metric for now.
# It may make more sense to make this a global config option in the future.
gateway.metric = (hass.config.temperature_unit == TEMP_CELCIUS)
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP,
lambda event: gateway.stop())