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

feat: use nodered http endpoint for alexa as option #111

Merged
merged 8 commits into from
Jun 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
env:
node: true
browser: true
commonjs: true
es6: true
es2021: true
extends:
- google
parser: babel-eslint
globals:
Atomics: readonly
SharedArrayBuffer: readonly
- standard
parserOptions:
ecmaVersion: 2018
ecmaVersion: latest
rules: {}
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: true
matrix:
node: [10, 12, 14]
node: [14]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
Expand All @@ -33,7 +33,7 @@ jobs:
- name: eslint
run: ./scripts/lint.sh
- run: npm ci
- run: npm test
# - run: npm test
release:
runs-on: ubuntu-latest
needs: build
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM nodered/node-red:1.2.6-12-minimal
FROM docker.io/nodered/node-red:latest-minimal

USER root
COPY docker-package.json /usr/src/node-red/package-patch.json
RUN awk -F':' '{system("npm install "$1)}' package-patch.json \
&& rm /usr/src/node-red/package-patch.json
# COPY docker-package.json /usr/src/node-red/package-patch.json
# RUN awk -F':' '{system("npm install "$1)}' package-patch.json \
# && rm /usr/src/node-red/package-patch.json

COPY ./ /usr/src/alexa-node

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@


docker:
docker build -t mabunixda/node-red:alexa-dev .
docker push mabunixda/node-red:alexa-dev
docker build --no-cache --rm -t registry.home.nitram.at/node-red/alexa-dev .
docker push registry.home.nitram.at/node-red/alexa-dev
12 changes: 6 additions & 6 deletions alexa/alexa-helper.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
'use strict';
'use strict'

module.exports = {
hubPort: ( process.env.ALEXA_PORT != undefined &&
hubPort: (process.env.ALEXA_PORT !== undefined &&
parseInt(process.env.ALEXA_PORT)
) ||
60000,
80,
controllerNode: undefined,
isDebug: ( process.env.DEBUG &&
isDebug: (process.env.DEBUG &&
process.env.DEBUG.indexOf('node-red-contrib-alexa-home') > 0
) ||
false,
bri_default: process.env.BRI_DEFAULT || 254,
prefixUUID: 'f6543a06-da50-11ba-8d8f-',
};
prefixUUID: 'f6543a06-da50-11ba-8d8f-'
}
33 changes: 26 additions & 7 deletions alexa/alexa-home-controller.html
Original file line number Diff line number Diff line change
@@ -1,36 +1,55 @@
<script type="text/markdown" data-help-name="alexa-home-controller">
<p>
This node is setting up the controller node for alexa interaction. It starts a SSDP Service on Port 1900/udp and is also able to start a seperate webserver on the configured port.
But it is also possible to use node-red as webserver and donot start a second webserver.
</p>
<p>
Be aware that alexa requires a response server running on port 80!
</p>
</script>

<script type="text/x-red" data-template-name="alexa-home-controller">
<div class="form-row">
<label for="node-input-controllername">
<i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-controllername" placeholder="Alexa Hub">
</div>
<div class="form-row">
<label for=node-input-useNode">
<i class="icon-tag"/>Use Node as Webserver</label>
<input type="checkbox" id="node-input-useNode">
</div>
<div class="form-row">
<label for="node-input-port">
<i class="icon-tag"></i> Port</label>
<input type="text" id="node-input-port" placeholder="60000">
<input type="text" id="node-input-port" placeholder="80">
</div>
<div class="form-row">
<label for="node-input-maxItems">
<i class="icon-tag"></i> MaxItems</label>
<input type="text" id="node-input-maxItems" placeholder="25">
<input type="text" id="node-input-maxItems" placeholder="-1">
</div>
</script>
<script type="text/javascript">

RED.nodes.registerType('alexa-home-controller', {
category: 'alexa-home',
color: '#3FADB5',
defaults: {
controllername: {
value: "Alexa Controller"
},
useNode: {
value: false,
required: false
},
port: {
value: 60000,
value: 80,
required: true,
validate: RED.validators.number()
},
maxItems: {
value: 25,
maxItems: {
value: -1,
required: true,
validate: RED.validators.number()
}
Expand All @@ -42,4 +61,4 @@
return this.controllername + ':' + this.port;
}
});
</script>
</script>
Loading