Using MQT from Sonoff Bridge - how to configure HASS.IO

Hi all,

I hope someone can help me with this.

I have MQT setup as standard in HASS.IO and have the sonoff power switches working well.

I now have flashed the Sonoff bridge to allow me to use PIRs and Door/window switches.

The problem I have, is I’m unsure as to how to use the triggers from this device and get automation to work.

The MQT response is as follows:

18:50:49 MQT: tele/sonoffbridge/RESULT = {“RfReceived”:{“Sync”:12540,“Low”:420,“High”:1210,“Data”:“D1397E”,“RfKey”:“None”}}

Any idea how I develop an automation from this data?

many thanks

Andy.

try this Link

as is a JSON Object

this should work
base on my understanding of JSON

- platform: mqtt
  name: RfReceived
  state_topic: "tele/sonoffbridge/RESULT"
  value_template: "{{value_json.Data }}"

Put it into a Group
then RfReceived should show D1397E

once that Done

you should be able to create a Automation base on the RfReceived

this is base on my understanding of HA never tryed to read a single JSON Data Array

1 Like

Many thanks for the reply, much appreciated.

I’ve used the following in my configuration.yaml:
sensor:

  • platform: mqtt
    name: “sonoffPIR1”
    state_topic: “tele/sonoffbridge/RESULT”
    value_template: ‘{{ value_json[“RfReceived”][“Data”] }}’
    expire_after: 3

This now shows as a sensor in the top of the HASS.IO home page, and triggers from one of my automation rules.

Great help!! Thank you!!

1 Like

nice glad i could help

lets see your automation what have you got it doing

mite give someone else some ideas

what does the “expire_after: 3” do ???

Hi,

I’m using the PIR to notify me of visitors when I’m in the study and can’t hear the doorbell.

The automation is:
Trigger type: STATE
Entity: sensor.sonoffpir1
From:
To: D1397E

This fires a colourful led strip to let me know someone is at the door.

The “expire_after: 3” simply clears the PIR State back to blank after 3 seconds (as there is no trigger from the MQTT to clear it).

I then use another automation to turn off the LEDs based on the expire.

I could have used timers, but this is so much simpler :slight_smile:

thanks again, without your help I wouldn’t have got this far.

regards

Andy

Hi Cardblower, I’m working on this topic for 2 days now and I don’t get this to work.

I used you code:
sensor:

  • platform: mqtt
    name: “sonoffPIR1”
    command_topic: “tele/sonoffbridge/RESULT”
    value_template: ‘{{ value_json[“RfReceived”][“Data”] }}’
    expire_after: 20

But when I restart HA I get the following:
Failed config
sensor.mqtt:
platform: mqtt
command_topic: tele/sonoffbridge/RESULT
expire_after: 20
name: sonoffPIR1
value_template: {{ value_json[“RfReceived”][“Data”] }}
Successful config (partial)
sensor.mqtt:

I think I do something wrong :S Can you see whats the problem?

How have you setup the sonoff bridge mqtt settings?
Here’s mine:

Check the quote marks, when I copied the value_template line I got some weird quote marks.

[“Data"]

as you can see the qoute marks at the start are different from the quote marks at the end, replacing all the qoute marks made the command work as it should.

I copied it exactly the same! But it fixed now :slight_smile: There was something wrong in my code with the quote marks

That did the trick. Thanks! :slight_smile:

cool, great that it’s all working!

1 Like