# Event-triggered flow to switch on/off rf-plug

**URL:** https://discourse.nodered.org/t/event-triggered-flow-to-switch-on-off-rf-plug/74306
**Category:** General
**Created:** [28 January 2023 14:55 UTC](https://discourse.nodered.org/t/event-triggered-flow-to-switch-on-off-rf-plug/74306 "2023-01-28T14:55:46Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![KlausR](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@KlausR](https://discourse.nodered.org/u/KlausR)
#### Post date: [28 January 2023 14:55 UTC](https://discourse.nodered.org/t/event-triggered-flow-to-switch-on-off-rf-plug/74306/1 "2023-01-28T14:55:46Z")

</div>

Absolute newbie in terms of nodered and hass needs a little help...^^

I managed to turn on/off almost with 2 nodes:

1. inject node with msg.payload like "#123456"
2. mqtt-out node with topic "cmnd/tasmota/rfbridge/RfCode"

Now i need to exchange inject node with...? I guess, event node, but i don`t know how ...

Thanx in advance!  
Klaus

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [28 January 2023 14:57 UTC](https://discourse.nodered.org/t/event-triggered-flow-to-switch-on-off-rf-plug/74306/2 "2023-01-28T14:57:21Z")

</div>

Welcome to the forum Klaus.

> [@KlausR](#):
>
> Now i need to exchange inject node with...? I guess, event node, but i don`t know how ...

You haven't told us how you want to trigger it. User input, some other device? ...

---

<div class="post-metadata">

### Author: ![KlausR](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@KlausR](https://discourse.nodered.org/u/KlausR)
#### Post date: [28 January 2023 15:01 UTC](https://discourse.nodered.org/t/event-triggered-flow-to-switch-on-off-rf-plug/74306/3 "2023-01-28T15:01:22Z")

</div>

sry, sure. By motion sensor.

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [28 January 2023 15:23 UTC](https://discourse.nodered.org/t/event-triggered-flow-to-switch-on-off-rf-plug/74306/4 "2023-01-28T15:23:52Z")

</div>

How does that motion sensor talk ? mqtt ? rfbridge ? zigbee ?

---

<div class="post-metadata">

### Author: ![KlausR](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@KlausR](https://discourse.nodered.org/u/KlausR)
#### Post date: [28 January 2023 15:28 UTC](https://discourse.nodered.org/t/event-triggered-flow-to-switch-on-off-rf-plug/74306/5 "2023-01-28T15:28:39Z")

</div>

zigbee - zigbee2mwtt - mqtt. Integration in hass is fine

---

<div class="post-metadata">

### Author: ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)
#### Post date: [28 January 2023 15:34 UTC](https://discourse.nodered.org/t/event-triggered-flow-to-switch-on-off-rf-plug/74306/6 "2023-01-28T15:34:54Z")

</div>

If you add an MQTT in node and set the topic to match what the PIR is using, then attach this to a debug node you will be able to see the messages that come in when the PIR is activated.

Once you know that you can progress furthur - Share here what you see in the debug output.

---

<div class="post-metadata">

### Author: ![KlausR](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@KlausR](https://discourse.nodered.org/u/KlausR)
#### Post date: [28 January 2023 15:41 UTC](https://discourse.nodered.org/t/event-triggered-flow-to-switch-on-off-rf-plug/74306/7 "2023-01-28T15:41:44Z")

</div>

thank you so far. Gonna have a try... ^^

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [28 January 2023 16:48 UTC](https://discourse.nodered.org/t/event-triggered-flow-to-switch-on-off-rf-plug/74306/8 "2023-01-28T16:48:36Z")

</div>

Keep in mind that most people on this forum don't use home assistant (they let node-red do everything instead). With a mqtt node connecting to the broker directly and listening on the zigbee2mqtt topic will work (I use it myself in the same manner).

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [28 January 2023 19:21 UTC](https://discourse.nodered.org/t/event-triggered-flow-to-switch-on-off-rf-plug/74306/9 "2023-01-28T19:21:33Z")

</div>

Yup, me too.

---

<div class="post-metadata">

### Author: ![KlausR](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@KlausR](https://discourse.nodered.org/u/KlausR)
#### Post date: [28 January 2023 20:07 UTC](https://discourse.nodered.org/t/event-triggered-flow-to-switch-on-off-rf-plug/74306/10 "2023-01-28T20:07:34Z")

</div>

> [@bakman2](#):
>
> With a mqtt node connecting to the broker directly and listening on the zigbee2mqtt topic

Please don't forget my knowledge with Node-Red. It does not exist or hardly exists. HOW? Which node do you use for PIR? And where can i adjust the payload?

Found a solution by trying...^^

Starting with event state node. Changed nothing but choosing PIR entity, "If state = on", state type string

My solution between that and mqtt-out node is change node. (exactly i was looking for). Can set my msg.payload there. Of course 2 of them, on/off.

Thank you anyway.

---

<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: [29 March 2023 20:07 UTC](https://discourse.nodered.org/t/event-triggered-flow-to-switch-on-off-rf-plug/74306/11 "2023-03-29T20:07:58Z")

</div>

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