Supergiovane / node-red-contrib-boolean-logic-ultimate

Enhanced boolean logic with persistent values after reboot and more
https://www.youtube.com/watch?v=sYc6L5QQrTw&list=PL9Yh1bjbLAYoRH4IyQB7EL5srHAihiKpy
MIT License
31 stars 4 forks source link

Getting "Received invalid topic" #19

Closed markus-fischbacher closed 2 years ago

markus-fischbacher commented 2 years ago

Hi there,

I'm getting always the message "Received invalid topic" when inserting 5 boolean into OR logic. I've no idea what I'm doing wrong.

NodeRed: 2.1.4 Logic-Ultimate: 1.0.39

Any help is appreciated.

Kind regards, Markus

image

[
    {
        "id": "f3705579e0700f54",
        "type": "tab",
        "label": "Heizung",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "4a8d6d981986f82e",
        "type": "hb-event",
        "z": "f3705579e0700f54",
        "name": "Thermostat Wohnzimmer",
        "Homebridge": "HOOBS",
        "Manufacturer": "mqttthing",
        "Service": "Thermostat",
        "device": "HOOBSBF:42:9D:EF:8C:0CmqttthingThermostat Wohnzimmer0000004A",
        "conf": "49807f87018f55ea",
        "x": 170,
        "y": 60,
        "wires": [
            [
                "1e88dd1358c1fdf1"
            ]
        ]
    },
    {
        "id": "3345e96c60bdcd4e",
        "type": "hb-control",
        "z": "f3705579e0700f54",
        "name": "Pumpe",
        "Homebridge": "HOOBS",
        "Manufacturer": "Tasmota",
        "Service": "Switch",
        "device": "HOOBSBF:42:9D:EF:8C:0CTasmotaPumpe00000049",
        "conf": "49807f87018f55ea",
        "outputs": 0,
        "x": 760,
        "y": 600,
        "wires": []
    },
    {
        "id": "f931d5486eb44f35",
        "type": "hb-control",
        "z": "f3705579e0700f54",
        "name": "STB Ventil",
        "Homebridge": "HOOBS",
        "Manufacturer": "Tasmota",
        "Service": "Switch",
        "device": "HOOBSBF:42:9D:EF:8C:0CTasmotaSTB Ventil00000049",
        "conf": "49807f87018f55ea",
        "outputs": 0,
        "x": 770,
        "y": 660,
        "wires": []
    },
    {
        "id": "6ffa989fa8f163e6",
        "type": "hb-control",
        "z": "f3705579e0700f54",
        "name": "Ventil Wohnzimmer",
        "Homebridge": "HOOBS",
        "Manufacturer": "Tasmota",
        "Service": "Switch",
        "device": "HOOBSBF:42:9D:EF:8C:0CTasmotaVentil Wohnzimmer00000049",
        "conf": "49807f87018f55ea",
        "outputs": 0,
        "x": 790,
        "y": 60,
        "wires": []
    },
    {
        "id": "1a099652fdb0bbc5",
        "type": "function",
        "z": "f3705579e0700f54",
        "name": "Convert CMD",
        "func": "msg.payload = { \"On\": msg.payload};\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 580,
        "y": 60,
        "wires": [
            [
                "6ffa989fa8f163e6"
            ]
        ]
    },
    {
        "id": "24dc350efbd954f4",
        "type": "hb-event",
        "z": "f3705579e0700f54",
        "name": "Thermostat Leo",
        "Homebridge": "HOOBS",
        "Manufacturer": "mqttthing",
        "Service": "Thermostat",
        "device": "HOOBSBF:42:9D:EF:8C:0CmqttthingThermostat Leo0000004A",
        "conf": "49807f87018f55ea",
        "x": 140,
        "y": 160,
        "wires": [
            [
                "9fc052423b62d5dc"
            ]
        ]
    },
    {
        "id": "dcc6d5601f1ca999",
        "type": "hb-control",
        "z": "f3705579e0700f54",
        "name": "Ventil Leo",
        "Homebridge": "HOOBS",
        "Manufacturer": "Tasmota",
        "Service": "Switch",
        "device": "HOOBSBF:42:9D:EF:8C:0CTasmotaVentil Leo00000049",
        "conf": "49807f87018f55ea",
        "outputs": 0,
        "x": 760,
        "y": 160,
        "wires": []
    },
    {
        "id": "2cd9396862e4dc53",
        "type": "hb-event",
        "z": "f3705579e0700f54",
        "name": "Thermostat Eltern",
        "Homebridge": "HOOBS",
        "Manufacturer": "mqttthing",
        "Service": "Thermostat",
        "device": "HOOBSBF:42:9D:EF:8C:0CmqttthingThermostat Eltern0000004A",
        "conf": "49807f87018f55ea",
        "x": 150,
        "y": 260,
        "wires": [
            [
                "9b8e6f5534cda354"
            ]
        ]
    },
    {
        "id": "cbc3827f914a6a8a",
        "type": "hb-control",
        "z": "f3705579e0700f54",
        "name": "Ventil Eltern",
        "Homebridge": "HOOBS",
        "Manufacturer": "Tasmota",
        "Service": "Switch",
        "device": "HOOBSBF:42:9D:EF:8C:0CTasmotaVentil Eltern00000049",
        "conf": "49807f87018f55ea",
        "outputs": 0,
        "x": 770,
        "y": 260,
        "wires": []
    },
    {
        "id": "133b5d139660ac40",
        "type": "hb-event",
        "z": "f3705579e0700f54",
        "name": "Thermostat Bad",
        "Homebridge": "HOOBS",
        "Manufacturer": "mqttthing",
        "Service": "Thermostat",
        "device": "HOOBSBF:42:9D:EF:8C:0CmqttthingThermostat Bad0000004A",
        "conf": "49807f87018f55ea",
        "x": 140,
        "y": 360,
        "wires": [
            [
                "eb34c3a39e752594"
            ]
        ]
    },
    {
        "id": "a0382f19759897a0",
        "type": "hb-control",
        "z": "f3705579e0700f54",
        "name": "Ventil Bad",
        "Homebridge": "HOOBS",
        "Manufacturer": "Tasmota",
        "Service": "Switch",
        "device": "HOOBSBF:42:9D:EF:8C:0CTasmotaVentil Bad00000049",
        "conf": "49807f87018f55ea",
        "outputs": 0,
        "x": 760,
        "y": 360,
        "wires": []
    },
    {
        "id": "1ed6c5b68bf9f4bd",
        "type": "hb-event",
        "z": "f3705579e0700f54",
        "name": "Thermostat Küche",
        "Homebridge": "HOOBS",
        "Manufacturer": "mqttthing",
        "Service": "Thermostat",
        "device": "HOOBSBF:42:9D:EF:8C:0CmqttthingThermostat Küche0000004A",
        "conf": "49807f87018f55ea",
        "x": 150,
        "y": 460,
        "wires": [
            [
                "0ea969a9c0f7b774"
            ]
        ]
    },
    {
        "id": "6f32d74189529259",
        "type": "hb-control",
        "z": "f3705579e0700f54",
        "name": "Ventil Wohnzimmer",
        "Homebridge": "HOOBS",
        "Manufacturer": "Tasmota",
        "Service": "Switch",
        "device": "HOOBSBF:42:9D:EF:8C:0CTasmotaVentil Wohnzimmer00000049",
        "conf": "49807f87018f55ea",
        "outputs": 0,
        "x": 790,
        "y": 460,
        "wires": []
    },
    {
        "id": "2fe83dd66a451757",
        "type": "hb-control",
        "z": "f3705579e0700f54",
        "name": "Ventil Wohnzimmer",
        "Homebridge": "HOOBS",
        "Manufacturer": "Tasmota",
        "Service": "Switch",
        "device": "HOOBSBF:42:9D:EF:8C:0CTasmotaVentil Wohnzimmer00000049",
        "conf": "49807f87018f55ea",
        "outputs": 0,
        "x": 790,
        "y": 500,
        "wires": []
    },
    {
        "id": "1e88dd1358c1fdf1",
        "type": "function",
        "z": "f3705579e0700f54",
        "name": "To Boolean",
        "func": "msg.payload = msg.payload.CurrentHeatingCoolingState == 1 ? true : false;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 390,
        "y": 60,
        "wires": [
            [
                "1a099652fdb0bbc5",
                "beb9d28d05bfbbcf"
            ]
        ]
    },
    {
        "id": "954744cc4fb45bdf",
        "type": "function",
        "z": "f3705579e0700f54",
        "name": "Convert CMD",
        "func": "msg.payload = { \"On\": msg.payload == true };\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 580,
        "y": 620,
        "wires": [
            [
                "3345e96c60bdcd4e",
                "f931d5486eb44f35"
            ]
        ]
    },
    {
        "id": "b40e561666b1b0a8",
        "type": "function",
        "z": "f3705579e0700f54",
        "name": "Convert CMD",
        "func": "msg.payload = { \"On\": msg.payload};\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 580,
        "y": 160,
        "wires": [
            [
                "dcc6d5601f1ca999"
            ]
        ]
    },
    {
        "id": "9fc052423b62d5dc",
        "type": "function",
        "z": "f3705579e0700f54",
        "name": "To Boolean",
        "func": "msg.payload = msg.payload.CurrentHeatingCoolingState == 1 ? true : false;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 390,
        "y": 160,
        "wires": [
            [
                "b40e561666b1b0a8",
                "beb9d28d05bfbbcf"
            ]
        ]
    },
    {
        "id": "183fc823a1e2029a",
        "type": "function",
        "z": "f3705579e0700f54",
        "name": "Convert CMD",
        "func": "msg.payload = { \"On\": msg.payload};\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 580,
        "y": 260,
        "wires": [
            [
                "cbc3827f914a6a8a"
            ]
        ]
    },
    {
        "id": "9b8e6f5534cda354",
        "type": "function",
        "z": "f3705579e0700f54",
        "name": "To Boolean",
        "func": "msg.payload = msg.payload.CurrentHeatingCoolingState == 1 ? true : false;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 390,
        "y": 260,
        "wires": [
            [
                "183fc823a1e2029a",
                "beb9d28d05bfbbcf"
            ]
        ]
    },
    {
        "id": "751aafaf04d6be8e",
        "type": "function",
        "z": "f3705579e0700f54",
        "name": "Convert CMD",
        "func": "msg.payload = { \"On\": msg.payload};\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 580,
        "y": 360,
        "wires": [
            [
                "a0382f19759897a0"
            ]
        ]
    },
    {
        "id": "eb34c3a39e752594",
        "type": "function",
        "z": "f3705579e0700f54",
        "name": "To Boolean",
        "func": "msg.payload = msg.payload.CurrentHeatingCoolingState == 1 ? true : false;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 390,
        "y": 360,
        "wires": [
            [
                "751aafaf04d6be8e",
                "beb9d28d05bfbbcf"
            ]
        ]
    },
    {
        "id": "544add4f3abbef4d",
        "type": "function",
        "z": "f3705579e0700f54",
        "name": "Convert CMD",
        "func": "msg.payload = { \"On\": msg.payload};\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 580,
        "y": 460,
        "wires": [
            [
                "6f32d74189529259",
                "2fe83dd66a451757"
            ]
        ]
    },
    {
        "id": "0ea969a9c0f7b774",
        "type": "function",
        "z": "f3705579e0700f54",
        "name": "To Boolean",
        "func": "msg.payload = msg.payload.CurrentHeatingCoolingState == 1 ? true : false;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 390,
        "y": 460,
        "wires": [
            [
                "544add4f3abbef4d",
                "beb9d28d05bfbbcf"
            ]
        ]
    },
    {
        "id": "beb9d28d05bfbbcf",
        "type": "BooleanLogicUltimate",
        "z": "f3705579e0700f54",
        "name": "",
        "filtertrue": "both",
        "persist": true,
        "sInitializeWith": "WaitForPayload",
        "triggertopic": "trigger",
        "outputtriggeredby": "all",
        "inputCount": "5",
        "topic": "result",
        "restrictinputevaluation": false,
        "x": 400,
        "y": 620,
        "wires": [
            [],
            [
                "954744cc4fb45bdf"
            ],
            []
        ]
    },
    {
        "id": "49807f87018f55ea",
        "type": "hb-conf",
        "username": "031-45-154"
    }
]
Supergiovane commented 2 years ago

Hi you must alway pass a "topic" property along with the payload. One of your thermostat node doesn't emit a topic, so you should put a msg.topic = "something.." into each "ToBoolean" function.

markus-fischbacher commented 2 years ago

Hi, thanks for your answer. I do not completely understand the topic stuff. From Thermostat point of view I can not control the payload in my NodeRed flows. It's a object I'm getting.

{"CurrentHeatingCoolingState":0,"TargetHeatingCoolingState":3,"CurrentTemperature":21.3,"TargetTemperature":23,"TemperatureDisplayUnits":0,"CurrentRelativeHumidity":39}

The ToBoolean OnMessage is looking like this:

msg.payload = msg.payload.CurrentHeatingCoolingState == 1 ? true : false;
return msg;

I could leave away the ternary operator. It was just a way to check, if the evaluation has a bug.

Does you suggestion mean, that i should write it that way?

msg.payload.result = msg.payload.CurrentHeatingCoolingState == 1 ? true : false;
return msg;

result is the default topic's name for your boolean node. At least I tried that and it didn't work anyways. Getting the same message Received invalid topic

Am I on a way where I can get it working or am I completely wrong?

Supergiovane commented 2 years ago

Hi please read the README page on github. It explains all about the topics.

Just write on the ToBoolean of the first thermostat:

msg.payload = msg.payload.CurrentHeatingCoolingState == 1 ? true : false; msg.topic = "thermostat1"; return msg;

and on the ToBoolean of the second thermostat:

msg.payload = msg.payload.CurrentHeatingCoolingState == 1 ? true : false; msg.topic = "thermostat2"; return msg;

etc... etc...

markus-fischbacher commented 2 years ago

Ahhh, thank you! It works now :)