From 352bba1f15b62eb6d2088699911d6f6363279422 Mon Sep 17 00:00:00 2001 From: tkdrob Date: Mon, 8 Feb 2021 03:45:05 -0500 Subject: [PATCH] Use core constants for efergy (#46090) --- homeassistant/components/efergy/sensor.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/efergy/sensor.py b/homeassistant/components/efergy/sensor.py index 8c16317beda..02bc8fa0ccb 100644 --- a/homeassistant/components/efergy/sensor.py +++ b/homeassistant/components/efergy/sensor.py @@ -5,7 +5,13 @@ import requests import voluptuous as vol from homeassistant.components.sensor import PLATFORM_SCHEMA -from homeassistant.const import CONF_CURRENCY, ENERGY_KILO_WATT_HOUR, POWER_WATT +from homeassistant.const import ( + CONF_CURRENCY, + CONF_MONITORED_VARIABLES, + CONF_TYPE, + ENERGY_KILO_WATT_HOUR, + POWER_WATT, +) import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity import Entity @@ -14,8 +20,6 @@ _RESOURCE = "https://engage.efergy.com/mobile_proxy/" CONF_APPTOKEN = "app_token" CONF_UTC_OFFSET = "utc_offset" -CONF_MONITORED_VARIABLES = "monitored_variables" -CONF_SENSOR_TYPE = "type" CONF_PERIOD = "period" @@ -40,7 +44,7 @@ TYPES_SCHEMA = vol.In(SENSOR_TYPES) SENSORS_SCHEMA = vol.Schema( { - vol.Required(CONF_SENSOR_TYPE): TYPES_SCHEMA, + vol.Required(CONF_TYPE): TYPES_SCHEMA, vol.Optional(CONF_CURRENCY, default=""): cv.string, vol.Optional(CONF_PERIOD, default=DEFAULT_PERIOD): cv.string, } @@ -62,14 +66,14 @@ def setup_platform(hass, config, add_entities, discovery_info=None): dev = [] for variable in config[CONF_MONITORED_VARIABLES]: - if variable[CONF_SENSOR_TYPE] == CONF_CURRENT_VALUES: + if variable[CONF_TYPE] == CONF_CURRENT_VALUES: url_string = f"{_RESOURCE}getCurrentValuesSummary?token={app_token}" response = requests.get(url_string, timeout=10) for sensor in response.json(): sid = sensor["sid"] dev.append( EfergySensor( - variable[CONF_SENSOR_TYPE], + variable[CONF_TYPE], app_token, utc_offset, variable[CONF_PERIOD], @@ -79,7 +83,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): ) dev.append( EfergySensor( - variable[CONF_SENSOR_TYPE], + variable[CONF_TYPE], app_token, utc_offset, variable[CONF_PERIOD],