From b7275de837af33d94b6506fe88b397694d1d6168 Mon Sep 17 00:00:00 2001 From: indykoning <15870933+indykoning@users.noreply.github.com> Date: Sat, 15 Aug 2020 02:54:10 +0200 Subject: [PATCH] Get more detailed info for growatt_server (#38852) * Get more detailed info including inverter temperature * Bump version to 0.1.1 --- .../components/growatt_server/manifest.json | 2 +- .../components/growatt_server/sensor.py | 61 +++++++++++++------ requirements_all.txt | 2 +- 3 files changed, 44 insertions(+), 21 deletions(-) diff --git a/homeassistant/components/growatt_server/manifest.json b/homeassistant/components/growatt_server/manifest.json index 775ada9076d..d60f91d191c 100644 --- a/homeassistant/components/growatt_server/manifest.json +++ b/homeassistant/components/growatt_server/manifest.json @@ -2,6 +2,6 @@ "domain": "growatt_server", "name": "Growatt", "documentation": "https://www.home-assistant.io/integrations/growatt_server/", - "requirements": ["growattServer==0.0.4"], + "requirements": ["growattServer==0.1.1"], "codeowners": ["@indykoning"] } diff --git a/homeassistant/components/growatt_server/sensor.py b/homeassistant/components/growatt_server/sensor.py index 95d6ffd0ff7..28c068f7e77 100644 --- a/homeassistant/components/growatt_server/sensor.py +++ b/homeassistant/components/growatt_server/sensor.py @@ -16,6 +16,7 @@ from homeassistant.const import ( ENERGY_KILO_WATT_HOUR, FREQUENCY_HERTZ, POWER_WATT, + TEMP_CELSIUS, VOLT, ) import homeassistant.helpers.config_validation as cv @@ -56,77 +57,94 @@ TOTAL_SENSOR_TYPES = { } INVERTER_SENSOR_TYPES = { - "inverter_energy_today": ("Energy today", ENERGY_KILO_WATT_HOUR, "e_today", {},), + "inverter_energy_today": ( + "Energy today", + ENERGY_KILO_WATT_HOUR, + "powerToday", + {"round": 1}, + ), "inverter_energy_total": ( "Lifetime energy output", ENERGY_KILO_WATT_HOUR, - "e_total", - {}, + "powerTotal", + {"round": 1}, ), - "inverter_voltage_input_1": ("Input 1 voltage", VOLT, "vpv1", {}), + "inverter_voltage_input_1": ("Input 1 voltage", VOLT, "vpv1", {"round": 2}), "inverter_amperage_input_1": ( "Input 1 Amperage", ELECTRICAL_CURRENT_AMPERE, "ipv1", - {}, + {"round": 1}, ), "inverter_wattage_input_1": ( "Input 1 Wattage", POWER_WATT, "ppv1", - {"device_class": "power"}, + {"device_class": "power", "round": 1}, ), - "inverter_voltage_input_2": ("Input 2 voltage", VOLT, "vpv2", {}), + "inverter_voltage_input_2": ("Input 2 voltage", VOLT, "vpv2", {"round": 1}), "inverter_amperage_input_2": ( "Input 2 Amperage", ELECTRICAL_CURRENT_AMPERE, "ipv2", - {}, + {"round": 1}, ), "inverter_wattage_input_2": ( "Input 2 Wattage", POWER_WATT, "ppv2", - {"device_class": "power"}, + {"device_class": "power", "round": 1}, ), - "inverter_voltage_input_3": ("Input 3 voltage", VOLT, "vpv3", {}), + "inverter_voltage_input_3": ("Input 3 voltage", VOLT, "vpv3", {"round": 1}), "inverter_amperage_input_3": ( "Input 3 Amperage", ELECTRICAL_CURRENT_AMPERE, "ipv3", - {}, + {"round": 1}, ), "inverter_wattage_input_3": ( "Input 3 Wattage", POWER_WATT, "ppv3", - {"device_class": "power"}, + {"device_class": "power", "round": 1}, ), "inverter_internal_wattage": ( "Internal wattage", POWER_WATT, "ppv", - {"device_class": "power"}, + {"device_class": "power", "round": 1}, ), - "inverter_reactive_voltage": ("Reactive voltage", VOLT, "vacr", {}), + "inverter_reactive_voltage": ("Reactive voltage", VOLT, "vacr", {"round": 1}), "inverter_inverter_reactive_amperage": ( "Reactive amperage", ELECTRICAL_CURRENT_AMPERE, "iacr", - {}, + {"round": 1}, ), - "inverter_frequency": ("AC frequency", FREQUENCY_HERTZ, "fac", {}), + "inverter_frequency": ("AC frequency", FREQUENCY_HERTZ, "fac", {"round": 1}), "inverter_current_wattage": ( "Output power", POWER_WATT, "pac", - {"device_class": "power"}, + {"device_class": "power", "round": 1}, ), "inverter_current_reactive_wattage": ( "Reactive wattage", POWER_WATT, "pacr", - {"device_class": "power"}, + {"device_class": "power", "round": 1}, + ), + "inverter_ipm_temperature": ( + "Intelligent Power Management temperature", + TEMP_CELSIUS, + "ipmTemperature", + {"device_class": "temperature", "round": 1}, + ), + "inverter_temperature": ( + "Temperature", + TEMP_CELSIUS, + "temperature", + {"device_class": "temperature", "round": 1}, ), } @@ -326,6 +344,11 @@ def setup_platform(hass, config, add_entities, discovery_info=None): elif device["deviceType"] == "storage": probe.plant_id = plant_id sensors = STORAGE_SENSOR_TYPES + else: + _LOGGER.debug( + "Device type %s was found but is not supported right now.", + device["deviceType"], + ) for sensor in sensors: entities.append( @@ -420,7 +443,7 @@ class GrowattData: self.data = total_info elif self.growatt_type == "inverter": inverter_info = self.api.inverter_detail(self.device_id) - self.data = inverter_info["data"] + self.data = inverter_info elif self.growatt_type == "storage": storage_info_detail = self.api.storage_params(self.device_id)[ "storageDetailBean" diff --git a/requirements_all.txt b/requirements_all.txt index 2e4abaedf14..94b48677cbc 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -697,7 +697,7 @@ greenwavereality==0.5.1 griddypower==0.1.0 # homeassistant.components.growatt_server -growattServer==0.0.4 +growattServer==0.1.1 # homeassistant.components.gstreamer gstreamer-player==1.1.2