Sonoff RF Bridge (Tasmota) registering in HA

Hi all,

I need help. Have been spinning my wheels for a number of evenings trying to find a solution. I am new to HA and Tasmota.

I have the RF bridge tasmota’ed. I want to setup a 433mhz PIR to trigger turning on the front porch lights.

I have a sonoff basic already registering in HA overview by setting up MQTT (not via yaml method, but by ‘Intergations’.

Here is my config so far, but for reasons I cannot crack, however, HA ‘check config’ keeps throwing errors.

# Sensors
sensor:
  # Weather prediction
  - platform: yr
  - platform: ring

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml

#Ring Doorbell
ring:
    username: <removed>
    password: <removed>
    
camera:
    - platform: ring
    
binary_sensor:
    - platform: ring
    
    - platform: mqtt
state_topic: "rf.bridge/tele/RESULT"
name: 'Front House Motion'
payload_on: 'F18D3E'
payload_off: 'F18D3Eoff'
device_class: motion
optimistic: false
qos: 1

As you can see, i get the payload_on data, but i cant get my head around how I can get this into HA so I can use it as a part of an automation.

Really appreciate anyones experience and guidance on this.

Regards,
hooha_mc

type or paste code here

If this is the way your yaml is formatted, then it is very wrong. The correct spaces in front are very importent.

# Sensors
sensor:
  # Weather prediction
  - platform: yr
  - platform: ring

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml

#Ring Doorbell
ring:
  username: <removed>
  password: <removed>
    
camera:
  - platform: ring
    
binary_sensor:
  - platform: ring
    
  - platform: mqtt
      state_topic: "rf.bridge/tele/RESULT"
      name: 'Front House Motion'
      payload_on: 'F18D3E'
      payload_off: 'F18D3Eoff'
      device_class: motion
      optimistic: false
      qos: 1

#define your mqtt broker
mqtt:
  broker: 10.0.0.63
  port: 1883
  discovery: true
  discovery_prefix: homeassistant
  username: xxxx
  password: xxxx
  birth_message:
    topic: 'hass/status'
    payload: 'online'
  will_message:
    topic: 'hass/status'
    payload: 'offline'  

If you end up with several RF Sensors I recommend you look at @123 method of Strategy 2: Demultiplexer for RF Codes Sonoff RF Bridge. Strategies for receiving data

That way it’s saves on having a tone of repeated code and allow’s you to retain the sensor states in MQTT, saves using input_boolean’s like I first started off with.

Thank you @francisp.

I have updated with the following:

# Sensors
sensor:
  # Weather prediction
  - platform: yr
  - platform: ring
  
#define your mqtt broker
mqtt:
  broker: 192.168.1.199
  port: 1883
  discovery: true
  discovery_prefix: homeassistant
  username: <removed> 
  password: <removed>
  birth_message:
    topic: 'hass/status'
    payload: 'online'
  will_message:
    topic: 'hass/status'
    payload: 'offline'

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml

#Ring Doorbell
ring:
    username: <removed>
    password: <removed>
    
camera:
    - platform: ring
    
binary_sensor:
- platform: ring

- platform: mqtt
  name: 'Front House Motion'
  state_topic: 'rf433/fronthousepir'
  off_delay: 5
  device_class: motion

I could already see some of my other Sonoff Basic mqtt sensors and can control. Should I expect to see some icon or something on the overview page now this is configured here, or does it just sit in the background (intergrations)?

Regards the spacing, when I use the configurator from Hassio. It gives me a green tick and also when I check config under Server Control. It says configuration is all valid. Maybe you know something I havent learnt yet if you could share.
Thank you for replying. Appreciate the assistance.

Hey @wills106,
Thank you. I gave this a crack last night.
Copy-paste job and filled in the blanks :slight_smile:

What do you think?

  alias: rfbridge_demultiplexer
  trigger:
  - platform: mqtt
    topic: rf.bridge/tele/RESULT
  action:
  - service: python_script.rfbridge_demux
    data_template:
      payload: '{{trigger.payload_json.RfReceived.Data}}'

So when there is a message on: rf.bridge/tele/RESULT it triggers the python script where I specified all the sensors d:

d = { 'F18D3E':['fronthousepir','ON','false'],
    }

p = data.get('payload')

if p is not None:
  if p in d.keys():
    service_data = {'topic':'rf433/{}'.format(d[p][0]), 'payload':'{}'.format(d[p][1]), 'qos':0, 'retain':'{}'.format(d[p][2])}
  else:
    service_data = {'topic':'home/unknown', 'payload':'{}'.format(p), 'qos':0, 'retain':'false'}
    logger.warning('<rfbridge_demux> Received unknown RF command: {}'.format(p))
  hass.services.call('mqtt', 'publish', service_data, False)

Sounds like a silly question, but how could i test this is right?
I used MQTT Lens and subscribed to rf433* to see if any messages are being received, but I get nothing.

Sorry for my silly questions, trying to learn and master this setup.
Cheers.

That looks almost OK. Just one thing :

topic: rf.bridge/tele/RESULT

You are sure the topic recieved is rf.bridge/… and not rfbridge/… ?

If it gets triggered, you should see something like this

automation

and in MQTTlens you should see a message arriving on rf433/

thank you. for simplification, I have just made it without the dot (rfbridge).
The TOPIC modification. That in the automation or the MQTT broker config settings?

So I can see the demuxer was triggered today, but not the 'front house motion"

Looking at MQTT lens i got this:

Am I right in understanding that the PIR is still sending to: rf.bridge/tele/RESULT but nothing is being received on rf433/

Thank you

Your screenshot shows rfbridge/tele/RESULT, but your automation is defined as rf.bridge/tele/RESULT

Maybe

  service_data = {'topic':'rf433/{}'.format(d[p][0]), 'payload':'{}'.format(d[p][1]), 'qos':0, 'retain':'{}'.format(d[p][2])}
  else:
    service_data = {'topic':'home/unknown', 'payload':'{}'.format(p), 'qos':0, 'retain':'false'}

change home/unknown also to rf433

@francisp francisp
Well, im think im getting somewhere. I can see that when I trigger one of the rf433 switches that I have in my python_script.rfbridge_demux file, it changes the automation date/time:

rfbridge_demultiplexer Last triggered: September 26, 2019, 9:37 PM
Hooray

And, I think I have found that I have not added point 1 of: Sonoff RF Bridge. Strategies for receiving data

"To make this work, you have to configure Home Assistant to use the python_script component.

Add python_script: to your configuration file."

Is it as simple as adding:

#python script
python_script:

to my config.yaml?
Or do I need to link to the path of the demux file. E.G.

python_script: <insert path
?

I think i am nearly there. Much appreciated.

Just
Is it as simple as adding:

#python script
python_script:

nothing more, and restarting HA

After you’ve added python_script: to the configuration file and restarted Home Assistant any changes you make to rfbridge_demux.py will become effective immediately after the file is saved. You won’t need to restart Home Assistant after modifying an existing python_script file or adding a new one. This is very convenient because it saves you time when modifying/testing a python_script (and it’s less disruptive compared to adding/modifying entities).

so, here is my config file again:

# Sensors
sensor:
  # Weather prediction
  - platform: yr
  - platform: ring
  
#define your mqtt broker
mqtt:
  broker: 192.168.1.199
  port: 1883
  discovery: true
  discovery_prefix: homeassistant
  username: xxxx  
  password: xxxx
  birth_message:
    topic: 'hass/status'
    payload: 'online'
  will_message:
    topic: 'hass/status'
    payload: 'offline'

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml

#Ring Doorbell
ring:
    username: xxxx
    password: xxxx
    
camera:
    - platform: ring
    
binary_sensor:
- platform: ring

- platform: mqtt
  name: 'Front House Motion'
  state_topic: 'rf433/fronthousepir'
  off_delay: 5
  device_class: motion

#python script
  python_script:

after restarting HA, i get a notification:


The following components and platforms could not be set up:

* [python-script](https://home-assistant.io/components/python_script/)

Please check your config.

Is this worth worrying about?

remove the spaces in front of pyhon_script. It needs to be at the same level as group, automation, script, ring, etc…

I did it !!! I did it!! - with all of you legends help.

my pitfall was the folder location I created the ‘python_scripts’ folder.
Once I created in the HA directory and not under a separate folder, both the demux automation and the sensor light automation works.

Thank you ALL for your guidance and patience with me to nutt it out.
Much appreciated.

Ive got some cool automation to do now. :smile:

1 Like