# Watch smart-plug for power usage ans switch on/off other smart-plug

**URL:** <https://discourse.nodered.org/t/watch-smart-plug-for-power-usage-ans-switch-on-off-other-smart-plug/55847>\
**Category:** General\
**Created:** [29 December 2021 15:21 UTC](https://discourse.nodered.org/t/watch-smart-plug-for-power-usage-ans-switch-on-off-other-smart-plug/55847 "2021-12-29T15:21:51Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![adrieg](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/adrieg/32/47897_2.png) [@adrieg](https://discourse.nodered.org/u/adrieg)\
**Post date:** [29 December 2021 15:21 UTC](https://discourse.nodered.org/t/watch-smart-plug-for-power-usage-ans-switch-on-off-other-smart-plug/55847/1 "2021-12-29T15:21:51Z")

</div>

How can I create an sequence so a smart-plug will be watched and if power usage is above 1 watt the other plug turns on. I have made a sequence but that only works when I turn on the 1st plug and it only runs once.

Hope someone van help me. This is my sequence I'm using.

```auto
[{"id":"bea4e2293c75a78f","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"fbc345c4fe2fb6d2","type":"server-state-changed","z":"bea4e2293c75a78f","name":"Houtbewerking","server":"a465afba.fb6ee","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"switch.houtbewerking_local","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":120,"y":280,"wires":[["ca459df7c0fe8781"],[]]},{"id":"ca459df7c0fe8781","type":"ha-wait-until","z":"bea4e2293c75a78f","name":"","server":"a465afba.fb6ee","version":0,"outputs":2,"entityId":"switch.houtbewerking_local","entityIdFilterType":"exact","property":"attributes.current_consumption","comparator":"lt","value":"1","valueType":"num","timeout":"1","timeoutType":"num","timeoutUnits":"seconds","entityLocation":"","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":380,"y":280,"wires":[["dbb93dc2e3ff85c5"],["a68a4df249a64646"]]},{"id":"dbb93dc2e3ff85c5","type":"api-call-service","z":"bea4e2293c75a78f","name":"Stofzuiger-Uit","server":"a465afba.fb6ee","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.stofzuiger_local","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":720,"y":240,"wires":[[]]},{"id":"a68a4df249a64646","type":"api-call-service","z":"bea4e2293c75a78f","name":"Stofzuiger-Aan","server":"a465afba.fb6ee","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.stofzuiger_local","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":720,"y":320,"wires":[[]]},{"id":"a465afba.fb6ee","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [29 December 2021 15:42 UTC](https://discourse.nodered.org/t/watch-smart-plug-for-power-usage-ans-switch-on-off-other-smart-plug/55847/2 "2021-12-29T15:42:56Z")

</div>

Welcome to the forum @adrieg

When posting a flow please paste it inline using the `</>` button at the top of the forum entry field, rather that attaching it. That makes it easier for us to pick up. You can edit your post by clicking the pen icon at the bottom, then remove the attachment and paste the flow in. Thanks.

---

<div class="post-metadata">

**Author:** ![adrieg](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/adrieg/32/47897_2.png) [@adrieg](https://discourse.nodered.org/u/adrieg)\
**Post date:** [29 December 2021 15:44 UTC](https://discourse.nodered.org/t/watch-smart-plug-for-power-usage-ans-switch-on-off-other-smart-plug/55847/3 "2021-12-29T15:44:47Z")

</div>

Thank you Colling.  
Changed the passed code.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [29 December 2021 15:47 UTC](https://discourse.nodered.org/t/watch-smart-plug-for-power-usage-ans-switch-on-off-other-smart-plug/55847/4 "2021-12-29T15:47:29Z")

</div>

You didn't mention that you were using Home Assistant. Few (if any) here use it. For HA specific questions you may be better asking on an HA forum.

---

<div class="post-metadata">

**Author:** ![adrieg](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/adrieg/32/47897_2.png) [@adrieg](https://discourse.nodered.org/u/adrieg)\
**Post date:** [29 December 2021 15:49 UTC](https://discourse.nodered.org/t/watch-smart-plug-for-power-usage-ans-switch-on-off-other-smart-plug/55847/5 "2021-12-29T15:49:13Z")

</div>

Ok Collin.  
I will ask it there to.  
But I also think its a general thing I am missing.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [29 December 2021 15:57 UTC](https://discourse.nodered.org/t/watch-smart-plug-for-power-usage-ans-switch-on-off-other-smart-plug/55847/6 "2021-12-29T15:57:39Z")

</div>

My smart plugs are flashed with Tasmota, no doubt other devices have similar abilities  
They send consumption data over MQTT on request and respond to MQTT commands.

 ![Untitled 5](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/5/259101b672305cbaf02e90245b7d724d0291c7f0.jpeg)

---

<div class="post-metadata">

**Author:** ![adrieg](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/adrieg/32/47897_2.png) [@adrieg](https://discourse.nodered.org/u/adrieg)\
**Post date:** [29 December 2021 16:03 UTC](https://discourse.nodered.org/t/watch-smart-plug-for-power-usage-ans-switch-on-off-other-smart-plug/55847/7 "2021-12-29T16:03:10Z")

</div>

Thank you jbudd  
I don't know how to use MQTT.  
The sequence you are showing looks just what I am looking for. I think. 🙂

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [29 December 2021 16:30 UTC](https://discourse.nodered.org/t/watch-smart-plug-for-power-usage-ans-switch-on-off-other-smart-plug/55847/8 "2021-12-29T16:30:05Z")

</div>

> [@adrieg](#):
>
> I don't know how to use MQTT.

See this excellent tutorial [MQTT Essentials - All Core Concepts Explained](https://www.hivemq.com/mqtt-essentials/)

---

<div class="post-metadata">

**Author:** ![adrieg](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/adrieg/32/47897_2.png) [@adrieg](https://discourse.nodered.org/u/adrieg)\
**Post date:** [30 December 2021 10:21 UTC](https://discourse.nodered.org/t/watch-smart-plug-for-power-usage-ans-switch-on-off-other-smart-plug/55847/9 "2021-12-30T10:21:21Z")

</div>

Solved it with the Poll state node.  
Maybe its not the best way but it works for me.

```auto
[{"id":"ca459df7c0fe8781","type":"ha-wait-until","z":"bea4e2293c75a78f","name":"","server":"a465afba.fb6ee","version":0,"outputs":2,"entityId":"switch.houtbewerking_local","entityIdFilterType":"exact","property":"attributes.current_consumption","comparator":"lt","value":"1","valueType":"num","timeout":"1","timeoutType":"num","timeoutUnits":"seconds","entityLocation":"","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":500,"y":160,"wires":[["dbb93dc2e3ff85c5"],["a68a4df249a64646"]]},{"id":"dbb93dc2e3ff85c5","type":"api-call-service","z":"bea4e2293c75a78f","name":"Stofzuiger-Uit","server":"a465afba.fb6ee","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.stofzuiger_local","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":840,"y":120,"wires":[[]]},{"id":"a68a4df249a64646","type":"api-call-service","z":"bea4e2293c75a78f","name":"Stofzuiger-Aan","server":"a465afba.fb6ee","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.stofzuiger_local","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":840,"y":200,"wires":[[]]},{"id":"76f204fee3730d15","type":"poll-state","z":"bea4e2293c75a78f","name":"","server":"a465afba.fb6ee","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"updateinterval":"2","updateIntervalType":"num","updateIntervalUnits":"seconds","outputinitially":false,"outputonchanged":false,"entity_id":"switch.houtbewerking_local","state_type":"str","halt_if":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"x":190,"y":160,"wires":[["ca459df7c0fe8781"],[]]},{"id":"a465afba.fb6ee","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]

```

---

<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:** [28 February 2022 10:22 UTC](https://discourse.nodered.org/t/watch-smart-plug-for-power-usage-ans-switch-on-off-other-smart-plug/55847/10 "2022-02-28T10:22:17Z")

</div>

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