Intertechno receiving possible? Openhabian, CUL-Stick

Hi again,

the Sonoff Bridge cant receive raw. The decoding is done in a dedicated IC.
A alternative firmware for that is in early development…
But the good news when you can receive your codes it is just a Openhab job to do magic and send all the codes you need
Here is my rules file for the 433mhz stuff…


rule "RF433 switch sonoff"
when
    Item RfBridge_RfReceive changed
then
if (RfBridge_RfReceive.state == NULL)
    {
    logInfo("RfBridge.rules", "Item is null, cancelling...")
    return;
    } 
    var rfData = RfBridge_RfReceive.state.toString
    logInfo("rfbridge.rules", "Received IT Codes: " + rfData)
        switch (rfData) {         
            case "A00A1F":
               {
                publish("broker", "cmnd/sonoff-13D92F/POWER", "ON")
                }
            case "A00A17":
                {
                publish("broker", "cmnd/sonoff-13D92F/POWER", "OFF")
                }
            case "A00A1B":
               {
                publish("broker", "cmnd/sonoff-065CA6/POWER", "ON")
                }
            case "A00A13":
                {
                publish("broker", "cmnd/sonoff-065CA6/POWER", "OFF")
                }
            case "A00A1D":
               {
                publish("broker", "cmnd/sonoff-101AEE/POWER", "ON")
                }
            case "A00A15":
                {
                publish("broker", "cmnd/sonoff-101AEE/POWER", "OFF")
                }                
            case "A00A1E":
               {
                publish("broker", "cmnd/sonoff-5DE6D5/POWER", "ON")
                }
            case "A00A16":
                {
                publish("broker", "cmnd/sonoff-5DE6D5/POWER", "OFF")
                }   
/*
            case "on1":
               {
                publish("broker", "cmnd/" + device_id + "/RfSync", "11320") 
                publish("broker", "cmnd/" + device_id + "/RfLow", "360") 
                publish("broker", "cmnd/" + device_id + "/RfHigh", "1090")     
                publish("broker", "cmnd/" + device_id + "/RfCode", "#150551") 
                }
            case "off1":
                {
                publish("broker", "cmnd/" + device_id + "/RfSync", "11320") 
                publish("broker", "cmnd/" + device_id + "/RfLow", "360") 
                publish("broker", "cmnd/" + device_id + "/RfHigh", "1090")                         
                publish("broker", "cmnd/" + device_id + "/RfCode", "#150554") 
                }   
            case "on2":
               {
                publish("broker", "cmnd/" + device_id + "/RfSync", "11320") 
                publish("broker", "cmnd/" + device_id + "/RfLow", "360") 
                publish("broker", "cmnd/" + device_id + "/RfHigh", "1090")     
                publish("broker", "cmnd/" + device_id + "/RfCode", "#151151") 
                }
            case "off2":
                {
                publish("broker", "cmnd/" + device_id + "/RfSync", "11320") 
                publish("broker", "cmnd/" + device_id + "/RfLow", "360") 
                publish("broker", "cmnd/" + device_id + "/RfHigh", "1090")     
                publish("broker", "cmnd/" + device_id + "/RfCode", "#151154") 
                }
            case "on3":
               {
                publish("broker", "cmnd/" + device_id + "/RfSync", "11320") 
                publish("broker", "cmnd/" + device_id + "/RfLow", "360") 
                publish("broker", "cmnd/" + device_id + "/RfHigh", "1090")     
                publish("broker", "cmnd/" + device_id + "/RfCode", "#151451") 
                }
            case "off3":
                {
                publish("broker", "cmnd/" + device_id + "/RfSync", "11320") 
                publish("broker", "cmnd/" + device_id + "/RfLow", "360") 
                publish("broker", "cmnd/" + device_id + "/RfHigh", "1090")     
                publish("broker", "cmnd/" + device_id + "/RfCode", "#151454") 
                }
            case "on4":
               {
                publish("broker", "cmnd/" + device_id + "/RfSync", "11320") 
                publish("broker", "cmnd/" + device_id + "/RfLow", "360") 
                publish("broker", "cmnd/" + device_id + "/RfHigh", "1090")     
                publish("broker", "cmnd/" + device_id + "/RfCode", "#151511") 
                }
            case "off4":
                {
                publish("broker", "cmnd/" + device_id + "/RfSync", "11320") 
                publish("broker", "cmnd/" + device_id + "/RfLow", "360") 
                publish("broker", "cmnd/" + device_id + "/RfHigh", "1090")     
                publish("broker", "cmnd/" + device_id + "/RfCode", "#151514") 
                }
            case "on5":
               {
                publish("broker", "cmnd/" + device_id + "/RfSync", "11320") 
                publish("broker", "cmnd/" + device_id + "/RfLow", "360") 
                publish("broker", "cmnd/" + device_id + "/RfHigh", "1090")     
                publish("broker", "cmnd/" + device_id + "/RfCode", "#151541") 
                }
            case "off5":
                {
                publish("broker", "cmnd/" + device_id + "/RfSync", "11320") 
                publish("broker", "cmnd/" + device_id + "/RfLow", "360") 
                publish("broker", "cmnd/" + device_id + "/RfHigh", "1090")     
                publish("broker", "cmnd/" + device_id + "/RfCode", "#151544")
                }
            case "on6":
               {
                publish("broker", "cmnd/" + device_id + "/RfSync", "11320") 
                publish("broker", "cmnd/" + device_id + "/RfLow", "360") 
                publish("broker", "cmnd/" + device_id + "/RfHigh", "1090")     
                publish("broker", "cmnd/" + device_id + "/RfCode", "#150151") 
                }
            case "off6":
                {
                publish("broker", "cmnd/" + device_id + "/RfSync", "11320") 
                publish("broker", "cmnd/" + device_id + "/RfLow", "360") 
                publish("broker", "cmnd/" + device_id + "/RfHigh", "1090")     
                publish("broker", "cmnd/" + device_id + "/RfCode", "#150154") 
                }
            case "on7":
               {
                publish("broker", "cmnd/" + device_id + "/RfSync", "11320") 
                publish("broker", "cmnd/" + device_id + "/RfLow", "360") 
                publish("broker", "cmnd/" + device_id + "/RfHigh", "1090")     
                publish("broker", "cmnd/" + device_id + "/RfCode", "#151051") 
                }
            case "off7":
                {
                publish("broker", "cmnd/" + device_id + "/RfSync", "11320") 
                publish("broker", "cmnd/" + device_id + "/RfLow", "360") 
                publish("broker", "cmnd/" + device_id + "/RfHigh", "1090")     
                publish("broker", "cmnd/" + device_id + "/RfCode", "#151054") 
                }
            case "on8":
               {
                publish("broker", "cmnd/" + device_id + "/RfSync", "11320") 
                publish("broker", "cmnd/" + device_id + "/RfLow", "360") 
                publish("broker", "cmnd/" + device_id + "/RfHigh", "1090")     
                publish("broker", "cmnd/" + device_id + "/RfCode", "#151411") 
                }
            case "off8":
                {
                publish("broker", "cmnd/" + device_id + "/RfSync", "11320") 
                publish("broker", "cmnd/" + device_id + "/RfLow", "360") 
                publish("broker", "cmnd/" + device_id + "/RfHigh", "1090")     
                publish("broker", "cmnd/" + device_id + "/RfCode", "#151414") 
                }                 
            case "on9":
               {
                publish("broker", "cmnd/" + device_id + "/RfSync", "11320") 
                publish("broker", "cmnd/" + device_id + "/RfLow", "360") 
                publish("broker", "cmnd/" + device_id + "/RfHigh", "1090")     
                publish("broker", "cmnd/" + device_id + "/RfCode", "#150501") 
                }
            case "off9":
                {
                publish("broker", "cmnd/" + device_id + "/RfSync", "11320") 
                publish("broker", "cmnd/" + device_id + "/RfLow", "360") 
                publish("broker", "cmnd/" + device_id + "/RfHigh", "1090")     
                publish("broker", "cmnd/" + device_id + "/RfCode", "#150504") 
                }
            case "on10":
               {
                publish("broker", "cmnd/" + device_id + "/RfSync", "12880") 
                publish("broker", "cmnd/" + device_id + "/RfLow", "420") 
                publish("broker", "cmnd/" + device_id + "/RfHigh", "1270")
                publish("broker", "cmnd/" + device_id + "/RfCode", "#3575C0") 
                }
            case "off10":
                {
                publish("broker", "cmnd/" + device_id + "/RfSync", "12880") 
                publish("broker", "cmnd/" + device_id + "/RfLow", "420") 
                publish("broker", "cmnd/" + device_id + "/RfHigh", "1270")
                publish("broker", "cmnd/" + device_id + "/RfCode", "#35750C")                     
                }     */             
    }
 RfBridge_RfReceive.postUpdate(rfData)
end

and the items part

String RfBridge_RfReceive "RfReceive [%s]"
    { mqtt="<[broker:tele/sonoff-8E8329/RESULT:state:JSONPATH($.RfReceived.Data)]" }    

I dont use the function Key learning in RF Bridge. I didnt managed it to learn codes of my remote correct. So i decided to decode the JSON String.
I defined a Item for that. In the Rule the Action is done.
In this case, i use a Rf-Remote to switch some of my sonoffs wlan switches. Not always is a Tablet a good human interface. Easy for child and better WAF😎
What i do next is a rule for my Rf 433 Poweroutlets to have correct states in OpenHab when the are switched with the Rf Remote and not via OpenHab.
Nice or? This is done easy. I get the received code via mqtt from the RfBridge and with a rule i change the state of the corresponding item in OpenHab. I really like the RfBridge. With that and the Alexa binding i can control my 433mhz devices by voice😉

Thank you very much for your last post. This solved my problem :slight_smile:

This is my working example copied from yours:

// Sonoff-Bridge 433

rule "Sonoff-Bridge 433"
when
    Item RfBridge_RfReceive changed
then
if (RfBridge_RfReceive.state == NULL)
    {
    //logInfo("RfBridge.rules", "Item is null, cancelling...")
    return;
    } 
    var rfData = RfBridge_RfReceive.state.toString
    logInfo("rfbridge.rules", "Received IT Codes: " + rfData)
        switch (rfData) {         
            case "555541":
               {
                BM_new.sendCommand(ON)
                }
            case "555544":
                {
                BM_new.sendCommand(OFF)
                }
    }
 RfBridge_RfReceive.postUpdate(rfData)
end

With the items:

String RfBridge_RfReceive "RfReceive [%s]" { mqtt="<[mqtt:tele/sonoff-bridge/RESULT:state:JSONPATH($.RfReceived.Data)]" } 
Switch BM_new

and I had to install the JASONPATH transformation binding.

( My selfmade-sensors consist of an Attiny85, a cheapo fs1000a 433mhz chip, a capacitor and a 3,7V 18650 accu or just a CR2032 for window contacts (or cheap PIR module). Until the last weeks I used an Intertechno library to send/receive in FHEM with all the same protocol. Now I switched to another older Intertechno protocol library with DIP/DIL switch codes and this works now flawlessly with my Tasmota bridge. )

The item 100% switches a 433mhz socket if your codes are correct
Here is my in use definition for a german Wohnzimmerfluter

Switch WohnFluter       "Wohnz. Fluter"         <light> (LR,gLight)     [ "Lighting" ] 
		{ mqtt=">[broker:cmnd/sonoff-8E8329/Backlog:command:ON:RfSync 11320; RfLow 360; RfHigh 1090; RfCode #150551],
                >[broker:cmnd/sonoff-8E8329/Backlog:command:OFF:RfSync 11320; RfLow 360; RfHigh 1090; RfCode #150554]" }

The sensors are interesting!
Can i get links or your setup for this litte nice ones.
I have some use case for that. Window door contact etc…



The 2 fotos are from my window contacts, not the prettiest one, but they do work and the price is around 5€.
The circuit is from the PIR module, its just a grey 75x75 hardware store box for cables with a hole for the pir module and hot glue around it. They are sitting somewhre outside in the cold.

The attinys are going to deep sleep and just wake up by an interrupt coming from the pir resp. the windows contacts. The attiny sends the current state and goes to sleep again. The outside batteries (18650 3,7V 2600mAh) last for 2-3 years as a PIR. The window contacts with noname CR2032s from ebay last about 0,5-1 year depending on the window. For me it is just nice to have that for my cellar windows and shutters and so on.

Normally I test the code on an Arduno Uno with Arduino Studio because there you can see everything in a serial monitor. The deep-sleep code cannot be tested there, because its chip-sepcific, whereas the other libraries for radio commands, pins, etc is all universal, so you can take the arduino code and just program it to your attiny. I don’t know how familiar you are with that, maybe it’s nothing new for you.
(I made also an electric attic lid with an attiny board, some relais and an old accu drill :slight_smile: of course with an 433MHz Chip to receive the commands.)

This is e.g. the attiny code for my “old” Intertechno PIR modules:

#include <NewRemoteTransmitter.h>
#include <avr/sleep.h>
#include <avr/wdt.h>
 
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif

byte PIR_PIN=2;      // PB2
byte SEND_PIN=3;     // PB3

boolean BewegungsStatus;

NewRemoteTransmitter transmitter(50650000, SEND_PIN, 270, 3);   // Send-Pin wird als Output in Lib gesetzt

void setup() {
  pinMode(PIR_PIN, INPUT);  // Taster/Relais PB2
  setup_watchdog(8);  // approximately 4 seconds sleep
  cbi(ADCSRA,ADEN);                    // switch Analog to Digitalconverter OFF
  set_sleep_mode(SLEEP_MODE_PWR_DOWN); // sleep mode is set here
  BewegungsStatus=false;
}

void loop() {
system_sleep();
}

void system_sleep() {
  sleep_enable();
  sleep_mode();                        // System sleeps here
  sleep_disable();                     // System continues execution here when watchdog timed out
  //sbi(ADCSRA,ADEN);                    // switch Analog to Digitalconverter ON
}

// 0=16ms, 1=32ms,2=64ms,3=128ms,4=250ms,5=500ms
// 6=1 sec,7=2 sec, 8=4 sec, 9= 8sec

void setup_watchdog(int ii) {
  byte bb;
  int ww;
  if (ii > 9 ) ii=9;
  bb=ii & 7;
  if (ii > 7) bb|= (1<<5);
  bb|= (1<<WDCE);
  ww=bb;
  MCUSR &= ~(1<<WDRF);
  // start timed sequence
  WDTCR |= (1<<WDCE) | (1<<WDE);
  // set new watchdog timeout value
  WDTCR = bb;
  WDTCR |= _BV(WDIE);
}

// Watchdog Interrupt Service / is executed when watchdog timed out
ISR(WDT_vect) {
  if ((digitalRead(PIR_PIN) == HIGH)){
    if (BewegungsStatus==false){ 
      BewegungsStatus=true;
      transmitter.sendUnit(1, true);  // Hier Bewegung an FHEM senden!
    }
  }else{
    if (BewegungsStatus==true){
      BewegungsStatus=false;
      transmitter.sendUnit(1, false);  // Hier Bewegung an FHEM senden!
    }
  }
}

But you have to adapt it for your personal purpose, I used for example a special library from Randy Simons, he published his library on GitHub. Now in the new programming im using this library https://github.com/sui77/rc-switch When you just try an example (included) you see, it gets received by the sonoff-bridge. There are also receving-examples, so that you can build with an 433 Chip, attiny, relais, transistor, etc an radio relay. but these work better with WLAN and ESPEasy in my opinion.

So this is a small bunch of information of my projects, I’ve done quiet a lot with these things. I also made 433 MHz temperature/humidity sensors but since I dont see a way to receive my self made protocol I switched to ESPEasy sensors, where ever I have 230V power.

I hope it helps a bit and is not too confused :slight_smile:

Thanks a lot. I have some tinys in my “Grabbelkiste”. And already programmed a handfull with arduino and a other IDE. In the moment i forgot the name of it. For programming the tinys i use a real cheap one…
I am not a programmer but with some basic ideas and documented librarys
i got some things already running. With every project my skills grows a little.
So again thank you, i will take a deeper look in that.

Greets Hans