Skip to content

Commit

Permalink
Merge pull request #9 from BottlecapDave/develop
Browse files Browse the repository at this point in the history
New release
  • Loading branch information
BottlecapDave authored Jun 29, 2024
2 parents c6a3233 + b6e458b commit 87e132e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 16 deletions.
13 changes: 12 additions & 1 deletion .build/createGithubRelease.ts
Original file line number Diff line number Diff line change
@@ -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');
Expand Down Expand Up @@ -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'));
19 changes: 19 additions & 0 deletions _docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<config directory>/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.
Expand Down
19 changes: 5 additions & 14 deletions custom_components/harvest_time_tracker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, {})
Expand All @@ -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))

Expand Down Expand Up @@ -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
3 changes: 2 additions & 1 deletion hacs.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "Harvest Time Tracker",
"render_readme": true
"render_readme": true,
"homeassistant": "2023.5.0"
}

0 comments on commit 87e132e

Please sign in to comment.