Activate Scenes by 433 MHz remote control

Hello,
I made a RF/IR to MQTT gateway following the great project of 1technophile you can find here:

It really works great, I can control 433 outlets, stuff with IR remote, a lot of stuff.
I have a couple of RF remote that are received perfectly by the OpenMQTTGateway, I connected to some switch and turn on and off lights, but I wanted to use them to activate scenes.
I did that creating mqtt switches in HA and using them as trigger in an automation to recall a scene, but this use actually 2 buttons on the remote, to turn on and off each scene. It would be much better if I could use the 6 buttons on the remote, each sending a different RF code, to recall 6 different scenes, but I don’t know how to achieve that.
This is my config section to create the switches:

  - platform: mqtt
    name: "Scene Full"
    state_topic: "home/433toMQTT"      # defined in OpenMqttGateway
    command_topic: "home/commands/MQTTto433/PLSL_345/433_1"     #parameters for receiving RF
    payload_on: "1234567"      # code received when I push button 1 on remote
    payload_off: "7654321"      # code received when I push button 2 on remote
    optimistic: false
    retain: true

And this is the automation I use to recall a scene:

  # recall the scene "full" when switch is turned on
- alias: 'Remote Full'
  trigger:
    platform: state
    entity_id: switch.scene_full
    to: 'on'
  action:
   - service: scene.turn_on
      entity_id: scene.full

  #  recall a "all off" scene when the switch is turned off
- alias: 'Remote Off1'
  trigger:
    platform: state
    entity_id: switch.scene_full
    to: 'off'
  action:
    - service: scene.turn_on
      entity_id: scene.all_off

This code works great with outlet, if I push on or off from the remote the HA switch update, I can control by HA, perfect, but I don’t know how to make it a momentary switch to activate a scene.
What I mean is that, as know, I can’t assign a scene for each button of the remote, because switches in HA need to be on to be turned off, so I have to push on the buttons like a pianist to reach the scene I want, with psychedelic effects in my house ! :slight_smile:
Any advice?
Thanks

I think you need to trigger your automation from the mqtt message, with the payload specific for each button. The service can then specify which scene you want for that payload.

Thank you!
This seems to be intriguing :wink: I’ll check and let you know.

I tried, but it doesn’t seem to work.
This is how I wrote the automation in my automation.yaml file:

- alias: 'Remote Full'
  trigger:
    platform: mqtt
    topic: "home/commands/MQTTto433/PLSL_345/433_1" # defined by OpenMqttGateway
    payload: "1234567"
  action:
   - service: scene.turn_on
     entity_id: scene.full

Of course I commented all the section I used before in configuration.yaml and automation.yaml, but it doesn’t work.
Also, and this looks weird to me, it mess up my Automation section in main page:

10

In my eralier configuration, I took the instruction to write in config from the page of OpenMqttGateway, and it seems to need these two info, state_topic and command_topic, but I guess I’m too ignorant to understand :frowning:

I just tried your automation on my test system, and it seemed to work fine, so I don’t know why you are not getting a trigger.

I’m afraid I can’t help you with the front end - I don’t really use it.

The openMqttGateway just detects the 433 MHz signal from the button press and generates an MQTT message from it - I have been using it for over a year.

The switch needs a state_topic and a command_topic, but this doesn’t really correspond to your usage. I think you just want something to change when you press the button, and your automation does that - at least on my system.

Edit:
I think I see the problem. The OpenMQTTGateway sends the messages on the topic home/433toMQTT. It is messages to the gateway that use the other topic. You need to change your automation to

- alias: 'Remote Full'
  trigger:
    platform: mqtt
    topic: "home/433toMQTT" # defined by OpenMqttGateway
    payload: "1234567"
  action:
   - service: scene.turn_on
     entity_id: scene.full

and it should be fine.

I was just testing by sending the message from mosquitto_pub, and didn’t notice the discrepancy. :roll_eyes:

IT WORKS!
You’re great man, I was trying to do this but, shame on me, I know too little of the MQTT to understand correctly.
Thanks a lot, this is definitely solved!

1 Like