mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 10:47:10 +00:00
let the user supply the sensor name
This commit is contained in:
parent
a764817ee9
commit
956a6418cc
@ -26,6 +26,7 @@ from homeassistant.const import (STATE_UNKNOWN, CONF_ACCESS_TOKEN, CONF_NAME)
|
|||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
REQUIREMENTS = ['eliqonline==1.0.11']
|
REQUIREMENTS = ['eliqonline==1.0.11']
|
||||||
|
DEFAULT_NAME = "ELIQ Energy Usage"
|
||||||
|
|
||||||
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=30)
|
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=30)
|
||||||
|
|
||||||
@ -36,7 +37,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
import eliqonline
|
import eliqonline
|
||||||
|
|
||||||
access_token = config.get(CONF_ACCESS_TOKEN)
|
access_token = config.get(CONF_ACCESS_TOKEN)
|
||||||
name = config.get(CONF_NAME)
|
name = config.get(CONF_NAME, DEFAULT_NAME)
|
||||||
channel_id = config.get("channel_id")
|
channel_id = config.get("channel_id")
|
||||||
|
|
||||||
if not access_token:
|
if not access_token:
|
||||||
@ -54,9 +55,7 @@ class EliqSensor(Entity):
|
|||||||
""" Implements a Eliq sensor. """
|
""" Implements a Eliq sensor. """
|
||||||
|
|
||||||
def __init__(self, api, channel_id, name):
|
def __init__(self, api, channel_id, name):
|
||||||
self._name = "Energy Usage"
|
self._name = name
|
||||||
if name:
|
|
||||||
self._name = name + " " + self._name
|
|
||||||
self._unit_of_measurement = "W"
|
self._unit_of_measurement = "W"
|
||||||
self._state = STATE_UNKNOWN
|
self._state = STATE_UNKNOWN
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user