Skip to content

Commit

Permalink
Adjustments to HA v2021.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
elad-bar committed Sep 2, 2021
1 parent 80922a4 commit 119a5b1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
5 changes: 3 additions & 2 deletions custom_components/shinobi/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from abc import ABC
import asyncio
import logging
from typing import Optional

import aiohttp
import async_timeout
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion custom_components/shinobi/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"codeowners": ["@elad-bar"],
"requirements": [ ],
"config_flow": true,
"version": "1.1.7",
"version": "1.1.8",
"iot_class": "local_polling"
}
3 changes: 2 additions & 1 deletion custom_components/shinobi/models/base_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 119a5b1

Please sign in to comment.