Browse Source

added freifunk

master
Martin Sebald 7 years ago
parent
commit
bd19d21c41
  1. 3
      README.md
  2. 40
      freifunk/README.md
  3. 8
      freifunk/freifunk
  4. 3
      freifunk/freifunk.items
  5. 3
      freifunk/freifunk.map
  6. 1
      freifunk/freifunk_clientcount.js
  7. 1
      freifunk/freifunk_isonline.js
  8. 1
      freifunk/freifunk_updatedat.js

3
README.md

@ -8,6 +8,9 @@ The stuff I provide is based on [openHABian](http://docs.openhab.org/installatio
## apcups ## apcups
Receiving and using information from APC UPS devices Receiving and using information from APC UPS devices
## freifunk
Monitor some parameters of Freifunk routers
## heating ## heating
Some heating rules, based on a time schedule, presence and TV status. Some heating rules, based on a time schedule, presence and TV status.

40
freifunk/README.md

@ -0,0 +1,40 @@
# 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.

8
freifunk/freifunk

@ -0,0 +1,8 @@
#/bin/sh
cd /home/openhabian/freifunk
rm -f freifunk
rm -f 00:11:22:33:44:55
wget -q https://nodealarm.freifunk-stuttgart.de/00:11:22:33:44:55
sed "s/\[//g" <00:11:22:33:44:55 >freifunk
mv freifunk 00:11:22:33:44:55
sed "s/\]//g" <00:11:22:33:44:55 >freifunk

3
freifunk/freifunk.items

@ -0,0 +1,3 @@
String freifunk_Status "Status [MAP(freifunk.map):%s]" { channel="exec:command:a1b2c3d4:output" }
String freifunk_ClientCount "Clients [%s]" { channel="exec:command:b2c3d4e5:output" }
String freifunk_Updated_at "Updated at [%s]" { channel="exec:command:c3d4e5f6:output" }

3
freifunk/freifunk.map

@ -0,0 +1,3 @@
1=Online
0=Offline
NULL=unbekannt

1
freifunk/freifunk_clientcount.js

@ -0,0 +1 @@
JSON.parse(input).clientcount;

1
freifunk/freifunk_isonline.js

@ -0,0 +1 @@
JSON.parse(input).isonline;

1
freifunk/freifunk_updatedat.js

@ -0,0 +1 @@
JSON.parse(input).updated_at;
Loading…
Cancel
Save