From 119a5b1ec54d8e9a340736213efe2aad5d3c88cf Mon Sep 17 00:00:00 2001 From: Bar Date: Thu, 2 Sep 2021 22:45:38 +0300 Subject: [PATCH] Adjustments to HA v2021.9.0 --- CHANGELOG.md | 6 ++++++ custom_components/shinobi/camera.py | 5 +++-- custom_components/shinobi/manifest.json | 2 +- custom_components/shinobi/models/base_entity.py | 3 ++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a80ee08..a4aa060 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,10 @@ # Changelog + +## 1.1.8 + +- Support HA v2021.9.0 breaking change - `Camera` component +- Support `SensorEntity` instead of `Entity` + ## 1.1.7 - Path parameter causing issues for WebSocket (add protection in case virtual path is `/`) [#14](https://github.com/elad-bar/ha-shinobi/issues/14) diff --git a/custom_components/shinobi/camera.py b/custom_components/shinobi/camera.py index a49863d..7335467 100644 --- a/custom_components/shinobi/camera.py +++ b/custom_components/shinobi/camera.py @@ -6,6 +6,7 @@ from abc import ABC import asyncio import logging +from typing import Optional import aiohttp import async_timeout @@ -106,13 +107,13 @@ def frame_interval(self): """Return the interval between frames of the mjpeg stream.""" return self._frame_interval - def camera_image(self): + def camera_image(self, width: Optional[int] = None, height: Optional[int] = None) -> Optional[bytes]: """Return bytes of camera image.""" return asyncio.run_coroutine_threadsafe( self.async_camera_image(), self.hass.loop ).result() - async def async_camera_image(self): + async def async_camera_image(self, width: Optional[int] = None, height: Optional[int] = None) -> Optional[bytes]: """Return a still image response from the camera.""" try: url = self._still_image_url.async_render() diff --git a/custom_components/shinobi/manifest.json b/custom_components/shinobi/manifest.json index b3001d9..518fe0f 100644 --- a/custom_components/shinobi/manifest.json +++ b/custom_components/shinobi/manifest.json @@ -10,6 +10,6 @@ "codeowners": ["@elad-bar"], "requirements": [ ], "config_flow": true, - "version": "1.1.7", + "version": "1.1.8", "iot_class": "local_polling" } diff --git a/custom_components/shinobi/models/base_entity.py b/custom_components/shinobi/models/base_entity.py index a935803..a382477 100644 --- a/custom_components/shinobi/models/base_entity.py +++ b/custom_components/shinobi/models/base_entity.py @@ -2,6 +2,7 @@ import sys from typing import Any, Callable, Optional +from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -40,7 +41,7 @@ async def async_setup_base_entry( _LOGGER.error(f"Failed to load {domain}, error: {ex}, line: {line_number}") -class BaseEntity(Entity): +class BaseEntity(SensorEntity): """Representation a binary sensor that is updated by Shinobi Video.""" hass: HomeAssistant = None