Add mysensors support for metric/imperial units.
This commit is contained in:
parent
0e9d826d41
commit
4d47d313f9
1 changed files with 6 additions and 1 deletions
|
@ -16,7 +16,8 @@ import homeassistant.external.pymysensors.mysensors.mysensors as mysensors
|
||||||
import homeassistant.external.pymysensors.mysensors.const as const
|
import homeassistant.external.pymysensors.mysensors.const as const
|
||||||
from homeassistant.helpers.entity import Entity
|
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"
|
CONF_PORT = "port"
|
||||||
|
|
||||||
|
@ -51,6 +52,10 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
gateway = mysensors.SerialGateway(port, sensor_update)
|
gateway = mysensors.SerialGateway(port, sensor_update)
|
||||||
gateway.start()
|
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,
|
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP,
|
||||||
lambda event: gateway.stop())
|
lambda event: gateway.stop())
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue