From 757e87322b15bacf9fef75f7d1f155cf2402414b Mon Sep 17 00:00:00 2001 From: BottlecapDave Date: Sat, 29 Jun 2024 08:22:04 +0100 Subject: [PATCH] fix: Fixed warning around use of deprecated HA function (15 minutes dev time) --- .build/createGithubRelease.ts | 12 +++++++++++- custom_components/first_bus/__init__.py | 14 ++++---------- hacs.json | 3 ++- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/.build/createGithubRelease.ts b/.build/createGithubRelease.ts index 90cd56d..18473cd 100644 --- a/.build/createGithubRelease.ts +++ b/.build/createGithubRelease.ts @@ -1,5 +1,14 @@ +import { readFileSync } from 'fs'; +import { join } from 'path'; + const bodySuffix = "---\nEnjoying the integration? Why not make a one time or monthly [GitHub sponsorship](https://github.com/sponsors/bottlecapdave)?" +function getMinimumHomeAssistantVersion() { + const hacsFilePath = join(__dirname, '../hacs.json'); + const buffer = readFileSync(hacsFilePath); + const content = JSON.parse(buffer.toString()); + return content.homeassistant; +} async function createGithubRelease(githubToken: string, githubOwnerRepo: string, tag: string, notes: string) { if (!githubToken) { throw new Error('Github token not specified'); @@ -45,9 +54,10 @@ async function createGithubRelease(githubToken: string, githubOwnerRepo: string, } } +const minimumHAVersionNote = `\n**Minimum HA Version**: ${getMinimumHomeAssistantVersion()}\n\n`; createGithubRelease( process.env.GITHUB_TOKEN, process.env.GITHUB_REPOSITORY, process.argv[2], - `${process.argv[3]}\n${bodySuffix}` + `${process.argv[3]}\n${minimumHAVersionNote}${bodySuffix}` ).then(() => console.log('Success')); \ No newline at end of file diff --git a/custom_components/first_bus/__init__.py b/custom_components/first_bus/__init__.py index 429a406..13d99bb 100644 --- a/custom_components/first_bus/__init__.py +++ b/custom_components/first_bus/__init__.py @@ -1,19 +1,17 @@ -import logging from homeassistant.util.dt import utcnow -import asyncio from .const import ( DOMAIN, ) +PLATFORMS = ["sensor"] + async def async_setup_entry(hass, entry): """This is called from the config flow.""" hass.data.setdefault(DOMAIN, {}) # Forward our entry to setup our default sensors - hass.async_create_task( - hass.config_entries.async_forward_entry_setup(entry, "sensor") - ) + await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) return True @@ -24,10 +22,6 @@ async def options_update_listener(hass, entry): async def async_unload_entry(hass, entry): """Unload a config entry.""" - unload_ok = all( - await asyncio.gather( - *[hass.config_entries.async_forward_entry_unload(entry, "sensor")] - ) - ) + unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS) return unload_ok \ No newline at end of file diff --git a/hacs.json b/hacs.json index af96fb4..5f14412 100644 --- a/hacs.json +++ b/hacs.json @@ -1,4 +1,5 @@ { "name": "First Bus", - "render_readme": true + "render_readme": true, + "homeassistant": "2022.8.0" } \ No newline at end of file