Skip to content

Commit 2f69906

Browse files
Merge pull request #32 from BottlecapDave/develop
New release
2 parents 2d7dd04 + 73f98b8 commit 2f69906

File tree

16 files changed

+226
-187
lines changed

16 files changed

+226
-187
lines changed

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
11
blank_issues_enabled: false
2-
contact_links:
3-
- name: Integration Support
4-
url: https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/discussions
5-
about: Please ask and answer questions here.

.github/workflows/deploy_docs.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/workflows/docs.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Docs
2+
on:
3+
workflow_dispatch:
4+
push:
5+
paths:
6+
- 'mkdocs.yml'
7+
- '_docs/**'
8+
jobs:
9+
build_docs:
10+
if: ${{ (github.repository_owner == 'BottlecapDave' && (github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/main')) == false }}
11+
name: Build docs
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-python@v4
16+
with:
17+
python-version: 3.x
18+
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
19+
- uses: actions/cache@v3
20+
with:
21+
key: mkdocs-material-${{ env.cache_id }}
22+
path: .cache
23+
restore-keys: |
24+
mkdocs-material-
25+
- run: pip install mkdocs-material
26+
- run: mkdocs build --strict
27+
28+
deploy_docs:
29+
if: ${{ github.repository_owner == 'BottlecapDave' && (github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/main') }}
30+
name: Deploy docs
31+
runs-on: ubuntu-latest
32+
permissions:
33+
contents: write
34+
steps:
35+
- uses: actions/checkout@v4
36+
- uses: actions/setup-python@v4
37+
with:
38+
python-version: 3.x
39+
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
40+
- uses: actions/cache@v3
41+
with:
42+
key: mkdocs-material-${{ env.cache_id }}
43+
path: .cache
44+
restore-keys: |
45+
mkdocs-material-
46+
- run: pip install mkdocs-material
47+
- run: mkdocs gh-deploy --strict --force

.github/workflows/issues.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Close inactive issues
22
on:
33
schedule:
44
- cron: "30 1 * * *"
5-
65
jobs:
76
close-issues:
7+
if: ${{ github.repository_owner == 'BottlecapDave' }}
88
runs-on: ubuntu-latest
99
permissions:
1010
issues: write

.github/workflows/main.yml

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
name: Main
22
on:
33
schedule:
4-
- cron: '0 6 * * *'
4+
- cron: '0 1 * * *'
55
push:
66
branches:
77
- develop
88
- main
9+
paths-ignore:
10+
- 'mkdocs.yml'
11+
- '_docs/**'
912
pull_request:
10-
workflow_dispatch:
13+
paths-ignore:
14+
- 'mkdocs.yml'
15+
- '_docs/**'
1116
jobs:
1217
validate:
18+
if: ${{ github.event_name != 'schedule' || github.repository_owner == 'BottlecapDave' }}
19+
name: Validate
1320
runs-on: "ubuntu-latest"
1421
steps:
1522
- uses: "actions/checkout@v4"
@@ -18,8 +25,9 @@ jobs:
1825
uses: "hacs/action@main"
1926
with:
2027
category: "integration"
21-
test:
22-
name: Test
28+
unit_tests:
29+
if: ${{ github.event_name != 'schedule' || github.repository_owner == 'BottlecapDave' }}
30+
name: Unit Tests
2331
runs-on: ubuntu-latest
2432
steps:
2533
- name: Checkout
@@ -31,18 +39,33 @@ jobs:
3139
- name: Install Python modules
3240
run: |
3341
pip install -r requirements.test.txt
34-
- name: Unit tests suite
42+
- name: Run unit tests
3543
run: |
3644
python -m pytest tests/unit
37-
- name: Integration tests suite
45+
integration_tests:
46+
if: ${{ github.event_name != 'schedule' || github.repository_owner == 'BottlecapDave' }}
47+
name: Integration Tests
48+
runs-on: ubuntu-latest
49+
steps:
50+
- name: Checkout
51+
uses: actions/checkout@v4
52+
with:
53+
fetch-depth: 0
54+
- name: asdf_install
55+
uses: asdf-vm/actions/install@v3
56+
- name: Install Python modules
57+
run: |
58+
pip install -r requirements.test.txt
59+
- name: Run integration tests
3860
run: |
3961
python -m pytest tests/integration
4062
release:
4163
name: Release
42-
if: github.ref == 'refs/heads/main'
43-
needs:
64+
if: ${{ github.repository_owner == 'BottlecapDave' && github.ref == 'refs/heads/main' }}
65+
needs:
4466
- validate
45-
- test
67+
- unit_tests
68+
- integration_tests
4669
runs-on: ubuntu-latest
4770
steps:
4871
- name: Checkout

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ To install, place the contents of `custom_components` into the `<config director
3636

3737
## How to setup
3838

39-
Please follow the [setup guide](https://bottlecapdave.github.io/HomeAssistant-FirstBus/setup/account) to setup the integration. This guide details the configuration, along with the sensors that will be available to you.
39+
Please follow the [setup guide](https://bottlecapdave.github.io/HomeAssistant-FirstBus/setup) to setup the integration. This guide details the configuration, along with the sensors that will be available to you.
4040

4141
## Docs
4242

@@ -48,4 +48,4 @@ Before raising anything, please read through the [faq](https://bottlecapdave.git
4848

4949
## Sponsorship
5050

51-
If you are enjoying the integration, why not if possible, make a one off or monthly [GitHub sponsorship](https://github.com/sponsors/bottlecapdave).
51+
If you are enjoying the integration, why not if possible, make a one off or monthly [GitHub sponsorship](https://github.com/sponsors/bottlecapdave).

_docs/entities.md

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,23 @@ The sensor will pull the latest times for the stop every **5 minutes**. This is
1212

1313
The following attributes are available in addition
1414

15-
| Attribute | Notes |
16-
|-----------|-------|
17-
| `ServiceNumber` | The name/number of the next bus |
18-
| `Destination` | The destination of the next bus |
19-
| `Due` | The timestamp of when the next bus is due, in ISO format |
20-
| `IsFG` | Determines if the bus is a First bus (`Y`) or not (`N`) |
21-
| `IsLive` | Determines if the bus is being tracked (`Y`) or is from the timetable (`N`) |
22-
| `stop` | The ATCO code of the bus stop that is being tracked |
15+
| Attribute | Type | Notes |
16+
|-----------|------|-------|
17+
| `service_ref` | `string` | The internal reference for the service |
18+
| `service_number` | `string` | The name/number of the next bus |
19+
| `destination` | `string` | The destination of the next bus |
20+
| `due` | `datetime` | The timestamp of when the next bus is due |
21+
| `is_live` | `boolean` | Determines if the bus is being tracked (`true`) or is from the timetable (`false`) |
22+
| `stop` | `string` | The ATCO code of the bus stop that is being tracked |
23+
| `buses` | `list` | The collection of known upcoming buses for the stop |
24+
| `data_last_updated` | `datetime` | The timestamp when the underlying data was last updated |
25+
26+
For each bus in `buses`, you can find the following attributes
27+
28+
| Attribute | Type | Notes |
29+
|-----------|------|-------|
30+
| `service_ref` | `string` | The internal reference for the service |
31+
| `service_number` | `string` | The name/number of the next bus |
32+
| `destination` | `string` | The destination of the next bus |
33+
| `due` | `datetime` | The timestamp of when the next bus is due |
34+
| `is_live` | `boolean` | Determines if the bus is being tracked (`true`) or is from the timetable (`false`) |

custom_components/first_bus/api_client.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ async def async_get_bus_times(self, stop):
1414
data = await response.json(content_type=None)
1515

1616
if ("times" in data):
17-
return data["times"]
17+
return list(map(lambda time: {
18+
"due": time["Due"],
19+
"service_ref": time["ServiceRef"],
20+
"service_number": time["ServiceNumber"],
21+
"destination": time["Destination"],
22+
"is_live": True if time["IsLive"] == 'Y' or time["IsLive"] == 'y' else False
23+
}, data["times"]))
1824

1925
return []

custom_components/first_bus/const.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
DOMAIN = "first_bus"
44

5+
MINUTES_BETWEEN_UPDATES = 5
6+
57
CONFIG_NAME = "Name"
68
CONFIG_STOP = "Stop"
79
CONFIG_BUSES = "Buses"

custom_components/first_bus/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
],
77
"config_flow": true,
88
"dependencies": [],
9-
"documentation": "https://github.com/BottlecapDave/HomeAssistant-FirstBus/",
9+
"documentation": "https://bottlecapdave.github.io/HomeAssistant-FirstBus",
1010
"homekit": {},
1111
"iot_class": "cloud_polling",
1212
"issue_tracker": "https://github.com/BottlecapDave/HomeAssistant-FirstBus/issues",

0 commit comments

Comments
 (0)