-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
Showing
19 changed files
with
381 additions
and
557 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
142 changes: 71 additions & 71 deletions
142
src/sensor/config_flow.py → ...om_components/yerushamayim/config_flow.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
10
src/sensor/const.py → custom_components/yerushamayim/const.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
29 changes: 15 additions & 14 deletions
29
src/sensor/manifest.json → custom_components/yerushamayim/manifest.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
Oops, something went wrong.