Skip to content

Commit

Permalink
Rework implementation
Browse files Browse the repository at this point in the history
- Transform to Typescript
- Split into multiple files
- Support multiple renderers per room
- Add config schema
- Update Readme
  • Loading branch information
mathebox committed Jul 16, 2023
1 parent 9d3f911 commit c7374bc
Show file tree
Hide file tree
Showing 13 changed files with 5,830 additions and 963 deletions.
38 changes: 38 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"parser": "@typescript-eslint/parser",
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended" // uses the recommended rules from the @typescript-eslint/eslint-plugin
],
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"ignorePatterns": [
"dist"
],
"rules": {
"quotes": ["warn", "single"],
"indent": ["warn", 2, { "SwitchCase": 1 }],
"semi": ["off"],
"comma-dangle": ["warn", "always-multiline"],
"dot-notation": "off",
"eqeqeq": "warn",
"curly": ["warn", "all"],
"brace-style": ["warn"],
"prefer-arrow-callback": ["warn"],
"max-len": ["warn", 140],
"no-console": ["warn"], // use the provided Homebridge log method instead
"no-non-null-assertion": ["off"],
"comma-spacing": ["error"],
"no-multi-spaces": ["warn", { "ignoreEOLComments": true }],
"no-trailing-spaces": ["warn"],
"lines-between-class-members": ["warn", "always", {"exceptAfterSingleLine": true}],
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/semi": ["warn"],
"@typescript-eslint/member-delimiter-style": ["warn"]
}
}
95 changes: 5 additions & 90 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Created by .ignore support plugin (hsz.mobi)
### HAP-NodeJS files
persist
# Ignore compiled code
dist

# ------------- Defaults ------------- #

### Node template
# Logs
logs
*.log
Expand Down Expand Up @@ -117,89 +117,4 @@ dist
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.pnp.*

### VisualStudioCode template
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace

# Local History for Visual Studio Code
.history/

### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

.pnp.*
134 changes: 134 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# Ignore source code
src

# ------------- Defaults ------------- #

# gitHub actions
.github

# eslint
.eslintrc

# typescript
tsconfig.json

# vscode
.vscode

# nodemon
nodemon.json

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2

.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.pnp.*
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# homebridge-raumfeld-radio

### Setup
## Setup

When setting up the plugin for the first time (configuration of accessories), make sure the Raumfeld host is running (and playing any radio station).
When setting up the plugin for the first time (configuration of accessories), make sure all Raumfeld devices are running (and optionally playing any radio station).

### Example configuration

Expand All @@ -12,7 +12,6 @@ When setting up the plugin for the first time (configuration of accessories), ma
"platforms": [
{
"platform" : "RaumfeldRadio",
"name" : "Teufel",
"hostIP": "0.0.0.0", // optional
"stations": [
{
Expand All @@ -33,3 +32,17 @@ When setting up the plugin for the first time (configuration of accessories), ma
]
}
```

## Implementation details

### Raumfeld specfic

- The configuration can consist of multiple zones.
- Each zone can have multiple subzones.
- The playback is started on a subzone with a virtual renderer.
- Each subzone can have multiple rooms.
- In each room multiple renders can be located (actual devices).

### Plugin specific

- An accessory is created for each room. The individual renderers in this room are added as a service.
56 changes: 56 additions & 0 deletions config.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"pluginAlias": "RaumfeldRadio",
"pluginType": "platform",
"singular": true,
"schema": {
"type": "object",
"properties": {
"hostIP": {
"title": "Host IP",
"type": "string",
"required": false,
"default": "0.0.0.0",
"format": "hostname"
},
"stations": {
"title": "Stations",
"required": true,
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"properties": {
"name": {
"title": "Name",
"type": "string",
"required": true,
"default": "RadioEins"
},
"streamURL": {
"title": "Stream URL",
"type": "string",
"required": true,
"default": "https://radioeins.de/stream",
"format": "uri"
},
"ebrowseID": {
"title": "ebrowseID",
"type": "string",
"required": false,
"default": "s25111"
},
"excludedRooms": {
"title": "Excluded Rooms",
"required": false,
"type": "array",
"items": {
"title": "Room Name",
"type": "string"
}
}
}
}
}
}
}
}
Loading

0 comments on commit c7374bc

Please sign in to comment.