Skip to content

Commit

Permalink
fix: Fixed warning around use of deprecated HA function (15 minutes d…
Browse files Browse the repository at this point in the history
…ev time)
  • Loading branch information
BottlecapDave committed Jun 29, 2024
1 parent 84b7c77 commit 757e873
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
12 changes: 11 additions & 1 deletion .build/createGithubRelease.ts
Original file line number Diff line number Diff line change
@@ -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');
Expand Down Expand Up @@ -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'));
14 changes: 4 additions & 10 deletions custom_components/first_bus/__init__.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
3 changes: 2 additions & 1 deletion hacs.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "First Bus",
"render_readme": true
"render_readme": true,
"homeassistant": "2022.8.0"
}

0 comments on commit 757e873

Please sign in to comment.