This commit is contained in:
Robin Wohlers-Reichel
2019-03-31 19:02:06 +11:00
parent 028ee52a1d
commit caeaa44e8f

View File

@@ -83,12 +83,13 @@ REAL_TIME_DATA_SCHEMA = vol.Schema({
class SolaxRequestError(Exception): class SolaxRequestError(Exception):
"""Error to indicate a Solax API request has failed.""" """Error to indicate a Solax API request has failed."""
pass pass
async def async_setup_platform(hass, config, async_add_entities, async def async_setup_platform(hass, config, async_add_entities,
discovery_info=None): discovery_info=None):
"""Setup the sensor platform.""" """Platform setup."""
endpoint = RealTimeDataEndpoint(hass, config.get(CONF_IP_ADDRESS)) endpoint = RealTimeDataEndpoint(hass, config.get(CONF_IP_ADDRESS))
hass.async_add_job(endpoint.async_refresh) hass.async_add_job(endpoint.async_refresh)
async_track_time_interval(hass, endpoint.async_refresh, SCAN_INTERVAL) async_track_time_interval(hass, endpoint.async_refresh, SCAN_INTERVAL)
@@ -140,7 +141,7 @@ async def async_solax_real_time_request(hass, schema, ip_address, retry,
def parse_solax_battery_response(response): def parse_solax_battery_response(response):
"""Manipulate the response from solax endpoint""" """Manipulate the response from solax endpoint."""
data_list = response['Data'] data_list = response['Data']
result = {} result = {}
for name, index in INVERTER_SENSORS.items(): for name, index in INVERTER_SENSORS.items():
@@ -184,17 +185,21 @@ class RealTimeDataEndpoint:
class Inverter(Entity): class Inverter(Entity):
"""Class for a sensor""" """Class for a sensor."""
def __init__(self, key): def __init__(self, key):
"""Initialize an inverter sensor."""
self.key = key self.key = key
self.value = None self.value = None
@property @property
def state(self): def state(self):
"""State of this inverter attribute."""
return self.value return self.value
@property @property
def name(self): def name(self):
"""Name of this inverter attribute."""
return self.key return self.key
@property @property