Files, scripts, howtos and more for openHAB.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
2.4 KiB

5 years ago
# Freifunk
Monitor some parameters like online status and client count of [Freifunk](https://freifunk.net) routers
Typically Freifunk routers are not connected to the local (home) network. So it cannot be pinged to verify that it is online. Also successfully pinging the devices is not telling you anything about the status in the Freifunk network. So I access a JSON file provided by the Freifunk network, in my case [Freifunk Stuttgart](https://freifunk-stuttgart.de). You might need to adjust it to your needs as I do not have any information how other Freifunk communities provide data.
First you need to put the *freifunk* bash script somewhere where you can access it. I created a directory */home/openhabian/scripts* for scripts like this one. Then you need to create a working directory for this script, in my case it is */home/openhabian/freifunk*.
Use cron to get new data every minute, example:
```
*/1 * * * * root /home/openhabian/scripts/freifunk > /dev/null 2>&1
```
Then create three new things in Paper UI. Use the Exec binding and enter the following parameters:
Thing for online status:
* **Name:** freifunk_isonline
* **Command:** cat /home/openhabian/freifunk/freifunk
* **Transform:** JS(freifunk_isonline.js)
* **Interval:** 60
Thing for client count:
* **Name:** freifunk_clientcount
* **Command:** cat /home/openhabian/freifunk/freifunk
* **Transform:** JS(freifunk_clientcount.js)
* **Interval:** 60
When was the last change of the JSON data downloaded:
* **Name:** freifunk_updatedat
* **Command:** cat /home/openhabian/freifunk/freifunk
* **Transform:** JS(freifunk_updatedat.js)
* **Interval:** 60
The new things get an id like _exec:command:**a1b2c3d4**_ which you then need to enter in the items created through the *freifunk.items* file.
* **freifunk**: Put the bash script into */home/openhabian/scripts* (or somewhere else you like) and *chmod 755* it to make it executable. Modify/replace the MAC address to the MAC address of the Freifunk router you want to monitor.
* **freifunk.items**: Put this file into your */etc/openhab2/items* directory and modify it for your specific setup. Maybe everything suits your needs, but you need to match the command ids in the channel command to the things you created earlier in Paper UI.
* **freifunk.map**: Put this file into your */etc/openhab2/transform* directory.
* **freifunk_\*.js**: Put these files into your */etc/openhab2/transform* directory.