MQTT switch on rpi1 and light on rpi2

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
goblin
Posts: 37
Joined: Sunday 23 July 2017 14:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: Haarlemmermeer
Contact:

MQTT switch on rpi1 and light on rpi2

Post by goblin »

hello experts,
i have two Rpi's with Domoticz and want to use a switch button on the client to switch a light on the server and v.v. via MQTT
Sounds simple but can't get it work.
assume i have a situation like mentioned in "https://www.domoticz.com/wiki/MQTT#Architecture" where "other" is my second Rpi.
Can i use "on Action/Off Action" at edit light-switch ?

Thanks,

RPI 3
Mysensors gateway,
rflink Gateway
esp8266
User avatar
waltervl
Posts: 5904
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: MQTT switch on rpi1 and light on rpi2

Post by waltervl »

Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: MQTT switch on rpi1 and light on rpi2

Post by waaren »

goblin wrote: Thursday 15 April 2021 23:10 Can i use "on Action/Off Action" at edit light-switch ?
If there is no specific need to use MQTT you could simply use

Code: Select all

http://<target domoticz ip: target domoticz port>/json.htm?type=command&param=switchlight&idx=<target device idx>&switchcmd=On
http://<target domoticz ip: target domoticz port>/json.htm?type=command&param=switchlight&idx=<target device idx>&switchcmd=Off  
in the On Action / Off Action fields of the edit switch screen of the source system.

You will have to allow password-less access for your home LAN (Settings: LOcal Networks (no username / password) or include passwords in the JSON API for this to work.
Using this method you are not limited by the requirements of the shared devices setup (same endian / same version)
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
xury
Posts: 48
Joined: Monday 10 December 2018 23:32
Target OS: Linux
Domoticz version:
Location: Poland
Contact:

Re: MQTT switch on rpi1 and light on rpi2

Post by xury »

I've done a Node-Red flow named Domoticz to Domoticz. You can adapt it to you. Is available on the node Red site.
With kind of switch device you use?
goblin
Posts: 37
Joined: Sunday 23 July 2017 14:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: Haarlemmermeer
Contact:

Re: MQTT switch on rpi1 and light on rpi2

Post by goblin »

tenx
let's dive into it this weekend.
should get something to work :P
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest