From c7fa1ca6d6530d26b6c72e15d0d4396522465858 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Thu, 20 Feb 2025 18:15:36 +0000 Subject: [PATCH] Fix deprecation: import persistent_notification and use it directly See also home-assistant/core#63901. This avoids the below deprecation: ``` Detected that custom integration 'authenticated' accesses hass.components.persistent_notification which should be updated to import functions used from persistent_notification directly at custom_components/authenticated/sensor.py, line XYZ: hass.components.persistent_notification.create( This will stop working in Home Assistant 2025.3, please report it to the author of the 'authenticated' custom integration ``` --- custom_components/authenticated/sensor.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/custom_components/authenticated/sensor.py b/custom_components/authenticated/sensor.py index 8dc0eac..705f91d 100644 --- a/custom_components/authenticated/sensor.py +++ b/custom_components/authenticated/sensor.py @@ -16,6 +16,7 @@ import homeassistant.helpers.config_validation as cv import voluptuous as vol import yaml +from homeassistant.components import persistent_notification from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.helpers.entity import Entity @@ -459,7 +460,7 @@ def lookup(self): def notify(self, hass): """Create persistant notification.""" - notify = hass.components.persistent_notification.create + notify = persistent_notification.create message = f""" **IP Address:** {self.ip_address} **Username:** {self.username} @@ -479,4 +480,4 @@ def notify(self, hass): if self.last_used_at is not None: message += f"**Login time:** {self.last_used_at[:19].replace('T', ' ')}" - notify(message, title="New successful login", notification_id=self.ip_address) + notify(hass, message, title="New successful login", notification_id=self.ip_address)