From 4de09f8af7140ea0cb54a2c415dccb95a349506f Mon Sep 17 00:00:00 2001 From: BottlecapDave Date: Wed, 31 Jan 2024 20:56:16 +0000 Subject: [PATCH 1/2] docs: Added installation details --- _docs/index.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/_docs/index.md b/_docs/index.md index fbe7024..3826648 100644 --- a/_docs/index.md +++ b/_docs/index.md @@ -4,6 +4,25 @@ Custom component to allow you to interact with your [Harvest](https://www.gethar This integration is in no way affiliated with Harvest. +## How to install + +There are multiple ways of installing the integration. + +### HACS + +[![hacs_badge](https://img.shields.io/badge/HACS-Default-41BDF5.svg?style=for-the-badge)](https://github.com/hacs/integration) + +This integration can be installed directly via HACS. To install: + +* [Add the repository](https://my.home-assistant.io/redirect/hacs_repository/?owner=BottlecapDave&repository=homeassistant-harvesttimetracker&category=integration) to your HACS installation +* Click `Download` + +### Manual + +You should take the latest [published release](https://github.com/BottlecapDave/HomeAssistant-HarvestTimeTracker/releases). The current state of `develop` will be in flux and therefore possibly subject to change. + +To install, place the contents of `custom_components` into the `/custom_components` folder of your Home Assistant installation. Once installed, don't forget to restart your home assistant instance for the integration to be picked up. + ## How to setup Please follow the [setup guide](./setup.md) to setup your initial account. This will include a few sensors be default depending on your account. From b6e458b14e0613cd4c853661de6a13aa39f5a34a Mon Sep 17 00:00:00 2001 From: BottlecapDave Date: Sat, 29 Jun 2024 08:22:23 +0100 Subject: [PATCH 2/2] fix: Fixed warning around use of deprecated HA function (15 minutes dev time) --- .build/createGithubRelease.ts | 13 ++++++++++++- .../harvest_time_tracker/__init__.py | 19 +++++-------------- hacs.json | 3 ++- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/.build/createGithubRelease.ts b/.build/createGithubRelease.ts index 90cd56d..c8869b2 100644 --- a/.build/createGithubRelease.ts +++ b/.build/createGithubRelease.ts @@ -1,5 +1,15 @@ +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 +55,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/harvest_time_tracker/__init__.py b/custom_components/harvest_time_tracker/__init__.py index 458c264..2f13134 100644 --- a/custom_components/harvest_time_tracker/__init__.py +++ b/custom_components/harvest_time_tracker/__init__.py @@ -20,6 +20,8 @@ _LOGGER = logging.getLogger(__name__) +PLATFORMS = ["sensor", "select"] + async def async_setup_entry(hass, entry): """This is called from the config flow.""" hass.data.setdefault(DOMAIN, {}) @@ -33,13 +35,7 @@ async def async_setup_entry(hass, entry): await async_setup_dependencies(hass, config) # Forward our entry to setup our default sensors - hass.async_create_task( - hass.config_entries.async_forward_entry_setup(entry, "sensor") - ) - - hass.async_create_task( - hass.config_entries.async_forward_entry_setup(entry, "select") - ) + await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) entry.async_on_unload(entry.add_update_listener(options_update_listener)) @@ -71,13 +67,8 @@ async def options_update_listener(hass, entry): async def async_unload_entry(hass, entry): """Unload a config entry.""" + unload_ok = True if CONFIG_MAIN_API_KEY in entry.data: - target_domain = "sensor" - - unload_ok = all( - await asyncio.gather( - *[hass.config_entries.async_forward_entry_unload(entry, target_domain)] - ) - ) + 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 a021bc0..da72a6c 100644 --- a/hacs.json +++ b/hacs.json @@ -1,4 +1,5 @@ { "name": "Harvest Time Tracker", - "render_readme": true + "render_readme": true, + "homeassistant": "2023.5.0" } \ No newline at end of file