Easy Sonoff Bridge controls

Hey guys!

Just a quick share of my latest simple project I’ve created.

With this package, you will have this:

image

Sorry, the image is in portuguese, but the code is translated to english:

You can choose the device, if you have more than one, chose mode (send or learn key), chose key from 1-16 and send the command as a script.

Here is the full package file:

input_select:
  
  rf_bridge_device_select:
    name: 'Device'
    initial: Select
    options:
      - "Select"
      - "Device 1"
      - "Device 2"

  rf_bridge_mode_select:
    name: 'Mode'
    initial: Select
    options:
      - "Select"
      - "Learn"
      - "Send"

  rf_bridge_key_select:
    name: 'Key'
    initial: Select
    options:
      - "Select"
      - "01"
      - "02"
      - "03"
      - "04"
      - "05"
      - "06"
      - "07"
      - "08"
      - "09"
      - "10"
      - "11"
      - "12"
      - "13"
      - "14"
      - "15"
      - "16"

script:

  rf_bridge_send_command:
    alias: 'Send command'
    sequence:
    - service: mqtt.publish
      data_template:
        topic: 'cmnd/{% if states.input_select.rf_bridge_device_select.state == "Device 1" %}rfbridgetopicdevice1{% elif states.input_select.rf_bridge_device_select.state == "Device 2" %}rfbridgetopicdevice2{% endif %}/backlog'
        payload: 'rfkey{{ states("input_select.rf_bridge_key_select") }} {% if states.input_select.rf_bridge_mode_select.state == "Learn" %}2{% elif states.input_select.rf_bridge_mode_select.state == "Send" %}1{% endif %}'
    - service: input_select.select_option
      entity_id: input_select.rf_bridge_device_select
      data_template:
        option: "Select"
    - service: input_select.select_option
      entity_id: input_select.rf_bridge_mode_select
      data_template:
        option: "Select"
    - service: input_select.select_option
      entity_id: input_select.rf_bridge_key_select
      data_template:
        option: "Select"

group:

  rf_bridge_controls:
    control: hidden
    entities:
    - input_select.rf_bridge_device_select
    - input_select.rf_bridge_mode_select
    - input_select.rf_bridge_key_select
    - script.rf_bridge_send_command
    name: RF Bridge
    view: false

homeassistant:
  customize:

    input_select.rf_bridge_device_select:
      icon: mdi:access-point
    
    input_select.rf_bridge_mode_select:
      icon: mdi:swap-vertical
    
    input_select.rf_bridge_key_select:
      icon: mdi:format-list-numbers
    
    script.rf_bridge_send_command:
      icon: mdi:send

Hope it helps!

6 Likes

Hi, if I just want to send a specific frequency (like 987621), which is the command?

- service: mqtt.publish
  topic: 'cmnd/WHAT HERE???" 
  payload: '987621'

Hello.

With my code, you need to fist learn the code using keys (this example, using KEY 1), then call this service:

- service: mqtt.publish
  topic: 'cmnd/DEVICETOPIC/backlog'
  payload: 'rfkey1'
1 Like

So in my case
cmnd/rf-bridge/backlog ?

stat/rf-bridge/RESULT

Thius solution is ok, for now (I do not have 16 objects), but it should be possible to send just by having the parameters (data, low, high, and so on)??

EDIT, thanks a lot, will try now (it works in the consolle), where did you get this info, I coulkdn’t find it nowhere

15:06:22 CMD: cmnd/rf-bridge/rfkey16
15:06:22 MQT: stat/rf-bridge/RESULT = {"RfKey16":"Learned sent"}

this works too

- service: mqtt.publish
  topic: 'cmnd/DEVICETOPIC/rfkey16'

Nice! Good to know, thanks!