From f74e976be1a46dc379025914d9b0335c8dd8dae2 Mon Sep 17 00:00:00 2001 From: Kevin Fronczak Date: Wed, 17 Oct 2018 02:38:03 -0400 Subject: [PATCH] Blink update - fixes #17316 (#17538) * Updgrae blinkpy to 0.10.0 - Remove status sensor (API endpoint unreliable for this) - Wifi strength reports in wifi bars rather than dBm (result of new API endpoint) - Added unique ids based on serial number * Update requirements --- .../components/alarm_control_panel/blink.py | 12 +++++++++--- homeassistant/components/binary_sensor/blink.py | 1 + homeassistant/components/blink/__init__.py | 6 ++---- homeassistant/components/camera/blink.py | 8 +++++++- homeassistant/components/sensor/blink.py | 6 ++++++ requirements_all.txt | 2 +- 6 files changed, 26 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/alarm_control_panel/blink.py b/homeassistant/components/alarm_control_panel/blink.py index 850ac52fda4..728b5967db1 100644 --- a/homeassistant/components/alarm_control_panel/blink.py +++ b/homeassistant/components/alarm_control_panel/blink.py @@ -43,6 +43,11 @@ class BlinkSyncModule(AlarmControlPanel): self._name = name self._state = None + @property + def unique_id(self): + """Return the unique id for the sync module.""" + return self.sync.serial + @property def icon(self): """Return icon.""" @@ -61,9 +66,10 @@ class BlinkSyncModule(AlarmControlPanel): @property def device_state_attributes(self): """Return the state attributes.""" - return { - ATTR_ATTRIBUTION: DEFAULT_ATTRIBUTION, - } + attr = self.sync.attributes + attr['network_info'] = self.data.networks + attr[ATTR_ATTRIBUTION] = DEFAULT_ATTRIBUTION + return attr def update(self): """Update the state of the device.""" diff --git a/homeassistant/components/binary_sensor/blink.py b/homeassistant/components/binary_sensor/blink.py index 6519d09a29a..46751ce5394 100644 --- a/homeassistant/components/binary_sensor/blink.py +++ b/homeassistant/components/binary_sensor/blink.py @@ -36,6 +36,7 @@ class BlinkBinarySensor(BinarySensorDevice): self._icon = icon self._camera = data.sync.cameras[camera] self._state = None + self._unique_id = "{}-{}".format(self._camera.serial, self._type) @property def name(self): diff --git a/homeassistant/components/blink/__init__.py b/homeassistant/components/blink/__init__.py index 1d84b5be113..abdbc1a2e92 100644 --- a/homeassistant/components/blink/__init__.py +++ b/homeassistant/components/blink/__init__.py @@ -15,7 +15,7 @@ from homeassistant.const import ( CONF_BINARY_SENSORS, CONF_SENSORS, CONF_FILENAME, CONF_MONITORED_CONDITIONS, TEMP_FAHRENHEIT) -REQUIREMENTS = ['blinkpy==0.9.0'] +REQUIREMENTS = ['blinkpy==0.10.0'] _LOGGER = logging.getLogger(__name__) @@ -36,7 +36,6 @@ TYPE_MOTION_DETECTED = 'motion_detected' TYPE_TEMPERATURE = 'temperature' TYPE_BATTERY = 'battery' TYPE_WIFI_STRENGTH = 'wifi_strength' -TYPE_STATUS = 'status' SERVICE_REFRESH = 'blink_update' SERVICE_TRIGGER = 'trigger_camera' @@ -50,8 +49,7 @@ BINARY_SENSORS = { SENSORS = { TYPE_TEMPERATURE: ['Temperature', TEMP_FAHRENHEIT, 'mdi:thermometer'], TYPE_BATTERY: ['Battery', '%', 'mdi:battery-80'], - TYPE_WIFI_STRENGTH: ['Wifi Signal', 'dBm', 'mdi:wifi-strength-2'], - TYPE_STATUS: ['Status', '', 'mdi:bell'] + TYPE_WIFI_STRENGTH: ['Wifi Signal', 'bars', 'mdi:wifi-strength-2'], } BINARY_SENSOR_SCHEMA = vol.Schema({ diff --git a/homeassistant/components/camera/blink.py b/homeassistant/components/camera/blink.py index 5a728e92ce3..510c2ab2563 100644 --- a/homeassistant/components/camera/blink.py +++ b/homeassistant/components/camera/blink.py @@ -38,6 +38,7 @@ class BlinkCamera(Camera): self.data = data self._name = "{} {}".format(BLINK_DATA, name) self._camera = camera + self._unique_id = "{}-camera".format(camera.serial) self.response = None self.current_image = None self.last_image = None @@ -48,6 +49,11 @@ class BlinkCamera(Camera): """Return the camera name.""" return self._name + @property + def unique_id(self): + """Return the unique camera id.""" + return self._unique_id + @property def device_state_attributes(self): """Return the camera attributes.""" @@ -64,7 +70,7 @@ class BlinkCamera(Camera): @property def motion_detection_enabled(self): """Return the state of the camera.""" - return self._camera.armed + return self._camera.motion_enabled @property def brand(self): diff --git a/homeassistant/components/sensor/blink.py b/homeassistant/components/sensor/blink.py index 885bb939edf..804f83de4fd 100644 --- a/homeassistant/components/sensor/blink.py +++ b/homeassistant/components/sensor/blink.py @@ -43,12 +43,18 @@ class BlinkSensor(Entity): self._state = None self._unit_of_measurement = units self._icon = icon + self._unique_id = "{}-{}".format(self._camera.serial, self._type) @property def name(self): """Return the name of the camera.""" return self._name + @property + def unique_id(self): + """Return the unique id for the camera sensor.""" + return self._unique_id + @property def icon(self): """Return the icon of the sensor.""" diff --git a/requirements_all.txt b/requirements_all.txt index 0f2b3d43fb4..e86a488de51 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -179,7 +179,7 @@ bellows==0.7.0 bimmer_connected==0.5.3 # homeassistant.components.blink -blinkpy==0.9.0 +blinkpy==0.10.0 # homeassistant.components.light.blinksticklight blinkstick==1.1.8