Skip to content

Commit

Permalink
HACS (#2)
Browse files Browse the repository at this point in the history
* initial hacs implementation

* Commit dist

* Commit updated README.md

* delete dist folder content

* Commit updated README.md

* update readme with screenshot

* Commit updated README.md

* update readme with screenshot #2

* Commit updated README.md

* update build action

* Commit updated README.md

* update readme with screenshot #3

* Commit updated README.md

* update readme with screenshot #4

* Commit updated README.md

* update readme with screenshot #5

* Commit updated README.md

* update readme with screenshot #6

* Commit updated README.md

* update readme with screenshot #7

* Commit updated README.md

* update readme with screenshot #8

* Commit updated README.md

* update readme with screenshot #9

* Commit updated README.md

---------

Co-authored-by: chilikla <[email protected]>
  • Loading branch information
chilikla and chilikla authored Oct 7, 2024
1 parent aa1c7e7 commit 663e3ea
Show file tree
Hide file tree
Showing 19 changed files with 381 additions and 557 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ name: Build release

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
Expand All @@ -21,8 +18,8 @@ jobs:
cache: 'npm'
- run: npm ci
- run: npm run rollup
- name: copy sensor files
run: mkdir -p dist/custom_components && mkdir -p dist/custom_components/yerushamayim && cd src/sensor/ && cp __init__.py sensor.py manifest.json ../../dist/custom_components/yerushamayim
# - name: copy sensor files
# run: mkdir -p dist/custom_components && mkdir -p dist/custom_components/yerushamayim && cd src/sensor/ && cp __init__.py sensor.py manifest.json ../../dist/custom_components/yerushamayim
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Commit dist
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Validate

on:
push:

jobs:
validate-hacs-integration:
runs-on: "ubuntu-latest"
steps:
- name: HACS validation
uses: "hacs/action@main"
with:
category: "integration"
validate-hacs-plugin:
runs-on: "ubuntu-latest"
steps:
- name: HACS validation
uses: "hacs/action@main"
with:
category: "plugin"
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
# Yerushamayim
## Unofficial Yerushamayim Home Assistant integration and Lovelace card

### :hammer_and_wrench: Version: v1.0.7
### :hammer_and_wrench: Version: v1.0.12-hacs.7
<br/>
![screenshot](../screenshot.png?raw=true)

### Instructions
- Add this repo to HACS' Custom repositories: `https://github.com/chilikla/yerushamayim`
- Restart Home Assistant
- Add card to your dashboard

### Old Instructions
- Copy `dist/custom_components/yerushamayim` folder to your `custom_components` Home Assistant folder
- Restart Home Assistant
- Add to your configuration yaml:
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,72 +1,72 @@
"""Config flow for Yerushamayim integration."""
from __future__ import annotations

from typing import Any

import voluptuous as vol

from homeassistant import config_entries
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from homeassistant.exceptions import HomeAssistantError

from .const import DOMAIN

STEP_USER_DATA_SCHEMA = vol.Schema({})

async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str, Any]:
"""Validate the user input allows us to connect."""
# TODO: Validate the data can be used to set up a connection.

# If your PyPI package is not built with async, pass your methods
# to the executor:
# await hass.async_add_executor_job(
# your_validate_func, data["username"], data["password"]
# )

# If you cannot connect:
# throw CannotConnect

# If the authentication is wrong:
# throw InvalidAuth

# Return info that you want to store in the config entry.
return {"title": "Yerushamayim Weather"}

class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Yerushamayim."""

VERSION = 1

async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
"""Handle the initial step."""
if user_input is None:
return self.async_show_form(
step_id="user", data_schema=STEP_USER_DATA_SCHEMA
)

errors = {}

try:
info = await validate_input(self.hass, user_input)
except CannotConnect:
errors["base"] = "cannot_connect"
except InvalidAuth:
errors["base"] = "invalid_auth"
except Exception: # pylint: disable=broad-except
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:
return self.async_create_entry(title=info["title"], data=user_input)

return self.async_show_form(
step_id="user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors
)

class CannotConnect(HomeAssistantError):
"""Error to indicate we cannot connect."""

class InvalidAuth(HomeAssistantError):
"""Config flow for Yerushamayim integration."""
from __future__ import annotations

from typing import Any

import voluptuous as vol

from homeassistant import config_entries
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from homeassistant.exceptions import HomeAssistantError

from .const import DOMAIN

STEP_USER_DATA_SCHEMA = vol.Schema({})

async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str, Any]:
"""Validate the user input allows us to connect."""
# TODO: Validate the data can be used to set up a connection.

# If your PyPI package is not built with async, pass your methods
# to the executor:
# await hass.async_add_executor_job(
# your_validate_func, data["username"], data["password"]
# )

# If you cannot connect:
# throw CannotConnect

# If the authentication is wrong:
# throw InvalidAuth

# Return info that you want to store in the config entry.
return {"title": "Yerushamayim Weather"}

class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Yerushamayim."""

VERSION = 1

async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
"""Handle the initial step."""
if user_input is None:
return self.async_show_form(
step_id="user", data_schema=STEP_USER_DATA_SCHEMA
)

errors = {}

try:
info = await validate_input(self.hass, user_input)
except CannotConnect:
errors["base"] = "cannot_connect"
except InvalidAuth:
errors["base"] = "invalid_auth"
except Exception: # pylint: disable=broad-except
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:
return self.async_create_entry(title=info["title"], data=user_input)

return self.async_show_form(
step_id="user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors
)

class CannotConnect(HomeAssistantError):
"""Error to indicate we cannot connect."""

class InvalidAuth(HomeAssistantError):
"""Error to indicate there is invalid auth."""
10 changes: 5 additions & 5 deletions src/sensor/const.py → custom_components/yerushamayim/const.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Constants for the Yerushamayim integration."""

DOMAIN = "yerushamayim"
SCAN_INTERVAL = 180
URL = "https://www.02ws.co.il/"
"""Constants for the Yerushamayim integration."""

DOMAIN = "yerushamayim"
SCAN_INTERVAL = 180
URL = "https://www.02ws.co.il/"
API = URL + "coldmeter_service.php?lang=1&json=1&cloth_type=e"
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"domain": "yerushamayim",
"name": "Yerushamayim Weather",
"config_flow": true,
"documentation": "https://github.com/chilikla/yerushamayim",
"requirements": ["beautifulsoup4==4.10.0"],
"ssdp": [],
"zeroconf": [],
"homekit": {},
"dependencies": [],
"after_dependencies": ["rest"],
"codeowners": ["chilikla"],
"iot_class": "cloud_polling",
"version": "0.0.14"
{
"domain": "yerushamayim",
"name": "Yerushamayim Weather",
"config_flow": true,
"documentation": "https://github.com/chilikla/yerushamayim",
"issue_tracker": "https://github.com/chilikla/yerushamayim/issues",
"requirements": ["beautifulsoup4==4.10.0"],
"ssdp": [],
"zeroconf": [],
"homekit": {},
"dependencies": [],
"after_dependencies": ["rest"],
"codeowners": ["chilikla"],
"iot_class": "cloud_polling",
"version": "0.0.14"
}
Loading

0 comments on commit 663e3ea

Please sign in to comment.