diff --git a/LICENSE b/LICENSE index cd61917..be8ae69 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020 FL550 +Copyright (c) 2020 @FL550 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 1d56b27..c669922 100644 --- a/README.md +++ b/README.md @@ -1,144 +1,30 @@ # Notice -The component and platforms in this repository are not meant to be used by a -user, but as a "blueprint" that custom component developers can build -upon, to make more awesome stuff. - This blueprint uses ['sampleclient'](https://github.com/ludeeus/sampleclient) to simulate what you actually might use in your integration. -HAVE FUN! 😎 - -## Why? - -This is simple, by having custom_components look (README + structure) the same -it is easier for developers to help each other and for users to start using them. - -If you are a developer and you want to add things to this "blueprint" that you think more -developers will have use for, please open a PR to add it :) - -## What? - -This repository contains multiple files, here is a overview: - -File | Purpose --- | -- -`.devcontainer/*` | Used for development/testing with VSCODE, more info in the readme file in that dir. -`.github/ISSUE_TEMPLATE/feature_request.md` | Template for Feature Requests -`.github/ISSUE_TEMPLATE/issue.md` | Template for issues -`.github/settings.yml` | Probot settings to control the repository settings. -`.vscode/tasks.json` | Tasks for the devcontainer. -`custom_components/blueprint/.translations/*` | [Translation files.](https://developers.home-assistant.io/docs/en/next/internationalization_custom_component_localization.html#translation-strings) -`custom_components/blueprint/__init__.py` | The component file for the integration. -`custom_components/blueprint/binary_sensor.py` | Binary sensor platform for the integration. -`custom_components/blueprint/config_flow.py` | Config flow file, this adds the UI configuration possibilities. -`custom_components/blueprint/const.py` | A file to hold shared variables/constants for the entire integration. -`custom_components/blueprint/manifest.json` | A [manifest file](https://developers.home-assistant.io/docs/en/creating_integration_manifest.html) for Home Assistant. -`custom_components/blueprint/sensor.py` | Sensor platform for the integration. -`custom_components/blueprint/switch.py` | Switch sensor platform for the integration. -`CONTRIBUTING.md` | Guidelines on how to contribute. -`example.png` | Screenshot that demonstrate how it might look in the UI. -`info.md` | An example on a info file (used by [hacs][hacs]). -`LICENSE` | The license file for the project. -`README.md` | The file you are reading now, should contain info about the integration, installation and configuration instructions. -`requirements.txt` | Python packages used by this integration. - -## How? - -If you want to use all the potential and features of this blueprint tempalte you -should use Visual Studio Code to develop in a container. In this container you -will have all the tools to ease your python development and a dedicated Home -Assistant core instance to run your integration. See `.devcontainer/README.md` for more information. - -If you need to work on the python library in parallel of this integration -(`sampleclient` in this example) there are different options. The following one seems -easy to implement: - -- Create a dedicated branch for your python library on a public git repository (example: branch -`dev` on `https://github.com/ludeeus/sampleclient`) -- Update in the `manifest.json` file the `requirements` key to point on your development branch -( example: `"requirements": ["git+https://github.com/ludeeus/sampleclient.git@dev#devp==0.0.1beta1"]`) -- Each time you need to make a modification to your python library, push it to your -development branch and increase the number of the python library version in `manifest.json` file -to ensure Home Assistant update the code of the python library. (example `"requirements": ["git+https://...==0.0.1beta2"]`). - - -*** -README content if this was a published component: -*** - -# blueprint - -[![GitHub Release][releases-shield]][releases] -[![GitHub Activity][commits-shield]][commits] + [![License][license-shield]](LICENSE) - -[![hacs][hacsbadge]][hacs] -![Project Maintenance][maintenance-shield] -[![BuyMeCoffee][buymecoffeebadge]][buymecoffee] - -[![Discord][discord-shield]][discord] -[![Community Forum][forum-shield]][forum] - -_Component to integrate with [blueprint][blueprint]._ - -**This component will set up the following platforms.** - -Platform | Description --- | -- -`binary_sensor` | Show something `True` or `False`. -`sensor` | Show info from blueprint API. -`switch` | Switch something `True` or `False`. - -![example][exampleimg] +[![hacs][hacsbadge]](hacs) + ## Installation -1. Using the tool of choice open the directory (folder) for your HA configuration (where you find `configuration.yaml`). -2. If you do not have a `custom_components` directory (folder) there, you need to create it. -3. In the `custom_components` directory (folder) create a new folder called `blueprint`. -4. Download _all_ the files from the `custom_components/blueprint/` directory (folder) in this repository. -5. Place the files you downloaded in the new directory (folder) you created. -6. Restart Home Assistant -7. In the HA UI go to "Configuration" -> "Integrations" click "+" and search for "Blueprint" - -Using your HA configuration directory (folder) as a starting point you should now also have this: - -```text -custom_components/blueprint/.translations/en.json -custom_components/blueprint/.translations/nb.json -custom_components/blueprint/.translations/sensor.nb.json -custom_components/blueprint/__init__.py -custom_components/blueprint/binary_sensor.py -custom_components/blueprint/config_flow.py -custom_components/blueprint/const.py -custom_components/blueprint/manifest.json -custom_components/blueprint/sensor.py -custom_components/blueprint/switch.py -``` +1. Click install. +1. In the HA UI go to "Configuration" -> "Integrations" click "+" and search for "Deutscher Wetterdienst". +1. Change the coordinates to your needs or insert a station_id directly. This will override the search for the nearest station. ## Configuration is done in the UI +station_ids can be found [here](https://github.com/FL550/simple_dwd_weatherforecast/blob/master/simple_dwd_weatherforecast/stations.py) if needed. For further infos about the usage and reporting issuesplease visit GITHUB + -## Contributions are welcome! - -If you want to contribute to this please read the [Contribution guidelines](CONTRIBUTING.md) - *** -[blueprint]: https://github.com/custom-components/blueprint -[buymecoffee]: https://www.buymeacoffee.com/ludeeus -[buymecoffeebadge]: https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg?style=for-the-badge -[commits-shield]: https://img.shields.io/github/commit-activity/y/custom-components/blueprint.svg?style=for-the-badge -[commits]: https://github.com/custom-components/blueprint/commits/master [hacs]: https://github.com/custom-components/hacs [hacsbadge]: https://img.shields.io/badge/HACS-Custom-orange.svg?style=for-the-badge -[discord]: https://discord.gg/Qa5fW2R -[discord-shield]: https://img.shields.io/discord/330944238910963714.svg?style=for-the-badge -[exampleimg]: example.png -[forum-shield]: https://img.shields.io/badge/community-forum-brightgreen.svg?style=for-the-badge -[forum]: https://community.home-assistant.io/ + + [license-shield]: https://img.shields.io/github/license/custom-components/blueprint.svg?style=for-the-badge -[maintenance-shield]: https://img.shields.io/badge/maintainer-Joakim%20Sørensen%20%40ludeeus-blue.svg?style=for-the-badge [releases-shield]: https://img.shields.io/github/release/custom-components/blueprint.svg?style=for-the-badge -[releases]: https://github.com/custom-components/blueprint/releases + diff --git a/custom_components/dwd_weather/config_flow.py b/custom_components/dwd_weather/config_flow.py index a811a62..48d848e 100644 --- a/custom_components/dwd_weather/config_flow.py +++ b/custom_components/dwd_weather/config_flow.py @@ -4,10 +4,10 @@ import voluptuous as vol from homeassistant import config_entries, core, exceptions -from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME +from homeassistant.const import CONF_NAME from homeassistant.helpers import config_validation as cv -from .const import DOMAIN +from .const import DOMAIN, CONF_LATITUDE, CONF_LONGITUDE, CONF_STATION_ID from .connector import DWDWeatherData @@ -62,6 +62,8 @@ async def async_step_user(self, user_input=None): cv.latitude, vol.Required(CONF_LONGITUDE, default=self.hass.config.longitude): cv.longitude, + vol.Optional(CONF_STATION_ID): + str, },) return self.async_show_form(step_id="user", diff --git a/custom_components/dwd_weather/const.py b/custom_components/dwd_weather/const.py index 1a72cba..df1e4ce 100644 --- a/custom_components/dwd_weather/const.py +++ b/custom_components/dwd_weather/const.py @@ -12,3 +12,7 @@ DWDWEATHER_COORDINATOR = "dwd_weather_coordinator" DWDWEATHER_MONITORED_CONDITIONS = "dwd_weather_monitored_conditions" DWDWEATHER_NAME = "dwd_weather_name" + +CONF_LATITUDE = "latitude" +CONF_LONGITUDE = "longitude" +CONF_STATION_ID = "station_id" diff --git a/custom_components/dwd_weather/manifest.json b/custom_components/dwd_weather/manifest.json index 83c3018..1777fca 100644 --- a/custom_components/dwd_weather/manifest.json +++ b/custom_components/dwd_weather/manifest.json @@ -1,7 +1,8 @@ { "domain": "dwd_weather", - "name": "DWD Weather", + "name": "Deutscher Wetterdienst (DWD)", "documentation": "https://github.com/FL550/dwd_weather", + "issue_tracker": "https://github.com/FL550/dwd_weather/issues", "dependencies": [], "config_flow": true, "codeowners": [ diff --git a/custom_components/dwd_weather/strings.json b/custom_components/dwd_weather/strings.json index 197ff47..b6107ec 100644 --- a/custom_components/dwd_weather/strings.json +++ b/custom_components/dwd_weather/strings.json @@ -1,23 +1,24 @@ { - "#TODO": "Check values", "title": "Deutscher Wetterdienst", "config": { "step": { "user": { + "description": "The latitude and longitude will be used to find the closest weather station. If you specify a station id, this will be used and latitude and longitude will be ignored. You can search available station-ids here: https://github.com/FL550/simple_dwd_weatherforecast/blob/master/simple_dwd_weatherforecast/stations.py", + "title": "Deutscher Wetterdienst", + "station_id": "Station ID", "data": { - "host": "[%key:common::config_flow::data::host%]", - "username": "[%key:common::config_flow::data::username%]", - "password": "[%key:common::config_flow::data::password%]" + "latitude": "Latitude", + "longitude": "Longitude", + "station_id": "Station ID" } } }, "error": { "cannot_connect": "[%key:common::config_flow::error::cannot_connect%]", - "invalid_auth": "[%key:common::config_flow::error::invalid_auth%]", "unknown": "[%key:common::config_flow::error::unknown%]" }, "abort": { "already_configured": "[%key:common::config_flow::abort::already_configured_device%]" } } -} \ No newline at end of file +} diff --git a/custom_components/dwd_weather/translations/en.json b/custom_components/dwd_weather/translations/en.json index a2b4f4d..b6107ec 100644 --- a/custom_components/dwd_weather/translations/en.json +++ b/custom_components/dwd_weather/translations/en.json @@ -1,22 +1,24 @@ { - "config": { - "abort": { - "already_configured": "[%key:common::config_flow::abort::already_configured_device%]" - }, - "error": { - "cannot_connect": "[%key:common::config_flow::error::cannot_connect%]", - "invalid_auth": "[%key:common::config_flow::error::invalid_auth%]", - "unknown": "[%key:common::config_flow::error::unknown%]" - }, - "step": { - "user": { - "data": { - "host": "[%key:common::config_flow::data::host%]", - "password": "[%key:common::config_flow::data::password%]", - "username": "[%key:common::config_flow::data::username%]" - } - } + "title": "Deutscher Wetterdienst", + "config": { + "step": { + "user": { + "description": "The latitude and longitude will be used to find the closest weather station. If you specify a station id, this will be used and latitude and longitude will be ignored. You can search available station-ids here: https://github.com/FL550/simple_dwd_weatherforecast/blob/master/simple_dwd_weatherforecast/stations.py", + "title": "Deutscher Wetterdienst", + "station_id": "Station ID", + "data": { + "latitude": "Latitude", + "longitude": "Longitude", + "station_id": "Station ID" } + } }, - "title": "Deutscher Wetterdienst" -} \ No newline at end of file + "error": { + "cannot_connect": "[%key:common::config_flow::error::cannot_connect%]", + "unknown": "[%key:common::config_flow::error::unknown%]" + }, + "abort": { + "already_configured": "[%key:common::config_flow::abort::already_configured_device%]" + } + } +} diff --git a/hacs.json b/hacs.json index 672c49a..5afc198 100644 --- a/hacs.json +++ b/hacs.json @@ -4,5 +4,5 @@ "weather" ], "iot_class": "Cloud Polling", - "render_readme": true + "render_readme": false } \ No newline at end of file diff --git a/info.md b/info.md index 4a097f5..09dd611 100644 --- a/info.md +++ b/info.md @@ -1,54 +1,33 @@ -[![GitHub Release][releases-shield]][releases] -[![GitHub Activity][commits-shield]][commits] + [![License][license-shield]](LICENSE) - [![hacs][hacsbadge]](hacs) -![Project Maintenance][maintenance-shield] -[![BuyMeCoffee][buymecoffeebadge]][buymecoffee] - -[![Discord][discord-shield]][discord] -[![Community Forum][forum-shield]][forum] - -_Component to integrate with [blueprint][blueprint]._ - -**This component will set up the following platforms.** + -Platform | Description --- | -- -`binary_sensor` | Show something `True` or `False`. -`sensor` | Show info from blueprint API. -`switch` | Switch something `True` or `False`. - -![example][exampleimg] +{% if prerelease %} +### NB!: This is a Beta version! Please report any errors and bugs! +{% endif %} {% if not installed %} ## Installation 1. Click install. -1. In the HA UI go to "Configuration" -> "Integrations" click "+" and search for "Blueprint". +1. In the HA UI go to "Configuration" -> "Integrations" click "+" and search for "Deutscher Wetterdienst". +1. Change the coordinates to your needs or insert a station_id directly. This will override the search for the nearest station. {% endif %} - ## Configuration is done in the UI +station_ids can be found [here](https://github.com/FL550/simple_dwd_weatherforecast/blob/master/simple_dwd_weatherforecast/stations.py) if needed. For further infos about the usage and reporting issuesplease visit GITHUB + *** -[blueprint]: https://github.com/custom-components/blueprint -[buymecoffee]: https://www.buymeacoffee.com/ludeeus -[buymecoffeebadge]: https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg?style=for-the-badge -[commits-shield]: https://img.shields.io/github/commit-activity/y/custom-components/blueprint.svg?style=for-the-badge -[commits]: https://github.com/custom-components/blueprint/commits/master [hacs]: https://github.com/custom-components/hacs [hacsbadge]: https://img.shields.io/badge/HACS-Custom-orange.svg?style=for-the-badge -[discord]: https://discord.gg/Qa5fW2R -[discord-shield]: https://img.shields.io/discord/330944238910963714.svg?style=for-the-badge -[exampleimg]: example.png -[forum-shield]: https://img.shields.io/badge/community-forum-brightgreen.svg?style=for-the-badge -[forum]: https://community.home-assistant.io/ + + [license-shield]: https://img.shields.io/github/license/custom-components/blueprint.svg?style=for-the-badge -[maintenance-shield]: https://img.shields.io/badge/maintainer-Joakim%20Sørensen%20%40ludeeus-blue.svg?style=for-the-badge [releases-shield]: https://img.shields.io/github/release/custom-components/blueprint.svg?style=for-the-badge -[releases]: https://github.com/custom-components/blueprint/releases +