Remove global variable from apcupsd (#33717)
* Remove global variable from apcupsd * Run isort * Address review comments
This commit is contained in:
1 parent
00e67fb2c7
commit
60dd2213cf
3 files changed
+15
-13
No files matched your search
@@ -4,7 +4,6 @@ import logging
|
||||
from apcaccess.status import ALL_UNITS
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components import apcupsd
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import (
|
||||
CONF_RESOURCES,
|
||||
@@ -17,6 +16,8 @@ from homeassistant.const import (
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
from . import DOMAIN
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
SENSOR_PREFIX = "UPS "
|
||||
@@ -114,6 +115,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the APCUPSd sensors."""
|
||||
apcups_data = hass.data[DOMAIN]
|
||||
entities = []
|
||||
|
||||
for resource in config[CONF_RESOURCES]:
|
||||
@@ -126,13 +128,13 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"mdi:information-outline",
|
||||
]
|
||||
|
||||
if sensor_type.upper() not in apcupsd.DATA.status:
|
||||
if sensor_type.upper() not in apcups_data.status:
|
||||
_LOGGER.warning(
|
||||
"Sensor type: %s does not appear in the APCUPSd status output",
|
||||
sensor_type,
|
||||
)
|
||||
|
||||
entities.append(APCUPSdSensor(apcupsd.DATA, sensor_type))
|
||||
entities.append(APCUPSdSensor(apcups_data, sensor_type))
|
||||
|
||||
add_entities(entities, True)
|
||||
|
||||
|
||||
Reference in new issue
Block a user