From bfb8d81af2914f16de721057272625c5ad056082 Mon Sep 17 00:00:00 2001 From: Torsten Stauder Date: Thu, 30 Apr 2020 22:21:31 +0200 Subject: [PATCH] Trailing slashes are removed autom. from directories --- html/website.html | 9 ++++++++- openHAB/README.md | 6 +++--- src/websiteMgmt.h | 9 ++++++++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/html/website.html b/html/website.html index a128eed..28d8def 100644 --- a/html/website.html +++ b/html/website.html @@ -313,12 +313,19 @@ socket.send(myJSON); } + function removeTrSlash(str) { + if(str.substr(-1) === '/') { + return str.substr(0, str.length - 1); + } + return str; + } + function rfidAssign(clickedId) { lastIdclicked = clickedId; var myObj = { "rfidAssign": { rfidIdMusic: document.getElementById('rfidIdMusic').value, - fileOrUrl: document.getElementById('fileOrUrl').value, + fileOrUrl: removeTrSlash(document.getElementById('fileOrUrl').value), playMode: document.getElementById('playMode').value } }; diff --git a/openHAB/README.md b/openHAB/README.md index dd1cda8..623c786 100644 --- a/openHAB/README.md +++ b/openHAB/README.md @@ -1,17 +1,17 @@ # OpenHAB-integration for Tonuino ## Disclaimer -[OpenHAB](https://www.openhab.org/) is a pretty complex software for home automation. I Just extracted that parts of my local config, that's necessary for Tonuino. Hopefully I didn't forget anything :-) Said this I want to rule out that this document's aim isn't to provide a fully-featured howto. For further informations please have a look at the project's [documentation](https://www.openhab.org/docs/). +[OpenHAB](https://www.openhab.org/) is a pretty complex software for home automation. I Just extracted that parts of my local config, that are necessary for Tonuino. Hopefully I didn't forget anything :-) Said this I want to rule out I didn't test this minimal setup and that this document's aim isn't to provide a fully-featured howto. For further informations please have a look at the project's [documentation](https://www.openhab.org/docs/) or the [community](https://community.openhab.org/). ## What's necessary -In order to make use of my config-files you need to have a running openHAB-installation. Mine is running on the Raspberry Pi. In general there are two ways to achieve this: +In order to make use of my config-files you need to have a running openHAB-installation. Mine is running on a Raspberry Pi 3b+. In general there are two ways to achieve this: * [Raspbian with manual openHAB-installation](https://www.openhab.org/docs/installation/rasppi.html) * [openHABian](https://www.openhab.org/docs/installation/openhabian.html) After completing the installation, [PaperUI](http://:8080/paperui/index.html) should be browsable. In order to get Tonuino running you need at least the MQTT-binding (Add-ons -> Bindings) and the Map-transformation (Add-ons -> transformations). Beside of openHAB you need a MQTT-broker. You can use a public one but if there's already a Raspberry Pi running with openHAB, it probably makes sense to install [Mosquitto](https://mosquitto.org/) as MQTT-broker in parallel. ## MQTT -After MQTT-broker is set up have look at mqttConnections.things in order to configure the MQTTT-connection between openHAB and the broker. In doubt restart openHAB as changes sometimes don't get recognized immediately without restart. If nothing happens have a look at the logfiles /var/log/openhab2/openhab.log or /var/log/openhab2/events.log. In general, to debug MQTT-stuff, [MQTT fx](https://mqttfx.jensd.de/) is a good tool to refer. +After your MQTT-broker is set up have look at mqttConnections.things in order to configure the MQTTT-connection between openHAB and the broker. In doubt restart openHAB as changes sometimes don't get recognized immediately without restart. If nothing happens have a look at the logfiles /var/log/openhab2/openhab.log or /var/log/openhab2/events.log. In general, to debug MQTT-stuff, [MQTT fx](https://mqttfx.jensd.de/) is a good tool to refer. ## Important In openHAB it's your choice to make use of configuration via Paper UI or textfiles. Sounds basically good but in fact it's not, because mixing up both can be really crappy and painstaking to debug. Make sure to only use one way. \ No newline at end of file diff --git a/src/websiteMgmt.h b/src/websiteMgmt.h index a2a557b..f6694d4 100644 --- a/src/websiteMgmt.h +++ b/src/websiteMgmt.h @@ -312,13 +312,20 @@ static const char mgtWebsite[] PROGMEM = "\ var myJSON = JSON.stringify(myObj);\ socket.send(myJSON);\ }\ +\ + function removeTrSlash(str) {\ + if(str.substr(-1) === '/') {\ + return str.substr(0, str.length - 1);\ + }\ + return str;\ + }\ \ function rfidAssign(clickedId) {\ lastIdclicked = clickedId;\ var myObj = {\ \"rfidAssign\": {\ rfidIdMusic: document.getElementById('rfidIdMusic').value,\ - fileOrUrl: document.getElementById('fileOrUrl').value,\ + fileOrUrl: removeTrSlash(document.getElementById('fileOrUrl').value),\ playMode: document.getElementById('playMode').value\ }\ };\