# Help me stop repeating message. (Super noob)

**URL:** <https://discourse.nodered.org/t/help-me-stop-repeating-message-super-noob/70832>\
**Category:** General\
**Created:** [18 November 2022 13:09 UTC](https://discourse.nodered.org/t/help-me-stop-repeating-message-super-noob/70832 "2022-11-18T13:09:34Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![lemehavit](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lemehavit/32/70963_2.png) [@lemehavit](https://discourse.nodered.org/u/lemehavit)\
**Post date:** [18 November 2022 13:09 UTC](https://discourse.nodered.org/t/help-me-stop-repeating-message-super-noob/70832/1 "2022-11-18T13:09:34Z")

</div>

Hi I’m completely new to node red and I tried for hours to figure this out and need some help.

I made a very simple flow that checks current electricity prices and turn on or off my AC unit. Base on specific values, now set to \<2 turn on \>2 turn off.

Problem is that the electricity price updates ones an hour and send for example a turn on message every hour even if it’s already turned on. My unit beeps every time so would like it to only send the message if it is not already in the current state.

I can’t get the state inform of the AC unit as I can only use scenes to turn off or on.

Any one have a clever and hopefully easy method to not send a turn on messages if its already turned on?

---

<div class="post-metadata">

**Author:** ![gemini86](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gemini86/32/70967_2.png) [@gemini86](https://discourse.nodered.org/u/gemini86)\
**Post date:** [18 November 2022 13:12 UTC](https://discourse.nodered.org/t/help-me-stop-repeating-message-super-noob/70832/2 "2022-11-18T13:12:22Z")

</div>

Check out the filter node (formerly RBE node)

Posting your flow using the triple backticks in a code block (```code```) will help us see where things are going wrong or right.

---

<div class="post-metadata">

**Author:** ![lemehavit](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lemehavit/32/70963_2.png) [@lemehavit](https://discourse.nodered.org/u/lemehavit)\
**Post date:** [18 November 2022 13:32 UTC](https://discourse.nodered.org/t/help-me-stop-repeating-message-super-noob/70832/3 "2022-11-18T13:32:04Z")

</div>

Thank you, below is a picture of the flow and further down I think is the code.

 ![Skärmbild 2022-11-18 142748](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bdf76e9f78cda1e85623f18a0bc2acc034b851a7.png)

```auto
[
    {
        "id": "6a09e8e444b558c5",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "a6600699e1f126fa",
        "type": "debug",
        "z": "6a09e8e444b558c5",
        "name": "debug 1",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 580,
        "y": 140,
        "wires": []
    },
    {
        "id": "298d04b3d453a432",
        "type": "server-state-changed",
        "z": "6a09e8e444b558c5",
        "name": "El pris",
        "server": "c2c0d2e9.e099e",
        "version": 4,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "entityidfilter": "sensor.electricity_price_skogsvagen_47",
        "entityidfiltertype": "exact",
        "outputinitially": true,
        "state_type": "str",
        "haltifstate": "2",
        "halt_if_type": "num",
        "halt_if_compare": "lt",
        "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": 70,
        "y": 120,
        "wires": [
            [
                "eaa5d84f38fb8f8b"
            ],
            [
                "aecb8dac276442b0"
            ]
        ]
    },
    {
        "id": "eaa5d84f38fb8f8b",
        "type": "api-call-service",
        "z": "6a09e8e444b558c5",
        "name": "Starta AC 23C",
        "server": "c2c0d2e9.e099e",
        "version": 5,
        "debugenabled": true,
        "domain": "homeassistant",
        "service": "turn_on",
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "scene.mitsubishi_cold_23degc_auto"
        ],
        "data": "",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 300,
        "y": 80,
        "wires": [
            [
                "a6600699e1f126fa"
            ]
        ]
    },
    {
        "id": "aecb8dac276442b0",
        "type": "api-call-service",
        "z": "6a09e8e444b558c5",
        "name": "Stäng av AC",
        "server": "c2c0d2e9.e099e",
        "version": 5,
        "debugenabled": true,
        "domain": "homeassistant",
        "service": "turn_on",
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "scene.mitsubishi_power_off"
        ],
        "data": "",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 290,
        "y": 160,
        "wires": [
            [
                "a6600699e1f126fa"
            ]
        ]
    },
    {
        "id": "c2c0d2e9.e099e",
        "type": "server",
        "name": "Home Assistant",
        "addon": true
    }
]

```

[Edited by moderator]

---

<div class="post-metadata">

**Author:** ![gemini86](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gemini86/32/70967_2.png) [@gemini86](https://discourse.nodered.org/u/gemini86)\
**Post date:** [18 November 2022 13:35 UTC](https://discourse.nodered.org/t/help-me-stop-repeating-message-super-noob/70832/4 "2022-11-18T13:35:47Z")

</div>

Ah, home assistant again...

somebody familiar with that maybe could chime in, I don't mess with it, since I like to be in control of the data requests/state handlers etc.

Is the first node configurable for only one output? then a switch node and a filter node could be used to toggle the AC only on state change.

---

<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:** [18 November 2022 13:49 UTC](https://discourse.nodered.org/t/help-me-stop-repeating-message-super-noob/70832/5 "2022-11-18T13:49:12Z")

</div>

> [@lemehavit](#):
>
> and further down I think is the code.

Sadly not!  
To post code in the forum:

1. Export your flow JSON, preferably in "compact" rather than "formatted" layout (these are buttons on the JSON tab of the export dialog)
2. In your post here click the `</>` button
3. Paste your code so that it replaces the highlighted "type or paste code here"

You posted code as a quote and the forum software has replaced some parts of it with a square non-printing character.

---

<div class="post-metadata">

**Author:** ![lemehavit](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lemehavit/32/70963_2.png) [@lemehavit](https://discourse.nodered.org/u/lemehavit)\
**Post date:** [18 November 2022 13:53 UTC](https://discourse.nodered.org/t/help-me-stop-repeating-message-super-noob/70832/6 "2022-11-18T13:53:33Z")

</div>

sorry about that, let's try agan then.

```auto
[{"id":"6a09e8e444b558c5","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"a6600699e1f126fa","type":"debug","z":"6a09e8e444b558c5","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":580,"y":140,"wires":[]},{"id":"298d04b3d453a432","type":"server-state-changed","z":"6a09e8e444b558c5","name":"El price","server":"c2c0d2e9.e099e","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.electricity_price_skogsvagen_47","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"2","halt_if_type":"num","halt_if_compare":"lt","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":70,"y":120,"wires":[["eaa5d84f38fb8f8b"],["aecb8dac276442b0"]]},{"id":"eaa5d84f38fb8f8b","type":"api-call-service","z":"6a09e8e444b558c5","name":"Turn on AC 23C","server":"c2c0d2e9.e099e","version":5,"debugenabled":true,"domain":"homeassistant","service":"turn_on","areaId":[],"deviceId":[],"entityId":["scene.mitsubishi_cold_23degc_auto"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":300,"y":80,"wires":[["a6600699e1f126fa"]]},{"id":"aecb8dac276442b0","type":"api-call-service","z":"6a09e8e444b558c5","name":"Turn Off AC","server":"c2c0d2e9.e099e","version":5,"debugenabled":true,"domain":"homeassistant","service":"turn_on","areaId":[],"deviceId":[],"entityId":["scene.mitsubishi_power_off"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":290,"y":160,"wires":[["a6600699e1f126fa"]]},{"id":"c2c0d2e9.e099e","type":"server","name":"Home Assistant","addon":true}]

```

---

<div class="post-metadata">

**Author:** ![gemini86](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gemini86/32/70967_2.png) [@gemini86](https://discourse.nodered.org/u/gemini86)\
**Post date:** [18 November 2022 13:54 UTC](https://discourse.nodered.org/t/help-me-stop-repeating-message-super-noob/70832/7 "2022-11-18T13:54:55Z")

</div>

> [@jbudd](#):
>
> You posted code as a quote and the forum software has replaced some parts of it with a square non-printing character.

Ah yes, the elusive _empty array_.

---

<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:** [18 November 2022 14:01 UTC](https://discourse.nodered.org/t/help-me-stop-repeating-message-super-noob/70832/8 "2022-11-18T14:01:54Z")

</div>

Yes is`[]` but the forum will also mangle other bits, HTML tags for instance.

---

<div class="post-metadata">

**Author:** ![lemehavit](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lemehavit/32/70963_2.png) [@lemehavit](https://discourse.nodered.org/u/lemehavit)\
**Post date:** [19 November 2022 08:19 UTC](https://discourse.nodered.org/t/help-me-stop-repeating-message-super-noob/70832/9 "2022-11-19T08:19:20Z")

</div>

Just thinking out loud. Would it be possible to write some code using the function node that only sends the message forward if the value changes from less than 2 to above 2. So that any changes that happen below 2 is halted?

Would that sort coding be hard to do?

---

<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:** [19 November 2022 13:05 UTC](https://discourse.nodered.org/t/help-me-stop-repeating-message-super-noob/70832/10 "2022-11-19T13:05:10Z")

</div>

It would be easy enough to insert a node in the wire I have coloured red:

 ![Untitled 1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/6/7697b3f3c0c572efa3f51e443f1322ff1296a651.jpeg)  
A Filter might block all duplicates, a Switch might block all messages below a certain value, or a Function could do whatever you like.

But imagine the energy price rises. Presumably a [different] message is sent down the yellow wire and AC is turned off. Then prices fall again. How is the "block repeated messages" node going to know that this "turn on" message has to be allowed through?

---

<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:** [18 January 2023 13:05 UTC](https://discourse.nodered.org/t/help-me-stop-repeating-message-super-noob/70832/11 "2023-01-18T13:05:44Z")

</div>

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