core/homeassistant/components/fronius/sensor.py

294 lines
8.9 KiB
Python
Raw Normal View History

Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
"""Support for Fronius devices."""
import copy
from datetime import timedelta
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
import logging
import voluptuous as vol
from pyfronius import Fronius
from homeassistant.components.sensor import PLATFORM_SCHEMA
2019-07-31 19:25:30 +00:00
from homeassistant.const import (
CONF_RESOURCE,
CONF_SENSOR_TYPE,
CONF_DEVICE,
CONF_MONITORED_CONDITIONS,
CONF_SCAN_INTERVAL,
2019-07-31 19:25:30 +00:00
)
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
from homeassistant.helpers.aiohttp_client import async_get_clientsession
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.event import async_track_time_interval
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
_LOGGER = logging.getLogger(__name__)
2019-07-31 19:25:30 +00:00
CONF_SCOPE = "scope"
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
2019-07-31 19:25:30 +00:00
TYPE_INVERTER = "inverter"
TYPE_STORAGE = "storage"
TYPE_METER = "meter"
TYPE_POWER_FLOW = "power_flow"
SCOPE_DEVICE = "device"
SCOPE_SYSTEM = "system"
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
DEFAULT_SCOPE = SCOPE_DEVICE
DEFAULT_DEVICE = 0
DEFAULT_INVERTER = 1
DEFAULT_SCAN_INTERVAL = timedelta(seconds=60)
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
SENSOR_TYPES = [TYPE_INVERTER, TYPE_STORAGE, TYPE_METER, TYPE_POWER_FLOW]
SCOPE_TYPES = [SCOPE_DEVICE, SCOPE_SYSTEM]
def _device_id_validator(config):
"""Ensure that inverters have default id 1 and other devices 0."""
config = copy.deepcopy(config)
for cond in config[CONF_MONITORED_CONDITIONS]:
if CONF_DEVICE not in cond:
if cond[CONF_SENSOR_TYPE] == TYPE_INVERTER:
cond[CONF_DEVICE] = DEFAULT_INVERTER
else:
cond[CONF_DEVICE] = DEFAULT_DEVICE
return config
2019-07-31 19:25:30 +00:00
PLATFORM_SCHEMA = vol.Schema(
vol.All(
PLATFORM_SCHEMA.extend(
{
vol.Required(CONF_RESOURCE): cv.url,
vol.Required(CONF_MONITORED_CONDITIONS): vol.All(
cv.ensure_list,
[
{
vol.Required(CONF_SENSOR_TYPE): vol.In(SENSOR_TYPES),
vol.Optional(CONF_SCOPE, default=DEFAULT_SCOPE): vol.In(
SCOPE_TYPES
),
vol.Optional(CONF_DEVICE): vol.All(
vol.Coerce(int), vol.Range(min=0)
),
}
],
),
}
),
_device_id_validator,
)
)
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
"""Set up of Fronius platform."""
session = async_get_clientsession(hass)
fronius = Fronius(session, config[CONF_RESOURCE])
scan_interval = config.get(CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL)
adapters = []
# Creates all adapters for monitored conditions
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
for condition in config[CONF_MONITORED_CONDITIONS]:
device = condition[CONF_DEVICE]
sensor_type = condition[CONF_SENSOR_TYPE]
scope = condition[CONF_SCOPE]
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
name = "Fronius {} {} {}".format(
2019-07-31 19:25:30 +00:00
condition[CONF_SENSOR_TYPE].replace("_", " ").capitalize(),
device if scope == SCOPE_DEVICE else SCOPE_SYSTEM,
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
config[CONF_RESOURCE],
)
if sensor_type == TYPE_INVERTER:
if scope == SCOPE_SYSTEM:
adapter_cls = FroniusInverterSystem
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
else:
adapter_cls = FroniusInverterDevice
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
elif sensor_type == TYPE_METER:
if scope == SCOPE_SYSTEM:
adapter_cls = FroniusMeterSystem
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
else:
adapter_cls = FroniusMeterDevice
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
elif sensor_type == TYPE_POWER_FLOW:
adapter_cls = FroniusPowerFlow
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
else:
adapter_cls = FroniusStorage
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
adapters.append(adapter_cls(fronius, name, device, async_add_entities))
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
# Creates a lamdba that fetches an update when called
def adapter_data_fetcher(data_adapter):
async def fetch_data(*_):
await data_adapter.async_update()
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
return fetch_data
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
# Set up the fetching in a fixed interval for each adapter
for adapter in adapters:
fetch = adapter_data_fetcher(adapter)
# fetch data once at set-up
await fetch()
async_track_time_interval(hass, fetch, scan_interval)
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
class FroniusAdapter:
"""The Fronius sensor fetching component."""
def __init__(self, bridge, name, device, add_entities):
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
"""Initialize the sensor."""
self.bridge = bridge
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
self._name = name
self._device = device
self._fetched = {}
self.sensors = set()
self._registered_sensors = set()
self._add_entities = add_entities
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
@property
def name(self):
"""Return the name of the sensor."""
return self._name
@property
def data(self):
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
"""Return the state attributes."""
return self._fetched
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
async def async_update(self):
"""Retrieve and update latest state."""
values = {}
try:
values = await self._update()
except ConnectionError:
_LOGGER.error("Failed to update: connection error")
except ValueError:
2019-07-31 19:25:30 +00:00
_LOGGER.error(
"Failed to update: invalid response returned."
"Maybe the configured device is not supported"
)
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
if not values:
return
attributes = self._fetched
# Copy data of current fronius device
for key, entry in values.items():
# If the data is directly a sensor
if "value" in entry:
attributes[key] = entry
self._fetched = attributes
# Add discovered value fields as sensors
# because some fields are only sent temporarily
new_sensors = []
for key in attributes:
if key not in self.sensors:
self.sensors.add(key)
_LOGGER.info("Discovered %s, adding as sensor", key)
new_sensors.append(FroniusTemplateSensor(self, key))
self._add_entities(new_sensors, True)
# Schedule an update for all included sensors
for sensor in self._registered_sensors:
sensor.async_schedule_update_ha_state(True)
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
async def _update(self):
"""Return values of interest."""
pass
async def register(self, sensor):
"""Register child sensor for update subscriptions."""
self._registered_sensors.add(sensor)
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
class FroniusInverterSystem(FroniusAdapter):
"""Adapter for the fronius inverter with system scope."""
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
async def _update(self):
"""Get the values for the current state."""
return await self.bridge.current_system_inverter_data()
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
class FroniusInverterDevice(FroniusAdapter):
"""Adapter for the fronius inverter with device scope."""
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
async def _update(self):
"""Get the values for the current state."""
return await self.bridge.current_inverter_data(self._device)
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
class FroniusStorage(FroniusAdapter):
"""Adapter for the fronius battery storage."""
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
async def _update(self):
"""Get the values for the current state."""
return await self.bridge.current_storage_data(self._device)
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
class FroniusMeterSystem(FroniusAdapter):
"""Adapter for the fronius meter with system scope."""
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
async def _update(self):
"""Get the values for the current state."""
return await self.bridge.current_system_meter_data()
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
class FroniusMeterDevice(FroniusAdapter):
"""Adapter for the fronius meter with device scope."""
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
async def _update(self):
"""Get the values for the current state."""
return await self.bridge.current_meter_data(self._device)
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
class FroniusPowerFlow(FroniusAdapter):
"""Adapter for the fronius power flow."""
Fronius (solar energy and inverter) component (#22316) * Introduced fronius component that adds ability to track Fronius devices from Home Assistant * Use device parameter for fetching inverter data * Fixed handling of default scope * Handle exceptions from yield * Fulfill PR requirements * Fixed houndci violations * Found the last hound violation * Fixed docstring (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776934) * Fixed import order with isort (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165776957) * CONF_DEVICE is now CONF_DEVICEID (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777161) * Added docstring to class FroniusSensor (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777792) * Fixed docstring for state (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165777885) * Added/fixed docstrings (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778108 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165778125) * Remove redundant log entry (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779213) * Fixed error message if sensor update fails (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779435) * Fixed error log messages (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779751 & https://github.com/home-assistant/home-assistant/pull/11446#discussion_r165779761) * Satisfy hound * Handle exceptions explicit (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940902) * Removed unnecessary call of update (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168940894) * The point makes the difference. * Removed unrelated requirements * Remove config logging (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968748) * Reorder and fix imports (https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968725, https://github.com/home-assistant/home-assistant/pull/11446#discussion_r168968691) * Update fronius requirement * Various small fixes * Small fixes * Formatting * Add fronius to coverage * New structure and formatting * Add manifest.json * Fix data loading * Make pylint happy * Fix issues * Fix parse_attributes * Fix docstring and platform schema * Make use of default HA-Const config values * Change configuration setup, introducing list of monitored conditions * Change the structure slightly, allowing for a list of sensors * Remove periods from logging * Formatting * Change name generation, use variable instead of string * small fixes * Update sensor.py * Incorporate correction proposals * Setting default device inside validation * Move import on top and small format * Formatting fix * Rename validation method to _device_id_validator
2019-06-29 03:48:53 +00:00
async def _update(self):
"""Get the values for the current state."""
return await self.bridge.current_power_flow()
class FroniusTemplateSensor(Entity):
"""Sensor for the single values (e.g. pv power, ac power)."""
def __init__(self, parent: FroniusAdapter, name):
"""Initialize a singular value sensor."""
self._name = name
self.parent = parent
self._state = None
self._unit = None
@property
def name(self):
"""Return the name of the sensor."""
return "{} {}".format(
self._name.replace("_", " ").capitalize(), self.parent.name
)
@property
def state(self):
"""Return the current state."""
return self._state
@property
def unit_of_measurement(self):
"""Return the unit of measurement."""
return self._unit
@property
def should_poll(self):
"""Device should not be polled, returns False."""
return False
async def async_update(self):
"""Update the internal state."""
state = self.parent.data.get(self._name)
self._state = state.get("value")
self._unit = state.get("unit")
async def async_added_to_hass(self):
"""Register at parent component for updates."""
await self.parent.register(self)
def __hash__(self):
"""Hash sensor by hashing its name."""
return hash(self.name)