meteocat 3.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/ISSUE_TEMPLATE/bug_report.md +8 -2
- package/.github/ISSUE_TEMPLATE/config.yml +7 -0
- package/.github/ISSUE_TEMPLATE/improvement.md +39 -0
- package/.github/ISSUE_TEMPLATE/new_function.md +41 -0
- package/.github/labels.yml +63 -0
- package/.github/workflows/autocloser.yaml +11 -9
- package/.github/workflows/close-on-label.yml +48 -0
- package/.github/workflows/force-sync-labels.yml +18 -0
- package/.github/workflows/sync-gitlab.yml +15 -4
- package/.github/workflows/sync-labels.yml +21 -0
- package/CHANGELOG.md +46 -11
- package/README.md +13 -4
- package/custom_components/meteocat/__init__.py +51 -41
- package/custom_components/meteocat/config_flow.py +52 -3
- package/custom_components/meteocat/const.py +3 -0
- package/custom_components/meteocat/coordinator.py +188 -2
- package/custom_components/meteocat/manifest.json +1 -1
- package/custom_components/meteocat/options_flow.py +61 -3
- package/custom_components/meteocat/sensor.py +297 -246
- package/custom_components/meteocat/strings.json +61 -15
- package/custom_components/meteocat/translations/ca.json +58 -13
- package/custom_components/meteocat/translations/en.json +61 -15
- package/custom_components/meteocat/translations/es.json +61 -15
- package/custom_components/meteocat/version.py +1 -1
- package/hacs.json +1 -1
- package/images/daily_forecast_2_alerts.png +0 -0
- package/package.json +1 -1
- package/pyproject.toml +1 -1
- package/scripts/update_version.sh +6 -0
- package/.github/workflows/close-duplicates.yml +0 -57
|
@@ -6,8 +6,14 @@ labels: bug
|
|
|
6
6
|
assignees: ""
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
**IMPORTANT
|
|
10
|
-
|
|
9
|
+
⚠️ **IMPORTANT:**
|
|
10
|
+
- This template is **only** for reporting bugs, errors, or malfunctions.
|
|
11
|
+
- Do **not** use it for improvements → use the ♻️ Improvement request template.
|
|
12
|
+
- Do **not** use it for new features or new API data → use the 🆕 New function template.
|
|
13
|
+
|
|
14
|
+
❌ The template is mandatory; failure to follow it will result in the issue being **closed without assistance**.
|
|
15
|
+
|
|
16
|
+
Before opening a bug report, please search existing issues (including closed ones) and check the [Wiki - Troubleshooting](https://github.com/figorr/meteocat/wiki/Troubleshooting) page.
|
|
11
17
|
|
|
12
18
|
---
|
|
13
19
|
|
|
@@ -1 +1,8 @@
|
|
|
1
1
|
blank_issues_enabled: false
|
|
2
|
+
contact_links:
|
|
3
|
+
- name: 📖 Wiki - Troubleshooting
|
|
4
|
+
url: https://github.com/figorr/meteocat/wiki/Troubleshooting
|
|
5
|
+
about: Please check the Wiki before opening an issue.
|
|
6
|
+
- name: 💬 Discussions
|
|
7
|
+
url: https://github.com/figorr/meteocat/discussions
|
|
8
|
+
about: Ask questions, share ideas, or get help from the community.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "♻️ Improvement request"
|
|
3
|
+
about: Suggest an improvement or change to the current behavior of the integration
|
|
4
|
+
title: "[Improvement] "
|
|
5
|
+
labels: enhancement
|
|
6
|
+
assignees: ""
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
⚠️ **NOTE:** This template is for improvements or changes to the **current behavior of the integration**.
|
|
10
|
+
|
|
11
|
+
- It is **not** for bugs, errors, or malfunctions → use the 🐞 Bug report template.
|
|
12
|
+
- It is **not** for requesting new features or new API data → use the 🆕 New function template.
|
|
13
|
+
|
|
14
|
+
❌ Any request that does not follow these rules (e.g. bug reports or feature requests submitted here) will be **closed without assistance**.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
### Current behavior
|
|
19
|
+
<!-- Describe the current behavior of the integration. -->
|
|
20
|
+
|
|
21
|
+
### Expected behavior
|
|
22
|
+
<!-- Describe what you would expect instead. -->
|
|
23
|
+
|
|
24
|
+
### Suggested solution
|
|
25
|
+
<!-- If you have an idea of how it could be improved, describe it here. -->
|
|
26
|
+
|
|
27
|
+
### Alternatives considered
|
|
28
|
+
<!-- Mention other approaches you thought about. -->
|
|
29
|
+
|
|
30
|
+
### Additional context
|
|
31
|
+
<!-- Add any other context, screenshots, or examples related to your request. -->
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
### Checklist
|
|
36
|
+
- [ ] I have searched existing issues (including closed ones).
|
|
37
|
+
- [ ] I have checked the [Wiki](https://github.com/figorr/meteocat/wiki).
|
|
38
|
+
- [ ] **I confirm this is not a bug or malfunction, but a request for improvement.**
|
|
39
|
+
- [ ] This request is not a duplicate.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "🆕 New function (API-based)"
|
|
3
|
+
about: Suggest a new function that uses data available from the Meteocat API
|
|
4
|
+
title: "[Function] "
|
|
5
|
+
labels: enhancement
|
|
6
|
+
assignees: ""
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
**IMPORTANT: Please check that the data you are requesting is available in the [Meteocat API Reference](https://apidocs.meteocat.gencat.cat/documentacio/).**
|
|
10
|
+
|
|
11
|
+
⚠️ **NOTE:** This template is for new functions or new API data for the **integration**.
|
|
12
|
+
|
|
13
|
+
- It is **not** for bugs, errors, or malfunctions → use the 🐞 Bug report template.
|
|
14
|
+
- It is **not** for requesting improvements or changes to the current behavior of the integration → use the ♻️ Improvement request template.
|
|
15
|
+
|
|
16
|
+
❌ Any request that does not follow these rules (e.g. bug reports or improvements requests submitted here) will be **closed without assistance**.
|
|
17
|
+
|
|
18
|
+
⚠️ **Note on API limits:** Each additional call to retrieve new or extra resources may cause the monthly API quota to be exhausted earlier than expected.
|
|
19
|
+
Keep in mind that the available limits are relatively low, especially with the basic plan.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
### Describe the function
|
|
24
|
+
<!-- Clear and concise description of the new function you want to add. -->
|
|
25
|
+
|
|
26
|
+
### API endpoint / resource
|
|
27
|
+
<!-- Indicate which API endpoint/resource provides this data. -->
|
|
28
|
+
|
|
29
|
+
### Why is it useful?
|
|
30
|
+
<!-- Explain the value of this function for Home Assistant users. -->
|
|
31
|
+
|
|
32
|
+
### Additional context
|
|
33
|
+
<!-- Add any other context, screenshots, or examples related to your request. -->
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
### Checklist
|
|
38
|
+
- [ ] I have searched existing issues (including closed ones).
|
|
39
|
+
- [ ] I have checked the [Wiki](https://github.com/figorr/meteocat/wiki).
|
|
40
|
+
- [ ] **I have verified that the requested data is available in the [Meteocat API Reference](https://apidocs.meteocat.gencat.cat/documentacio/).**
|
|
41
|
+
- [ ] This request is not a duplicate.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
- name: breaking-change
|
|
2
|
+
color: d73a4a
|
|
3
|
+
description: Indicates a breaking change affecting upgrade or usage.
|
|
4
|
+
|
|
5
|
+
- name: bug
|
|
6
|
+
color: d73a4a
|
|
7
|
+
description: Something isn't working.
|
|
8
|
+
|
|
9
|
+
- name: documentation
|
|
10
|
+
color: 0075ca
|
|
11
|
+
description: Improvements or additions to documentation.
|
|
12
|
+
|
|
13
|
+
- name: duplicate
|
|
14
|
+
color: cfd3d7
|
|
15
|
+
description: This issue or pull request already exists.
|
|
16
|
+
|
|
17
|
+
- name: enhancement
|
|
18
|
+
color: a2eeef
|
|
19
|
+
description: New feature or request.
|
|
20
|
+
|
|
21
|
+
- name: first read
|
|
22
|
+
color: 0052cc
|
|
23
|
+
description: Mandatory reading before opening issues.
|
|
24
|
+
|
|
25
|
+
- name: good first issue
|
|
26
|
+
color: 7057ff
|
|
27
|
+
description: Good for newcomers.
|
|
28
|
+
|
|
29
|
+
- name: help wanted
|
|
30
|
+
color: 008672
|
|
31
|
+
description: Extra attention is needed.
|
|
32
|
+
|
|
33
|
+
- name: invalid
|
|
34
|
+
color: e4e669
|
|
35
|
+
description: This doesn't seem right.
|
|
36
|
+
|
|
37
|
+
- name: logs required
|
|
38
|
+
color: b60205
|
|
39
|
+
description: Logs are required.
|
|
40
|
+
|
|
41
|
+
- name: merged
|
|
42
|
+
color: b337b8
|
|
43
|
+
description: Solution merged.
|
|
44
|
+
|
|
45
|
+
- name: question
|
|
46
|
+
color: d876e3
|
|
47
|
+
description: Further information is requested.
|
|
48
|
+
|
|
49
|
+
- name: solved
|
|
50
|
+
color: 0e8a16
|
|
51
|
+
description: Solved issue.
|
|
52
|
+
|
|
53
|
+
- name: stale
|
|
54
|
+
color: ededed
|
|
55
|
+
description: Marked as stale due to inactivity.
|
|
56
|
+
|
|
57
|
+
- name: wiki
|
|
58
|
+
color: fbca04
|
|
59
|
+
description: Documented at Wiki.
|
|
60
|
+
|
|
61
|
+
- name: wontfix
|
|
62
|
+
color: ffffff
|
|
63
|
+
description: This will not be worked on.
|
|
@@ -3,23 +3,25 @@ name: Autocloser
|
|
|
3
3
|
on:
|
|
4
4
|
issues:
|
|
5
5
|
types: [opened, edited, reopened]
|
|
6
|
-
issue_comment:
|
|
7
|
-
types: [created]
|
|
8
6
|
|
|
9
7
|
jobs:
|
|
10
8
|
autoclose:
|
|
11
9
|
runs-on: ubuntu-latest
|
|
12
10
|
steps:
|
|
13
|
-
- name: Autoclose issues that did not follow
|
|
11
|
+
- name: Autoclose issues that did not follow any template
|
|
14
12
|
uses: roots/issue-closer@v1.1
|
|
15
13
|
with:
|
|
16
14
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
17
15
|
issue-close-message: >
|
|
18
|
-
👋 @${{ github.event.issue.user.login }} this issue was automatically closed because it did not follow the
|
|
19
|
-
[issue template](https://github.com/figorr/meteocat/issues/new/choose).
|
|
16
|
+
👋 @${{ github.event.issue.user.login }} this issue was automatically closed because it did not follow any of the required templates.
|
|
20
17
|
|
|
21
|
-
⚠️ Reminder:
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
⚠️ Reminder:
|
|
19
|
+
- Use the [🐞 Bug report template](https://github.com/figorr/meteocat/issues/new?template=bug_report.md) for errors or malfunctions.
|
|
20
|
+
- Use the [♻️ Improvement request template](https://github.com/figorr/meteocat/issues/new?template=improvement.md) for changes to current behavior.
|
|
21
|
+
- Use the [🆕 New function template](https://github.com/figorr/meteocat/issues/new?template=new_function.md) for API-based new features.
|
|
22
|
+
|
|
23
|
+
The template is mandatory; failure to use it will result in issue closure.
|
|
24
24
|
issue-pattern: >
|
|
25
|
-
(Describe the bug
|
|
25
|
+
(### Describe the bug|### To Reproduce|### Expected behavior|### System details|### Debug Logs|
|
|
26
|
+
I confirm this is not a bug or malfunction, but a request for improvement|
|
|
27
|
+
I have verified that the requested data is available)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
name: Close on labels
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
issues:
|
|
5
|
+
types:
|
|
6
|
+
- labeled
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
close-and-comment:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- name: Filter relevant labels
|
|
13
|
+
if: ${{ contains('wiki,solved,merged,duplicate', github.event.label.name) }}
|
|
14
|
+
id: check
|
|
15
|
+
run: echo "label=${{ github.event.label.name }}" >> $GITHUB_OUTPUT
|
|
16
|
+
|
|
17
|
+
- name: Determine message based on label
|
|
18
|
+
if: ${{ steps.check.outputs.label }}
|
|
19
|
+
id: message
|
|
20
|
+
run: |
|
|
21
|
+
case "${{ github.event.label.name }}" in
|
|
22
|
+
wiki)
|
|
23
|
+
echo "message=👋 This issue is covered in the [Meteocat Wiki](https://github.com/figorr/meteocat/wiki). Please check the documentation there for guidance." >> $GITHUB_OUTPUT
|
|
24
|
+
;;
|
|
25
|
+
solved)
|
|
26
|
+
echo "message=✅ This issue has been solved. Closing now." >> $GITHUB_OUTPUT
|
|
27
|
+
;;
|
|
28
|
+
merged)
|
|
29
|
+
echo "message=🔀 This issue has been merged manually. 'Merged manually in master [commit_hash]'." >> $GITHUB_OUTPUT
|
|
30
|
+
;;
|
|
31
|
+
duplicate)
|
|
32
|
+
echo "message=📄 This issue is marked as a duplicate. 'Closed as duplicate of #<issue_number>'." >> $GITHUB_OUTPUT
|
|
33
|
+
;;
|
|
34
|
+
esac
|
|
35
|
+
|
|
36
|
+
- name: Add comment
|
|
37
|
+
if: ${{ steps.check.outputs.label }}
|
|
38
|
+
uses: peter-evans/create-or-update-comment@v4
|
|
39
|
+
with:
|
|
40
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
41
|
+
issue-number: ${{ github.event.issue.number }}
|
|
42
|
+
body: ${{ steps.message.outputs.message }}
|
|
43
|
+
|
|
44
|
+
- name: Close issue if open
|
|
45
|
+
if: ${{ github.event.issue.state == 'open' && steps.check.outputs.label }}
|
|
46
|
+
uses: peter-evans/close-issue@v2
|
|
47
|
+
with:
|
|
48
|
+
issue-number: ${{ github.event.issue.number }}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
name: Force sync labels
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch: # solo se ejecuta manualmente
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
labels:
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
steps:
|
|
10
|
+
- uses: actions/checkout@v4
|
|
11
|
+
|
|
12
|
+
- name: Force sync GitHub labels
|
|
13
|
+
uses: crazy-max/ghaction-github-labeler@v5
|
|
14
|
+
with:
|
|
15
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
16
|
+
yaml-file: .github/labels.yml
|
|
17
|
+
skip-delete: false # elimina labels que no estén en el YAML
|
|
18
|
+
dry-run: false # aplica cambios realmente
|
|
@@ -33,10 +33,21 @@ jobs:
|
|
|
33
33
|
# Paso 4: Comprobar divergencias en master
|
|
34
34
|
- name: Check for diverging commits
|
|
35
35
|
run: |
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
# Trae todas las ramas del remoto GitLab y crea referencias locales
|
|
37
|
+
git fetch gitlab +refs/heads/*:refs/remotes/gitlab/*
|
|
38
|
+
|
|
39
|
+
# Comprueba que la rama gitlab/master exista
|
|
40
|
+
if git show-ref --verify --quiet refs/remotes/gitlab/master; then
|
|
41
|
+
# Comprueba si GitLab master tiene commits que GitHub no tiene
|
|
42
|
+
if ! git merge-base --is-ancestor gitlab/master master; then
|
|
43
|
+
echo "❌ GitLab master tiene commits que GitHub no tiene. Revisar antes de sincronizar."
|
|
44
|
+
exit 1
|
|
45
|
+
else
|
|
46
|
+
echo "GitLab master está alineado con GitHub master ✅"
|
|
47
|
+
fi
|
|
48
|
+
else
|
|
49
|
+
echo "❌ La rama gitlab/master no se pudo encontrar localmente. Abortando."
|
|
50
|
+
exit 1
|
|
40
51
|
fi
|
|
41
52
|
|
|
42
53
|
# Paso 5: Push de commits y tags a GitLab
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
name: Sync labels
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
paths:
|
|
6
|
+
- .github/labels.yml
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
labels:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
|
|
15
|
+
- name: Sync GitHub labels (safe)
|
|
16
|
+
uses: crazy-max/ghaction-github-labeler@v5
|
|
17
|
+
with:
|
|
18
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
19
|
+
yaml-file: .github/labels.yml
|
|
20
|
+
skip-delete: true # no elimina labels que no estén en el YAML
|
|
21
|
+
dry-run: false # aplica cambios realmente
|
package/CHANGELOG.md
CHANGED
|
@@ -1,23 +1,58 @@
|
|
|
1
|
-
# [3.
|
|
1
|
+
# [3.1.0](https://github.com/figorr/meteocat/compare/v3.0.0...v3.1.0) (2025-09-27)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* fix unknown threshold translation ([6fa7964](https://github.com/figorr/meteocat/commit/6fa79644e3ebbdf9a44826f6071af6009cd2d02d))
|
|
7
|
+
* include Meteocat Card ([513d9ed](https://github.com/figorr/meteocat/commit/513d9ed50fcd9127ac64f0388ed1017db938f378))
|
|
2
8
|
|
|
3
9
|
|
|
4
10
|
### Features
|
|
5
11
|
|
|
6
|
-
*
|
|
12
|
+
* ✨ Add native sunrise and sunset sensors to Meteocat integration ([7bb70c6](https://github.com/figorr/meteocat/commit/7bb70c681c90773275e496f938f455c3688fb4c0))
|
|
13
|
+
|
|
14
|
+
## [3.0.0](https://github.com/figorr/meteocat/compare/v2.3.0...v3.0.0) (2025-09-14)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### ⚠️ BREAKING CHANGES
|
|
18
|
+
|
|
19
|
+
* Version **3.0.0 and later** introduces a **breaking change** in how entities are identified.
|
|
7
20
|
|
|
21
|
+
## ⚠️ What this affects
|
|
22
|
+
- This affects any update **from a version prior to 3.0.0** to **any version 3.x or later**.
|
|
23
|
+
- Entities now use **`town_id`** instead of `region_id` in their `unique_id`.
|
|
24
|
+
- This change allows multiple integration entries that share the same `region_id` but different towns.
|
|
8
25
|
|
|
9
|
-
###
|
|
26
|
+
### ✅ Recommended upgrade procedure
|
|
27
|
+
To avoid issues with duplicated or unavailable entities:
|
|
10
28
|
|
|
11
|
-
|
|
12
|
-
|
|
29
|
+
1. **Uninstall** the existing integration (v2.x).
|
|
30
|
+
2. **Restart** Home Assistant.
|
|
31
|
+
3. **Install v3.0.0 or later** and configure the integration again.
|
|
32
|
+
|
|
33
|
+
### 🚨 If you update directly
|
|
34
|
+
If you update without uninstalling first:
|
|
35
|
+
|
|
36
|
+
- Old entities will remain as **Unavailable**.
|
|
37
|
+
- New entities will be created (sometimes with a suffix like `2`).
|
|
38
|
+
- You may need to manually **remove old entities** and update your automations, dashboards, or scripts to point to the new entities.
|
|
39
|
+
|
|
40
|
+
### 📑 Additional notes
|
|
41
|
+
|
|
42
|
+
- This change affects all entity types, including **sensors, diagnostic sensors, and alerts**.
|
|
43
|
+
- Always backup your **Home Assistant configuration** before performing major upgrades.
|
|
44
|
+
|
|
45
|
+
ℹ️ More details:
|
|
46
|
+
- [README – Breaking changes](https://github.com/figorr/meteocat#-breaking-changes---upgrade-to-3x)
|
|
47
|
+
- [Wiki – Breaking changes](https://github.com/figorr/meteocat/wiki/Breaking-Changes)
|
|
48
|
+
|
|
49
|
+
### Features
|
|
50
|
+
|
|
51
|
+
* change unique_id to use town_id ([3a048ce](https://github.com/figorr/meteocat/commit/3a048ce48a0e1f3ee7642c28bbe7ac6e6e3fc298))
|
|
13
52
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
2. Restart Home Assistant.
|
|
17
|
-
3. Install v3.0.0 and reconfigure the integration.
|
|
53
|
+
### Contributors:
|
|
54
|
+
- [mcasellas](https://github.com/mcasellas) – contributed [c505f27](https://github.com/figorr/meteocat/commit/c505f27) - Improve Catalan translations
|
|
18
55
|
|
|
19
|
-
If you update directly without uninstalling first, old entities will remain as 'unavailable' and new entities will be created (possibly with a suffix like '2').
|
|
20
|
-
In that case, you may need to manually remove the old entities and update your automations or dashboards.
|
|
21
56
|
|
|
22
57
|
## [2.3.0](https://github.com/figorr/meteocat/compare/v2.2.7...v2.3.0) (2025-09-10)
|
|
23
58
|
|
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ This is a personal project.
|
|
|
26
26
|
- [Figorr](https://github.com/figorr)
|
|
27
27
|
|
|
28
28
|
**Contributors:**
|
|
29
|
-
- [mcasellas](https://github.com/mcasellas) – contributed [c505f27](https://github.com/figorr/meteocat/commit/c505f27)
|
|
29
|
+
- [mcasellas](https://github.com/mcasellas) – contributed [c505f27](https://github.com/figorr/meteocat/commit/c505f27) - Improve Catalan translations
|
|
30
30
|
|
|
31
31
|
## ⚠️ Breaking changes - Upgrade to 3.0.0 or later coming from prior versions
|
|
32
32
|
|
|
@@ -40,7 +40,8 @@ Version **3.0.0 and later** introduces a **breaking change** in how entities are
|
|
|
40
40
|
### ✅ Recommended upgrade procedure
|
|
41
41
|
To avoid issues with duplicated or unavailable entities:
|
|
42
42
|
|
|
43
|
-
1. **Uninstall** the existing integration (v2.x)
|
|
43
|
+
1. **Uninstall** the existing integration (v2.x).<br>
|
|
44
|
+
🔗 See [Uninstallation Guide](https://github.com/figorr/meteocat/wiki/Uninstallation) for the proper way of removing prior versions.
|
|
44
45
|
2. **Restart** Home Assistant.
|
|
45
46
|
3. **Install v3.0.0 or later** and configure the integration again.
|
|
46
47
|
|
|
@@ -146,9 +147,9 @@ You can access the Options Menu in two ways, both inside the integration:
|
|
|
146
147
|
|
|
147
148
|

|
|
148
149
|
|
|
149
|
-
Once inside, you will see the following options:
|
|
150
|
+
Once you are inside, you will see the following options:
|
|
150
151
|
|
|
151
|
-

|
|
152
|
+

|
|
152
153
|
|
|
153
154
|
|
|
154
155
|
## Uninstallation
|
|
@@ -161,6 +162,14 @@ To correctly uninstall the integration:
|
|
|
161
162
|
|
|
162
163
|
👉 For detailed steps with screenshots, check the [Uninstallation Guide](https://github.com/figorr/meteocat/wiki/Uninstallation).
|
|
163
164
|
|
|
165
|
+
## Custom Meteocat Card available
|
|
166
|
+
|
|
167
|
+
Meteocat integration has its own weather card.
|
|
168
|
+
|
|
169
|
+
To install the card, please follow the instructions from its own repository, [🎫 Meteocat Card](https://github.com/figorr/meteocat-card).
|
|
170
|
+
|
|
171
|
+

|
|
172
|
+
|
|
164
173
|
# Documentation
|
|
165
174
|
|
|
166
175
|
For more detailed information about:
|
|
@@ -5,6 +5,7 @@ import voluptuous as vol
|
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
import aiofiles
|
|
7
7
|
import json
|
|
8
|
+
import importlib # Para importaciones lazy
|
|
8
9
|
|
|
9
10
|
from homeassistant import core
|
|
10
11
|
from homeassistant.config_entries import ConfigEntry
|
|
@@ -14,24 +15,6 @@ from homeassistant.helpers.entity_platform import async_get_platforms
|
|
|
14
15
|
from homeassistant.helpers import config_validation as cv
|
|
15
16
|
|
|
16
17
|
from .helpers import get_storage_dir
|
|
17
|
-
from .coordinator import (
|
|
18
|
-
MeteocatSensorCoordinator,
|
|
19
|
-
MeteocatStaticSensorCoordinator,
|
|
20
|
-
MeteocatEntityCoordinator,
|
|
21
|
-
MeteocatUviCoordinator,
|
|
22
|
-
MeteocatUviFileCoordinator,
|
|
23
|
-
HourlyForecastCoordinator,
|
|
24
|
-
DailyForecastCoordinator,
|
|
25
|
-
MeteocatConditionCoordinator,
|
|
26
|
-
MeteocatTempForecastCoordinator,
|
|
27
|
-
MeteocatAlertsCoordinator,
|
|
28
|
-
MeteocatAlertsRegionCoordinator,
|
|
29
|
-
MeteocatQuotesCoordinator,
|
|
30
|
-
MeteocatQuotesFileCoordinator,
|
|
31
|
-
MeteocatLightningCoordinator,
|
|
32
|
-
MeteocatLightningFileCoordinator,
|
|
33
|
-
)
|
|
34
|
-
|
|
35
18
|
from meteocatpy.town import MeteocatTown
|
|
36
19
|
from meteocatpy.symbols import MeteocatSymbols
|
|
37
20
|
from meteocatpy.variables import MeteocatVariables
|
|
@@ -41,7 +24,7 @@ from .const import DOMAIN, PLATFORMS
|
|
|
41
24
|
_LOGGER = logging.getLogger(__name__)
|
|
42
25
|
|
|
43
26
|
# Versión
|
|
44
|
-
__version__ = "3.
|
|
27
|
+
__version__ = "3.1.0"
|
|
45
28
|
|
|
46
29
|
# Definir el esquema de configuración CONFIG_SCHEMA
|
|
47
30
|
CONFIG_SCHEMA = vol.Schema(
|
|
@@ -59,6 +42,8 @@ CONFIG_SCHEMA = vol.Schema(
|
|
|
59
42
|
vol.Optional("province_id"): cv.string,
|
|
60
43
|
vol.Optional("region_name"): cv.string,
|
|
61
44
|
vol.Optional("region_id"): cv.string,
|
|
45
|
+
vol.Required("latitude"): cv.latitude,
|
|
46
|
+
vol.Required("longitude"): cv.longitude,
|
|
62
47
|
}
|
|
63
48
|
)
|
|
64
49
|
},
|
|
@@ -119,6 +104,11 @@ async def async_setup(hass: core.HomeAssistant, config: dict) -> bool:
|
|
|
119
104
|
"""Configuración inicial del componente Meteocat."""
|
|
120
105
|
return True
|
|
121
106
|
|
|
107
|
+
def _get_coordinator_module(cls_name: str):
|
|
108
|
+
"""Importa dinámicamente un coordinador para evitar blocking imports."""
|
|
109
|
+
module = importlib.import_module(".coordinator", "custom_components.meteocat")
|
|
110
|
+
return getattr(module, cls_name)
|
|
111
|
+
|
|
122
112
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|
123
113
|
"""Configura una entrada de configuración para Meteocat."""
|
|
124
114
|
_LOGGER.info("Configurando la integración de Meteocat...")
|
|
@@ -129,14 +119,28 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|
|
129
119
|
# Validar campos requeridos
|
|
130
120
|
required_fields = [
|
|
131
121
|
"api_key", "town_name", "town_id", "variable_name",
|
|
132
|
-
"variable_id", "station_name", "station_id", "province_name",
|
|
133
|
-
"province_id", "region_name", "region_id"
|
|
122
|
+
"variable_id", "station_name", "station_id", "province_name",
|
|
123
|
+
"province_id", "region_name", "region_id", "latitude", "longitude"
|
|
134
124
|
]
|
|
135
125
|
missing_fields = [field for field in required_fields if field not in entry_data]
|
|
136
126
|
if missing_fields:
|
|
137
127
|
_LOGGER.error(f"Faltan los siguientes campos en la configuración: {missing_fields}")
|
|
138
128
|
return False
|
|
139
|
-
|
|
129
|
+
|
|
130
|
+
# Validar coordenadas válidas para Cataluña
|
|
131
|
+
latitude = entry_data.get("latitude")
|
|
132
|
+
longitude = entry_data.get("longitude")
|
|
133
|
+
if not (40.5 <= latitude <= 42.5 and 0.1 <= longitude <= 3.3): # Rango aproximado para Cataluña
|
|
134
|
+
_LOGGER.warning(
|
|
135
|
+
"Coordenadas inválidas (latitude: %s, longitude: %s). Usando coordenadas de Barcelona por defecto para MeteocatSunCoordinator.",
|
|
136
|
+
latitude, longitude
|
|
137
|
+
)
|
|
138
|
+
entry_data = {
|
|
139
|
+
**entry_data,
|
|
140
|
+
"latitude": 41.38879,
|
|
141
|
+
"longitude": 2.15899
|
|
142
|
+
}
|
|
143
|
+
|
|
140
144
|
# Crear los assets básicos si faltan
|
|
141
145
|
await ensure_assets_exist(
|
|
142
146
|
hass,
|
|
@@ -150,33 +154,38 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|
|
150
154
|
f"Variable '{entry_data['variable_name']}' (ID: {entry_data['variable_id']}), "
|
|
151
155
|
f"Estación '{entry_data['station_name']}' (ID: {entry_data['station_id']}), "
|
|
152
156
|
f"Provincia '{entry_data['province_name']}' (ID: {entry_data['province_id']}), "
|
|
153
|
-
f"Comarca '{entry_data['region_name']}' (ID: {entry_data['region_id']})
|
|
157
|
+
f"Comarca '{entry_data['region_name']}' (ID: {entry_data['region_id']}), "
|
|
158
|
+
f"Coordenadas: ({entry_data['latitude']}, {entry_data['longitude']})."
|
|
154
159
|
)
|
|
155
160
|
|
|
156
|
-
#
|
|
157
|
-
|
|
158
|
-
("sensor_coordinator", MeteocatSensorCoordinator),
|
|
159
|
-
("static_sensor_coordinator", MeteocatStaticSensorCoordinator),
|
|
160
|
-
("entity_coordinator", MeteocatEntityCoordinator),
|
|
161
|
-
("uvi_coordinator", MeteocatUviCoordinator),
|
|
162
|
-
("uvi_file_coordinator", MeteocatUviFileCoordinator),
|
|
163
|
-
("hourly_forecast_coordinator", HourlyForecastCoordinator),
|
|
164
|
-
("daily_forecast_coordinator", DailyForecastCoordinator),
|
|
165
|
-
("condition_coordinator", MeteocatConditionCoordinator),
|
|
166
|
-
("temp_forecast_coordinator", MeteocatTempForecastCoordinator),
|
|
167
|
-
("alerts_coordinator", MeteocatAlertsCoordinator),
|
|
168
|
-
("alerts_region_coordinator", MeteocatAlertsRegionCoordinator),
|
|
169
|
-
("quotes_coordinator", MeteocatQuotesCoordinator),
|
|
170
|
-
("quotes_file_coordinator", MeteocatQuotesFileCoordinator),
|
|
171
|
-
("lightning_coordinator", MeteocatLightningCoordinator),
|
|
172
|
-
("lightning_file_coordinator", MeteocatLightningFileCoordinator),
|
|
161
|
+
# Lista de coordinadores con sus clases
|
|
162
|
+
coordinator_configs = [
|
|
163
|
+
("sensor_coordinator", "MeteocatSensorCoordinator"),
|
|
164
|
+
("static_sensor_coordinator", "MeteocatStaticSensorCoordinator"),
|
|
165
|
+
("entity_coordinator", "MeteocatEntityCoordinator"),
|
|
166
|
+
("uvi_coordinator", "MeteocatUviCoordinator"),
|
|
167
|
+
("uvi_file_coordinator", "MeteocatUviFileCoordinator"),
|
|
168
|
+
("hourly_forecast_coordinator", "HourlyForecastCoordinator"),
|
|
169
|
+
("daily_forecast_coordinator", "DailyForecastCoordinator"),
|
|
170
|
+
("condition_coordinator", "MeteocatConditionCoordinator"),
|
|
171
|
+
("temp_forecast_coordinator", "MeteocatTempForecastCoordinator"),
|
|
172
|
+
("alerts_coordinator", "MeteocatAlertsCoordinator"),
|
|
173
|
+
("alerts_region_coordinator", "MeteocatAlertsRegionCoordinator"),
|
|
174
|
+
("quotes_coordinator", "MeteocatQuotesCoordinator"),
|
|
175
|
+
("quotes_file_coordinator", "MeteocatQuotesFileCoordinator"),
|
|
176
|
+
("lightning_coordinator", "MeteocatLightningCoordinator"),
|
|
177
|
+
("lightning_file_coordinator", "MeteocatLightningFileCoordinator"),
|
|
178
|
+
("sun_coordinator", "MeteocatSunCoordinator"),
|
|
179
|
+
("sun_file_coordinator", "MeteocatSunFileCoordinator"),
|
|
173
180
|
]
|
|
174
181
|
|
|
175
182
|
hass.data.setdefault(DOMAIN, {})
|
|
176
183
|
hass.data[DOMAIN][entry.entry_id] = {}
|
|
177
184
|
|
|
178
185
|
try:
|
|
179
|
-
for key,
|
|
186
|
+
for key, cls_name in coordinator_configs:
|
|
187
|
+
# Importación lazy: importa la clase solo cuando sea necesario
|
|
188
|
+
cls = await hass.async_add_executor_job(_get_coordinator_module, cls_name)
|
|
180
189
|
coordinator = cls(hass=hass, entry_data=entry_data)
|
|
181
190
|
await coordinator.async_config_entry_first_refresh()
|
|
182
191
|
hass.data[DOMAIN][entry.entry_id][key] = coordinator
|
|
@@ -251,6 +260,7 @@ async def async_remove_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
|
|
251
260
|
files_folder / f"uvi_{town_id.lower()}_data.json",
|
|
252
261
|
files_folder / f"forecast_{town_id.lower()}_hourly_data.json",
|
|
253
262
|
files_folder / f"forecast_{town_id.lower()}_daily_data.json",
|
|
263
|
+
files_folder / f"sun_{town_id.lower()}_data.json",
|
|
254
264
|
])
|
|
255
265
|
|
|
256
266
|
# 3. Archivos de comarca (region_id)
|