Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintainance update [v2.1.2] #248

Merged
merged 13 commits into from
Dec 10, 2024
16 changes: 8 additions & 8 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "npm" # See documentation for possible values
directory: "/" # Location of package manifests
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly

- package-ecosystem: npm
directory: /
schedule:
interval: "monthly"
interval: monthly
2 changes: 1 addition & 1 deletion .github/workflows/automated-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
cache: "npm"
- name: Install dependencies and run tests
run: |
Expand Down
5 changes: 5 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"line_length": false,
"no-duplicate-heading": false,
"no-inline-html": false
}
8 changes: 0 additions & 8 deletions .stylelintrc.json

This file was deleted.

4 changes: 2 additions & 2 deletions LICENSE → LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License
# The MIT License (MIT)

Copyright (c) 2016 Benjamin Gericke
Copyright © 2016 Benjamin Gericke

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
25 changes: 17 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ The module looks like this:

![Example for Alexanderplatz with time delay](img/MMM-PublicTransport_screenshot.png)

## Preconditions

- MagicMirror² instance

## Installation

Just clone the module into your MagicMirror modules directory and install the dependencies:
Expand Down Expand Up @@ -50,7 +46,7 @@ You need the `stationId` for the station whose departures should be displayed.
Here's how to find out the `stationId`:

1. You have to be in the modules directory (`~/MagicMirror/modules/MMM-PublicTransportBerlin`).
2. Then run the following command: `npm run query_station`.
2. Then run the following command: `npm run query`.
3. Enter a station name.
4. The result could contain one or more possible stations with valid IDs.
5. Use the appropriate ID as `stationId` in the configuration of the module.
Expand All @@ -66,10 +62,10 @@ The module is quite configurable. These are the possible options:
|--------|-------------|
|`stationName`|The name of the station.<br><br>**Type:** `string` This value is **optional**.|
|`stationId`|The ID of the station. How to get the ID for your station is described below.<br><br>**Type:** `string` This value is **Required**.|
|`directionStationId`|If you want the module to show departures only in a specific direction, you can enter the ID of the next station on your line to specify the direction. <br><br> *Note: After some tests, the data delivery of this feature seems not to be as reliable as the normal version. Also, please make sure you actually have the right `stationId` for the direction station. Please check your MagicMirror log for errors before reporting them. <br> Additionally, more request results take more time for the request. So please make sure to keep your `maxUnreachableDepartures` and `maxReachabledepartures` low when using this feature.* <br><br> **Type:** `string` <br>**Default value:** `<empty>`|
|`directionStationId`|If you want the module to show departures only in a specific direction, you can enter the ID of the next station on your line to specify the direction. <br><br> _Note: After some tests, the data delivery of this feature seems not to be as reliable as the normal version. Also, please make sure you actually have the right `stationId` for the direction station. Please check your MagicMirror log for errors before reporting them. <br> Additionally, more request results take more time for the request. So please make sure to keep your `maxUnreachableDepartures` and `maxReachabledepartures` low when using this feature._ <br><br> **Type:** `string` <br>**Default value:** `<empty>`|
|`ignoredLines`|You can exclude different lines of a station by adding them to this array. Usually, this can be empty.<br><br>**Type:** `string array` (comma separated `strings` in the array).<br>**Default value:** `<empty>` <br>**Possible values:** All valid line names like `'U5'` (for subway) , `'M10'` or `'21'` (for tram), `'S75'` (for suburban) , `'Bus 200'`(for bus), etc.|
|`excludedTransportationTypes`|Transportation types to be excluded from appearing on a module instance can be listed here.<br><br>**Type:** `string`, comma-separated list<br>**Default value:** `<empty>` <br>**Possible values:** `bus`, `tram`, `suburban`, `subway`, `regional`, `ferry`|
|`marqueeLongDirections`|Makes a marquee/ticker text out of all direction descriptions with more than 25 characters. If this value is false, the descriptions are trimmed to the station names. You can see a video of it [here](https://ds.kayuk.de/kAfzU/) (rendered by a regular computer).<br><br> *Note: The rendering on the mirror is not perfect, but it is OK in my opinion. If the movement is not fluent enough for you, you should turn it off.*<br><br>**Type:** `boolean`<br>**Default value:** `true`|
|`marqueeLongDirections`|Makes a marquee/ticker text out of all direction descriptions with more than 25 characters. If this value is false, the descriptions are trimmed to the station names. You can see a video of it [here](https://ds.kayuk.de/kAfzU/) (rendered by a regular computer).<br><br> _Note: The rendering on the mirror is not perfect, but it is OK in my opinion. If the movement is not fluent enough for you, you should turn it off._<br><br>**Type:** `boolean`<br>**Default value:** `true`|
|`interval`|How often the module should be updated. The value is given in milliseconds.<br><br>**Type:** `integer` (milliseconds)<br>**Default value:** `120000` (2 minutes)|
|`hidden`|Visibility of the module.<br><br>**Type:** `boolean`<br>**Default value:** `false`|
|`travelTimeToStation`|How long does it take you to get from the mirror to the station? The value is given in minutes. (this is the former `delay` option)<br><br>**Type:** `integer` (minutes)<br>**Default value:** `10` (10 minutes)|
Expand Down Expand Up @@ -133,6 +129,19 @@ Multiple instances of this module are possible. Just add another entry of MMM-Pu
You made my life a lot easier with this! Please consider supporting him on [Patreon](https://patreon.com/derhuerst)!
- The community of [magicmirror.builders](https://magicmirror.builders) for help in the development process and all contributors for finding and fixing errors in this module.

## Issues
## Contributing

If you find any problems, bugs or have questions, please [open a GitHub issue](https://github.com/deg0nz/MMM-PublicTransportBerlin/issues) in this repository.

Pull requests are of course also very welcome 🙂

### Developer commands

- `npm run lint` - Run linting and formatter checks.
- `npm run lint:fix` - Fix linting and formatter issues.
- `npm run release` - Bump version for release.
- `npm run test` - Run linting and formatter checks + Run spelling check.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE.md) file for details.
36 changes: 18 additions & 18 deletions convenience/query_stations.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
/* eslint-disable no-console */
import * as readline from "node:readline";
// eslint-disable-next-line import-x/namespace
import {createClient} from "hafas-client";
import process from "node:process";

let profileName = "";
const productMap = {};

/**
* Create an array without values that occur multiple times.
*
* @param {array} array An array that could have duplicate values.
* @returns {array} An array without duplicate values.
*/
Expand All @@ -18,7 +17,6 @@ function arrayUnique (array) {

/**
* Get proper names for the product keys.
*
* @param {object} products An object with the available transport products as a keys.
* @returns {string} A list of transport products as a string.
*/
Expand All @@ -40,7 +38,6 @@ function refineProducts (products) {

/**
* Output the information about the station on the console.
*
* @param {object} station The station it's about.
*/
function printStationInfo (station) {
Expand All @@ -54,34 +51,37 @@ function printStationInfo (station) {
}

function query (profile) {
if (profile !== "" && profile !== undefined) {
if (profile !== "" && typeof profile !== "undefined") {
const client = createClient(profile, "MMM-PublicTransportHafas");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});

rl.question("Enter an address or station name: ", (answer) => {
rl.question("Enter an address or station name: ", async (answer) => {
rl.close();

const opt = {
adresses: false,
addresses: false,
poi: false,
results: 10,
stations: true
};

client
.locations(answer, opt)
.then((response) => {
console.info(`\nStops found for '${answer}':\n`);
response.forEach((station) => {
printStationInfo(station);
});
process.exit(0);
})
.catch(console.error);
});
try {
const response = await client.locations(
answer,
opt
);
console.info(`\nStops found for '${answer}':\n`);
for (const station of response) {
printStationInfo(station);
}
} catch (error) {
console.error(error);
}
}
);
}
}

Expand Down
1 change: 0 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ const config = [
"func-style": "off",
"max-lines-per-function": ["error", 100],
"no-magic-numbers": "off",
"no-undefined": "off",
"one-var": "off",
"prefer-destructuring": "off"
}
Expand Down
Loading
Loading