MQTT Switch to MQTT Relay

Hello.
Can’t get automation to work.
I have made a mqtt switch, and I have another mqtt with relay on it to control the lights.
How to connect 2 of them, to work as one.
When I press my switch, I want the other mqtt device to turn on in automation.
Tried several examples, but nothing helps

from automations.yaml

  • alias: example
    trigger:
    platform: mqtt
    topic: “stat/kmx1/POWER2”
    action:
    service: switch.turn_on
    entity_id: switch.example

Simply use the same command topic… You can skip automation…

can share with you quick example from my automation

Task… On open gate (power1 ON) switch ON external lights only after sunset…

alias: 'Swiatła On brama Open ’
description: ‘’
trigger:

  • payload: ‘ON’
    platform: mqtt
    topic: stat/brama/POWER1
    condition:
  • condition: or
    conditions:
    • after: sunset
      condition: sun
    • before: sunrise
      condition: sun
      action:
  • data: {}
    entity_id: switch.lampy_front
    service: switch.turn_on

So in my opinion there is missing payload and trigger…
This simple automation was created by creator… it is very simple…in your case just skip condition part…

1 Like

Thanks. Will try that later