Help me stop repeating message. (Super noob)

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?

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.

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

[
    {
        "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]

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.

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.

sorry about that, let's try agan then.

[{"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}]

Ah yes, the elusive empty array.

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

1 Like

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?

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


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?

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