Skip to content

Commit

Permalink
Merge pull request #222 from elad-bar/fix-startup-warning-2025-1
Browse files Browse the repository at this point in the history
fix future incompatibility HA Core 2025.1
  • Loading branch information
kramttocs committed Jan 11, 2024
2 parents d32c2ea + 8c69734 commit 4484cf4
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 20 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 1.0.17

- Fix future incompatibility HA Core 2025.1 [Issue #221](https://github.com/elad-bar/ha-blueiris/issues/221)
- Remove outdated dependency of async_timeout, replace with aihttp.ClientRequest.timeout
- Fix warning for binary sensors when using async_call_later, changed to loop.call_later
- Remove unused parameters

## 1.0.16

- Update ConfigEntry to support HA v2024.1.0b0 and above [Issue #218](https://github.com/elad-bar/ha-blueiris/issues/218)
Expand Down
2 changes: 1 addition & 1 deletion custom_components/blueiris/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
_LOGGER = logging.getLogger(__name__)


async def async_setup(hass, config):
async def async_setup(_hass, _config):
return True


Expand Down
2 changes: 1 addition & 1 deletion custom_components/blueiris/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async def async_setup_entry(hass, config_entry, async_add_devices):
)


async def async_unload_entry(hass, config_entry):
async def async_unload_entry(_hass, config_entry):
_LOGGER.info(f"async_unload_entry {CURRENT_DOMAIN}: {config_entry}")

return True
5 changes: 2 additions & 3 deletions custom_components/blueiris/binary_sensors/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import logging

from homeassistant.components.binary_sensor import STATE_OFF
from homeassistant.helpers.event import async_call_later

from ..helpers.const import *
from .base import BlueIrisBinarySensor
Expand Down Expand Up @@ -32,7 +31,7 @@ def _immediate_update(self, previous_state: bool):
is_trigger_off = self.state == STATE_OFF
current_timestamp = datetime.now().timestamp()

def turn_off_automatically(now):
async def turn_off_automatically(now):
_LOGGER.info(f"Audio alert off | {self.name} @{now}")

self.entity_manager.set_mqtt_state(self.topic, self.event_type, False)
Expand Down Expand Up @@ -64,6 +63,6 @@ def turn_off_automatically(now):
self._last_alert = current_timestamp
super()._immediate_update(previous_state)

async_call_later(self.hass, 2, turn_off_automatically)
self.hass.loop.call_later(self.hass, 2, turn_off_automatically)
else:
_LOGGER.debug(f"Audio alert on, {message} | {self.name}")
32 changes: 24 additions & 8 deletions custom_components/blueiris/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,32 @@
from typing import Optional

import aiohttp
import async_timeout
import voluptuous as vol

from homeassistant.components.camera import SUPPORT_STREAM, Camera
from homeassistant.const import CONF_VERIFY_SSL
from homeassistant.components.camera import (
DOMAIN as DOMAIN_CAMERA,
Camera,
CameraEntityFeature,
)
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, CONF_VERIFY_SSL
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import TemplateError
from homeassistant.helpers import config_validation as cv, entity_platform
from homeassistant.helpers.aiohttp_client import async_get_clientsession

from .helpers.const import *
from .helpers.const import (
BI_CAMERA_ATTR_GROUP_CAMERAS,
CONF_CONTENT_TYPE,
CONF_FRAMERATE,
CONF_LIMIT_REFETCH_TO_URL_CHANGE,
CONF_STILL_IMAGE_URL,
CONF_STREAM_SOURCE,
CONF_SUPPORT_STREAM,
DOMAIN,
NOT_AVAILABLE,
SERVICE_MOVE_TO_PRESET,
SERVICE_TRIGGER_CAMERA,
)
from .models.base_entity import BlueIrisEntity, async_setup_base_entry
from .models.entity_data import EntityData

Expand Down Expand Up @@ -50,7 +65,7 @@ async def async_setup_entry(hass, config_entry, async_add_devices):
)


async def async_unload_entry(hass, config_entry):
async def async_unload_entry(_hass, config_entry):
_LOGGER.info(f"async_unload_entry {CURRENT_DOMAIN}: {config_entry}")

return True
Expand Down Expand Up @@ -78,7 +93,7 @@ def __init__(self, hass, device_info):
stream_support_flag = 0

if stream_source and stream_support:
stream_support_flag = SUPPORT_STREAM
stream_support_flag = CameraEntityFeature.STREAM

self._still_image_url = device_info[CONF_STILL_IMAGE_URL]
self._still_image_url.hass = hass
Expand Down Expand Up @@ -146,8 +161,9 @@ async def async_camera_image(

try:
websession = async_get_clientsession(self.hass, verify_ssl=self.verify_ssl)
with async_timeout.timeout(10):
response = await websession.get(url, auth=self._auth)

response = await websession.get(url, auth=self._auth, timeout=10)

self._last_image = await response.read()
except asyncio.TimeoutError:
_LOGGER.error("Timeout getting camera image from %s", self.name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ def generate(self):

self.generate_ui_lovelace()

@staticmethod
def _generate_lovelace(
self, integration_name, camera_list: list[CameraData], available_profiles
_integration_name, camera_list: list[CameraData], _available_profiles
):
# lovelace_template = LOVELACE_TEMPLATE

Expand Down
2 changes: 1 addition & 1 deletion custom_components/blueiris/managers/config_flow_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ async def update_data(self, data: dict, flow: str):
return self._data

def _get_default_fields(
self, flow, config_data: Optional[ConfigData] = None
self, _flow, config_data: Optional[ConfigData] = None
) -> dict[Marker, Any]:
if config_data is None:
config_data = self.config_data
Expand Down
6 changes: 3 additions & 3 deletions custom_components/blueiris/managers/home_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from homeassistant.core import HomeAssistant
from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.entity_registry import EntityRegistry, async_get
from homeassistant.helpers.event import async_call_later, async_track_time_interval
from homeassistant.helpers.event import async_track_time_interval

from ..api.blue_iris_api import BlueIrisApi
from ..helpers.advanced_configurations_generator import AdvancedConfigurationGenerator
Expand Down Expand Up @@ -157,7 +157,7 @@ async def async_update_entry(self, entry: ConfigEntry = None):

if update_config_manager and integration_data is not None:
if integration_data.generate_configuration_files:
async_call_later(self._hass, 5, self.generate_config_files)
self._hass.loop.call_later(self._hass, 5, self.generate_config_files)

integration_data.generate_configuration_files = False

Expand Down Expand Up @@ -239,5 +239,5 @@ async def dispatch_all(self):

async_dispatcher_send(self._hass, signal)

def generate_config_files(self, now):
async def generate_config_files(self, _now):
self._config_generator.generate()
2 changes: 1 addition & 1 deletion custom_components/blueiris/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"iot_class": "local_polling",
"issue_tracker": "https://github.com/elad-bar/ha-blueiris/issues",
"requirements": [],
"version": "1.0.16"
"version": "1.0.17"
}
2 changes: 1 addition & 1 deletion custom_components/blueiris/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async def async_setup_entry(hass, config_entry, async_add_devices):
)


async def async_unload_entry(hass, config_entry):
async def async_unload_entry(_hass, config_entry):
_LOGGER.info(f"async_unload_entry {CURRENT_DOMAIN}: {config_entry}")

return True
Expand Down

0 comments on commit 4484cf4

Please sign in to comment.