# TCP relay card controlled by two sources, how to keep in sync?

**URL:** https://discourse.nodered.org/t/tcp-relay-card-controlled-by-two-sources-how-to-keep-in-sync/68223
**Category:** Dashboard
**Created:** [26 September 2022 08:47 UTC](https://discourse.nodered.org/t/tcp-relay-card-controlled-by-two-sources-how-to-keep-in-sync/68223 "2022-09-26T08:47:57Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Abon](https://avatars.discourse-cdn.com/v4/letter/a/45deac/32.png) [@Abon](https://discourse.nodered.org/u/Abon)
#### Post date: [26 September 2022 08:47 UTC](https://discourse.nodered.org/t/tcp-relay-card-controlled-by-two-sources-how-to-keep-in-sync/68223/1 "2022-09-26T08:47:57Z")

</div>

I have a TCP relay board which is controlled by a function. I want to be able to control each relay from two sources, namely a dashboard switch and also a Google Home (Nora) switch. What is the best way to ensure the display on the dashboard and in Google Home app both reflect the current state of the switch?

I worked out if I connect both switch outputs to the activating function and also feed each switch output back to the input of the other switch it works. The only down side is, when operating the switch from Google Home, the message gets sent twice to the relay board. Not a major problem but surely there is a better way?

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [26 September 2022 08:57 UTC](https://discourse.nodered.org/t/tcp-relay-card-controlled-by-two-sources-how-to-keep-in-sync/68223/2 "2022-09-26T08:57:00Z")

</div>

(Just throwing it out there)

On each machine: when you send an `ON` or `OFF` command, it is also published on `MQTT`.

Then on each machine you subscribe to that topic and it _imposes_ the state to an indicator.

## OR

Use a `TCP IN` node and forget about `MQTT`.

(Sorry)

If you can post the basic part where you have an `inject` (2 actaully) node to turning the relay on/off and the `TCP-OUT` node.

Then I could show you what I mean with the second bit.

---

<div class="post-metadata">

### Author: ![Buckskin](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Buckskin](https://discourse.nodered.org/u/Buckskin)
#### Post date: [26 September 2022 14:24 UTC](https://discourse.nodered.org/t/tcp-relay-card-controlled-by-two-sources-how-to-keep-in-sync/68223/3 "2022-09-26T14:24:47Z")

</div>

Use a filter node on output to Google and use output from switch to determine current state (not switch output as this does not necessarily represent device state)

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [26 October 2022 14:24 UTC](https://discourse.nodered.org/t/tcp-relay-card-controlled-by-two-sources-how-to-keep-in-sync/68223/4 "2022-10-26T14:24:59Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
