http://www.amazon.de/Aukru-Superregener ... +raspberry
The Switches from Bennstuhl has a Remote Control but nobody can use it with Domoticz.
Now i have Playes with Wiringpi and 433Utils.
A Script to recive Actions from Remote Control is the RFSniffer. But he has no Actions.
So Modify the RFSniffer.cpp before using Make.
Code: Select all
/*
RFSniffer
Usage: ./RFSniffer [<pulseLength>]
[] = optional
Hacked from http://code.google.com/p/rc-switch/
by @justy to provide a handy RF code sniffer
*/
#include "RCSwitch.h"
#include <stdlib.h>
#include <stdio.h>
#define CURL_STATICLIB
#include <curl/curl.h>
RCSwitch mySwitch;
int main(int argc, char *argv[]) {
// This pin is not the first pin on the RPi GPIO header!
// Consult https://projects.drogon.net/raspberry-pi/wiringpi/pins/
// for more information.
int PIN = 2;
if(wiringPiSetup() == -1) {
printf("wiringPiSetup failed, exiting...");
return 0;
}
int pulseLength = 0;
if (argv[1] != NULL) pulseLength = atoi(argv[1]);
mySwitch = RCSwitch();
if (pulseLength != 0) mySwitch.setPulseLength(pulseLength);
mySwitch.enableReceive(PIN); // Receiver on interrupt 0 => that is pin #2
while(1) {
if (mySwitch.available()) {
int value = mySwitch.getReceivedValue();
if (value == 0) {
printf("Unknown encoding\n");
} else {
if (mySwitch.getReceivedValue() == 1394001) {
printf("Switch A ON");
FILE * pFile;
pFile = fopen ("test.txt","w");
if (pFile!=NULL)
{
fputs ("AON",pFile);
fclose (pFile);
}
}
if (mySwitch.getReceivedValue() == 1394004) {
printf("Switch A OFF");
FILE * pFile;
pFile = fopen ("test.txt","w");
fputs ("AOFF",pFile);
fclose (pFile);
}
}
if (mySwitch.getReceivedValue() == 1397073) {
printf("Switch B ON");
FILE * pFile;
pFile = fopen ("test.txt","w");
if (pFile!=NULL)
{
fputs ("BON",pFile);
fclose (pFile);
}
}
if (mySwitch.getReceivedValue() == 1397076) {
printf("Switch B OFF");
FILE * pFile;
pFile = fopen ("test.txt","w");
if (pFile!=NULL)
{
fputs ("BOFF",pFile);
fclose (pFile);
}
}
if (mySwitch.getReceivedValue() == 1397841) {
printf("Switch C ON");
FILE * pFile;
pFile = fopen ("test.txt","w");
if (pFile!=NULL)
{
fputs ("CON",pFile);
fclose (pFile);
}
}
if (mySwitch.getReceivedValue() == 1397844) {
printf("Switch C OFF");
FILE * pFile;
pFile = fopen ("test.txt","w");
if (pFile!=NULL)
{
fputs ("COFF",pFile);
fclose (pFile);
}
}
if (mySwitch.getReceivedValue() == 1398033) {
printf("Switch D ON");
FILE * pFile;
pFile = fopen ("test.txt","w");
fclose (pFile);
}
}
if (mySwitch.getReceivedValue() == 1398036) {
printf("Switch D OFF");
FILE * pFile;
pFile = fopen ("test.txt","w");
if (pFile!=NULL)
{
fputs ("DOFF",pFile);
fclose (pFile);
}
}
printf("\n" );
}
mySwitch.resetAvailable();
}
}
exit(0);
}
now Save it and using make.
Then make a read.sh
sudo nano read.sh
then add
Code: Select all
#!/bin/sh
# Domoticz server
SERVER="127.0.0.1:8080"
sleep 1
#sudo sh ./home/pi/wiringPi/433Utils/RPi_utils/RFSniffer
while [ true ]; do
werta=$(awk ' /AON/ {print substr ($0,0)}' /home/pi/wiringPi/433Utils/RPi_utils/test.txt)
wertb=$(awk ' /BON/ {print substr ($0,0)}' /home/pi/wiringPi/433Utils/RPi_utils/test.txt)
wertc=$(awk ' /CON/ {print substr ($0,0)}' /home/pi/wiringPi/433Utils/RPi_utils/test.txt)
wertd=$(awk ' /DON/ {print substr ($0,0)}' /home/pi/wiringPi/433Utils/RPi_utils/test.txt)
wertao=$(awk ' /AOFF/ {print substr ($0,0)}' /home/pi/wiringPi/433Utils/RPi_utils/test.txt)
wertbo=$(awk ' /BOFF/ {print substr ($0,0)}' /home/pi/wiringPi/433Utils/RPi_utils/test.txt)
wertco=$(awk ' /COFF/ {print substr ($0,0)}' /home/pi/wiringPi/433Utils/RPi_utils/test.txt)
wertdo=$(awk ' /DOFF/ {print substr ($0,0)}' /home/pi/wiringPi/433Utils/RPi_utils/test.txt)
if [ "$werta" = "AON" ]
then
curl -s -i -H "Accept: application/json" "http://$SERVER/json.htm?type=command¶m=switchscene&idx=9&switchcmd=On"
echo "AON"
sleep 1
reset=" " > /home/pi/wiringPi/433Utils/RPi_utils/test.txt
fi
if [ "$wertb" = "BON" ]
then
curl -s -i -H "Accept: application/json" "http://$SERVER/json.htm?type=command¶m=switchscene&idx=3&switchcmd=On"
echo "BON"
sleep 1
reset=" " > /home/pi/wiringPi/433Utils/RPi_utils/test.txt
fi
if [ "$wertc" = "CON" ]
then
curl -s -i -H "Accept: application/json" "http://$SERVER/json.htm?type=command¶m=switchscene&idx=7&switchcmd=On"
echo "CON"
sleep 1
reset=" " > /home/pi/wiringPi/433Utils/RPi_utils/test.txt
fi
if [ "$wertd" = "DON" ]
then
curl -s -i -H "Accept: application/json" "http://$SERVER/json.htm?type=command¶m=switchscene&idx=11&switchcmd=On"
echo "DON"
sleep 1
reset=" " > /home/pi/wiringPi/433Utils/RPi_utils/test.txt
fi
if [ "$wertao" = "AOFF" ]
then
curl -s -i -H "Accept: application/json" "http://$SERVER/json.htm?type=command¶m=switchscene&idx=10&switchcmd=On"
echo "AOFF"
sleep 1
reset=" " > /home/pi/wiringPi/433Utils/RPi_utils/test.txt
fi
if [ "$wertbo" = "BOFF" ]
then
curl -s -i -H "Accept: application/json" "http://$SERVER/json.htm?type=command¶m=switchscene&idx=2&switchcmd=On"
echo "BOFF"
sleep 1
reset=" " > /home/pi/wiringPi/433Utils/RPi_utils/test.txt
fi
if [ "$wertco" = "COFF" ]
then
curl -s -i -H "Accept: application/json" "http://$SERVER/json.htm?type=command¶m=switchscene&idx=6&switchcmd=On"
echo "COFF"
sleep 1
reset=" " > /home/pi/wiringPi/433Utils/RPi_utils/test.txt
fi
if [ "$wertdo" = "DOFF" ]
then
curl -s -i -H "Accept: application/json" "http://$SERVER/json.htm?type=command¶m=switchscene&idx=8&switchcmd=On"
echo "DOFF"
sleep 1
reset=" " > /home/pi/wiringPi/433Utils/RPi_utils/test.txt
fi
done
exit 0
then set the RW Rights
sudo chmod 0777 read.sh
sudo chown pi read.sh
sudo chmod 0777 RFSniffer
sudo chown pi RFSniffer
Start it to the next Restart with
cd /home/pi/domoticz/scripts
nice -n 19 nohup ./read.sh &
cd /home/pi/wiringPi/433Utils/RPi_utils/
nice -n 19 nohup ./RFSniffer &
and Revice from the Remote Contol.
HINT: Change the IDX for the Szenes its my IDX