# Problem with current state

**URL:** <https://discourse.nodered.org/t/problem-with-current-state/58599>\
**Category:** General\
**Created:** [18 February 2022 12:55 UTC](https://discourse.nodered.org/t/problem-with-current-state/58599 "2022-02-18T12:55:33Z")\
**Posts on this page:** 9\
**Page:** 2

<div class="post-metadata">

**Author:** ![Leopoll](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/leopoll/32/70361_2.png) [@Leopoll](https://discourse.nodered.org/u/Leopoll)\
**Post date:** [23 February 2022 17:45 UTC](https://discourse.nodered.org/t/problem-with-current-state/58599/21 "2022-02-23T17:45:04Z")

</div>

Is it normal that the command to turn on the lamp will come every time, even if the lamp is already on?  
And it seems that the switch node is not needed here. Messages can be received directly from timestamp 1 and 2.

---

<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:** [23 February 2022 17:58 UTC](https://discourse.nodered.org/t/problem-with-current-state/58599/22 "2022-02-23T17:58:10Z")

</div>

> [@Leopoll](#):
>
> Is it normal that the command to turn on the lamp will come every time, even if the lamp is already on?

The flow will do that. It shouldn't matter, but if it bothers you put a Filter node in the output to stop the repeats

> [@Leopoll](#):
>
> the switch node is not needed here.

If you haven't got the Switch then a motion end message when motion has not started will switch the light on.

---

<div class="post-metadata">

**Author:** ![Leopoll](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/leopoll/32/70361_2.png) [@Leopoll](https://discourse.nodered.org/u/Leopoll)\
**Post date:** [23 February 2022 18:10 UTC](https://discourse.nodered.org/t/problem-with-current-state/58599/23 "2022-02-23T18:10:38Z")

</div>

> [@Colin](#):
>
> If you haven't got the Switch then a motion end message when motion has not started will switch the light on.

Why?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/b/1b0756aba46b8d72ee6f015609e35f5931759707.png)

---

<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:** [23 February 2022 18:54 UTC](https://discourse.nodered.org/t/problem-with-current-state/58599/24 "2022-02-23T18:54:23Z")

</div>

You have removed the wire from the bottom inject to the change node

---

<div class="post-metadata">

**Author:** ![ceysa75](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ceysa75/32/31340_2.png) [@ceysa75](https://discourse.nodered.org/u/ceysa75)\
**Post date:** [23 February 2022 20:07 UTC](https://discourse.nodered.org/t/problem-with-current-state/58599/25 "2022-02-23T20:07:00Z")

</div>

This is exactly how I realized it with my Hue Motion Sensors

---

<div class="post-metadata">

**Author:** ![ceysa75](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ceysa75/32/31340_2.png) [@ceysa75](https://discourse.nodered.org/u/ceysa75)\
**Post date:** [23 February 2022 20:10 UTC](https://discourse.nodered.org/t/problem-with-current-state/58599/26 "2022-02-23T20:10:34Z")

</div>

Leopoll, of course you are right if considering this simple example. However, the occupied/not occupied message usually comes from one and the same node. Therefore, a switch node is required.

---

<div class="post-metadata">

**Author:** ![Leopoll](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/leopoll/32/70361_2.png) [@Leopoll](https://discourse.nodered.org/u/Leopoll)\
**Post date:** [23 February 2022 21:15 UTC](https://discourse.nodered.org/t/problem-with-current-state/58599/27 "2022-02-23T21:15:38Z")

</div>

I am using the library "node-red-contrib-home-assistant-websocket" because the server based on Home Assistant. This library has a device node. This node specifies a trigger, so you get two different nodes for occupied/not occupied.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/7/279f6be67e73ff0196edfe6c901b5b94274131f9.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/b/ab88c55b1b00a520e8aa7542076810fff016d4db.png)

---

<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:** [23 February 2022 21:34 UTC](https://discourse.nodered.org/t/problem-with-current-state/58599/28 "2022-02-23T21:34:25Z")

</div>

> [@Leopoll](#):
>
> you get two different nodes for occupied/not occupied.

In that case then yes, you don't need the switch as that is effectively included in the HA nodes.

---

<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:** [24 April 2022 21:34 UTC](https://discourse.nodered.org/t/problem-with-current-state/58599/29 "2022-04-24T21:34:55Z")

</div>

Closed on 24 April 2022 21:34 UTC

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

[Previous page](https://discourse.nodered.org/t/problem-with-current-state/58599.md?page=1)
