From 192b6d3de8cd00e0d30a4a7ced2f02375a8bdf07 Mon Sep 17 00:00:00 2001 From: magico13 Date: Fri, 3 Sep 2021 19:48:58 -0400 Subject: [PATCH] Only main and balance can be negative. Update sensor names to drop Power. Require HA 2021.9. --- custom_components/emporia_vue/__init__.py | 6 +++--- custom_components/emporia_vue/manifest.json | 3 ++- custom_components/emporia_vue/sensor.py | 4 ++-- hacs.json | 5 +++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/custom_components/emporia_vue/__init__.py b/custom_components/emporia_vue/__init__.py index a92dd0f..a951266 100644 --- a/custom_components/emporia_vue/__init__.py +++ b/custom_components/emporia_vue/__init__.py @@ -327,9 +327,9 @@ def make_channel_id(channel, scale): def fix_usage_sign(channel_num, usage): - """If the channel is MainsToGrid we need it to be positive (see https://github.com/magico13/ha-emporia-vue/issues/57)""" - if usage and channel_num == "MainsToGrid": - return -1 * usage + """If the channel is not '1,2,3' or 'Balance' we need it to be positive (see https://github.com/magico13/ha-emporia-vue/issues/57)""" + if usage and channel_num not in ["1,2,3", "Balance"]: + return abs(usage) elif not usage: usage = 0 return usage diff --git a/custom_components/emporia_vue/manifest.json b/custom_components/emporia_vue/manifest.json index 1783cdc..360a318 100644 --- a/custom_components/emporia_vue/manifest.json +++ b/custom_components/emporia_vue/manifest.json @@ -9,5 +9,6 @@ "homekit": {}, "dependencies": [], "codeowners": ["@magico13"], - "version": "0.6.6" + "iot_class": "cloud_polling", + "version": "0.7.0" } diff --git a/custom_components/emporia_vue/sensor.py b/custom_components/emporia_vue/sensor.py index 11250ec..6794ea4 100644 --- a/custom_components/emporia_vue/sensor.py +++ b/custom_components/emporia_vue/sensor.py @@ -74,9 +74,9 @@ def __init__(self, coordinator, id): f"No channel found for device_gid {device_gid} and channel_num {channel_num}" ) dName = self._device.device_name - if self._channel.name and self._channel.name != "Main": + if self._channel.name and self._channel.name not in ["Main", "Balance"]: dName = self._channel.name - self._name = f"Power {dName} {channel_num} {self._scale}" + self._name = f"{dName} {channel_num} {self._scale}" self._iskwh = self.scale_is_energy() @property diff --git a/hacs.json b/hacs.json index d9b372b..389d5e1 100644 --- a/hacs.json +++ b/hacs.json @@ -1,5 +1,6 @@ { - "name": "Emporia Vue Integration", + "name": "Emporia Vue", "domains": ["sensor", "switch"], - "iot_class": "Cloud Polling" + "iot_class": "Cloud Polling", + "homeassistant": "2021.9.0" } \ No newline at end of file