From 61e4a6be1847127822174621d9cc56de2a212981 Mon Sep 17 00:00:00 2001 From: Joe Trabulsy Date: Sat, 2 Mar 2019 05:57:10 -0500 Subject: [PATCH] Update for new pyvesyncv_v2 library and vesync switch support (#21449) * Change dependency to pyvesync-v2 for vesync switch * Update requirements_all.txt * Update Version - Wall Switch Support Update required version for vesync outlets and switches. Eliminate API call for energy usage for wall switches that do not have that feature * fix name convention --- homeassistant/components/switch/vesync.py | 9 +++++---- requirements_all.txt | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/switch/vesync.py b/homeassistant/components/switch/vesync.py index 382096ad5e4..d9ffbf9c12d 100644 --- a/homeassistant/components/switch/vesync.py +++ b/homeassistant/components/switch/vesync.py @@ -11,7 +11,7 @@ from homeassistant.const import (CONF_USERNAME, CONF_PASSWORD) import homeassistant.helpers.config_validation as cv -REQUIREMENTS = ['pyvesync==0.1.1'] +REQUIREMENTS = ['pyvesync_v2==0.9.6'] _LOGGER = logging.getLogger(__name__) @@ -23,7 +23,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the VeSync switch platform.""" - from pyvesync.vesync import VeSync + from pyvesync_v2.vesync import VeSync switches = [] @@ -104,5 +104,6 @@ class VeSyncSwitchHA(SwitchDevice): def update(self): """Handle data changes for node values.""" self.smartplug.update() - self._current_power_w = self.smartplug.get_power() - self._today_energy_kwh = self.smartplug.get_kwh_today() + if self.smartplug.devtype == 'outlet': + self._current_power_w = self.smartplug.get_power() + self._today_energy_kwh = self.smartplug.get_kwh_today() diff --git a/requirements_all.txt b/requirements_all.txt index 2ef12c7f7be..8ae7c543653 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1439,7 +1439,7 @@ pyuptimerobot==0.0.5 pyvera==0.2.45 # homeassistant.components.switch.vesync -pyvesync==0.1.1 +pyvesync_v2==0.9.6 # homeassistant.components.media_player.vizio pyvizio==0.0.4