Spartan-II-117 / node-red-contrib-home-assistant-llat

Home Assistant + Node-Red
MIT License
31 stars 5 forks source link

call_service node affects all input_boolean controls in default group #43

Closed githubbuh closed 6 years ago

githubbuh commented 6 years ago

Describe the bug A clear and concise description of what the bug is.

a call to the service_domain input_boolean service turn_off using call_service where the call_service received entity_id as an input turns off the entity_id input_booleand AND it also turns off all input_boolean objects in the default group.

To Reproduce Steps to reproduce the behavior:

  1. node red change node sets entity_id to input_boolean.object
  2. node red change node connects to call_service that has server, service_domain, and service specified

Expected behavior expected that the input_boolean entity_id passed to the call_service would be turned off

Screenshots If applicable, add screenshots to help explain your problem.

Example Flow If applicable, add an example of exported json of a flow exhibiting the issue to aid in reproduction.

These three nodes will turn off all input_boolean controls in the default group. [ { "id": "db76a7a0.7458b", "type": "inject", "z": "1c7031d2.6453be", "name": "", "topic": "", "payload": "", "payloadType": "date", "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "x": 940, "y": 140, "wires": [ [ "48be436d.892174" ] ] }

{
    "id": "48be436d.892174",
    "type": "change",
    "z": "1c7031d2.6453be",
    "name": "",
    "rules": [
        {
            "t": "set",
            "p": "payload.entity_id",
            "pt": "msg",
            "to": "input_boolean.valve_1",
            "tot": "str"
        }
    ],
    "action": "",
    "property": "",
    "from": "",
    "to": "",
    "reg": false,
    "x": 1230,
    "y": 180,
    "wires": [
        [
            "e85aab1c.1ed528"
        ]
    ]
}

{
    "id": "e85aab1c.1ed528",
    "type": "api-call-service",
    "z": "1c7031d2.6453be",
    "name": "valve_to_off",
    "server": "38e5a33d.64e74c",
    "service_domain": "input_boolean",
    "service": "turn_off",
    "data": "",
    "mergecontext": "",
    "x": 1710,
    "y": 280,
    "wires": [
        [
            "19c2bec9.7ee239"
        ]
    ]
},
{
    "id": "38e5a33d.64e74c",
    "type": "server",
    "z": "",
    "name": "The North Wing",
    "url": "url",
    "pass": "pwd",
    "llat": ""
}

]

Environment (please complete the following information):

Other (please complete the following information):

Additional context Add any other context about the problem here.

githubbuh commented 6 years ago

after doing more testing, i have discovered that the defect only occurs if there is no msg.payload.data.entity_id. per the code example, i was passing msg.payload.entity_id.

Spartan-II-117 commented 6 years ago

If you read the instructions for the node it is expecting the entity is inside an object in message.payload, I should probably update the node descriptions to make that more clear.

githubbuh commented 6 years ago

Indeed. I saw that. It was a defect on my part to put the entity id in the wrong spot. However, it still seems like defect in the node that it sets all input_booleans in the default group to off it the entity id is missing.

Spartan-II-117 commented 6 years ago

It's the same as using call service without an entity_id, if there's do entity_id, it calls all of them. that behavior is established on the home-assistant side.

githubbuh commented 6 years ago

thanks for this tidbit. i didn't know that the default behavior of a call to the input_boolean service without and entity_id will apply the action [turn_of | turn_off] to all input_boolean objects in the default group.

re passing entity_id, i have not completed my analysis, but I have a hunch that some of the nodes expect entity_id to be in .payload.data.entity_id and that there is at least one node that expects to find entity_id up one level as .payload.entity_id. I need to validate and will have time for that this evening.

It is interesting to me that there are three different node red home assistant libraries and that all three have used exactly the same names for their nodes. i imagine this because the two new libraries were forked from the same base. are the node names specified by the home assistant interface or can they be what ever you want? i ask because it is not convenient to compare nodes across the three libraries because it is not possible to have all three active in node red at the same time. seems like each library would want to have non-conflicting names. know what I mean? but, i am a node-red -> home assistant newb so i can imagine there is something i don't understand.

thank you for your work to support node-red integration for home assistant. the move to node red has rocked my home automation in a big way.

Spartan-II-117 commented 6 years ago

in reguards to the differen't home-assistant versions having the same nodes, mine and the new websockets one come from the same source, ayapejian, who completely stopped all github activity a few months ago. I forked his work to fix some problems, initially just for my own use, then people started to find it, so i decided to do my best to help other people as well. the websockets version forked from my brance and has made some significant changes, but we all want to be backwards compatible with the existing users so people don't have to re-design their existing flows.

If you find something that is inconsistent with how you pass in an entity_id, lease tell me, i'm trying to keep stuff like that from happening. but I'm IT support for 5 organizations, so life gets busy sometimes!

githubbuh commented 6 years ago

i fully understand and appreciate the backward compatibility consideration. i have migrated most of my automation to node red, and it is a non-trivial amount of code so backward compatibility has worked in my favor. as you know, moving from one to the next is not that big a deal. thanks for the explanation. i'll let you know this PM about the possible inconsistency.

I am just finishing a sprinkler controller implementation that is pretty cool and that i couldn't even imagine trying to do in yaml.

githubbuh commented 6 years ago

Spartan-II-117 This morning, i encountered the same error i did last week where in the elements I added to msg. were removed from the message after accessing a call service node. so, i decided to remove the other two home assistant libraries keeping only yours. It was a long journey with some unbelievably stupid mistakes. one of which was to change ownership on my node-red components.

I have covered, mostly, and now receive this message when I try to deploy flow changes. It could be a permissions issue, but I don't know what file nor where.

Flows stopped due to missing node types.

home-assistant-config

homemanadmin@homeMan-server:~/.node-red$ npm ls | grep home node-red-project@0.0.1 /home/homemanadmin/.node-red ├─┬ node-red-contrib-home-assistant-llat@0.3.10 │ ├─┬ node-home-assistant-llat@0.2.4 │ │ │ │ ├─┬ home-or-tmp@2.0.0 │ │ │ │ │ ├── os-homedir@1.0.2 npm ERR! peer dep missing: marked@^0.3.3, required by marked-terminal@1.7.0

githubbuh commented 6 years ago

After a complete purge of anything node and a reinstall of nodejs and node-red, everything is back up and running. Back to the original topic of what object should have entity_id. This flow works as expected. In some cases, entity_is is required to be a child of .payload and sometimes it has to be a child of .payload.data [ { "id": "560d208.36001e", "type": "subflow", "name": "twilio_sms_phone", "info": "write message to twilio sms for phone", "category": "", "in": [ { "x": 120, "y": 140, "wires": [ { "id": "9049811.e66be" } ] } ], "out": [] }, { "id": "9049811.e66be", "type": "twilio out", "z": "560d208.36001e", "twilio": "57d0e262.ffa8a4", "twilioType": "sms", "url": "", "number": "+1number", "name": "twilio_sms_phone", "x": 400, "y": 140, "wires": [] }, { "id": "57d0e262.ffa8a4", "type": "twilio-api", "z": "", "name": "twilio", "sid": "twiliosid", "from": "twiliofrom" }, { "id": "eb2695a2.969ba8", "type": "tab", "label": "Irrigation", "disabled": false, "info": "" }, { "id": "56377b03.cb17cc", "type": "function", "z": "eb2695a2.969ba8", "name": "group_str_parse", "func": "var array = [];\nvar seqStr;\nvar cntStr;\nvar lastStr;\nvar runMode;\n\n\nfor (var i=0; i<msg.payload.group.length;i++) {\n seqStr = i;\n cntStr = msg.payload.group.length;\n lastStr = \"false\";\n runMode = msg.run_mode;\n\n if ((msg.payload.group.length - i) == 1)\n {\n lastStr = \"true\";\n }\n \n msg.payload.group[i].seq = seqStr;\n msg.payload.group[i].cnt = cntStr;\n msg.payload.group[i].last = lastStr;\n \n if (runMode == \"batch\")\n {\n msg.payload.group[i].run_mode = runMode;\n }\n \n array.push({payload: msg.payload.group[i]});\n}\n\nreturn [array];", "outputs": 1, "noerr": 0, "x": 1060, "y": 520, "wires": [ [ "4cbf551e.d2cdf4" ] ] }, { "id": "b45ff655.65ec9", "type": "debug", "z": "eb2695a2.969ba8", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "x": 1830, "y": 600, "wires": [] }, { "id": "e07e7a61.a94798", "type": "function", "z": "eb2695a2.969ba8", "name": "duration_to_minutes", "func": "msg.delay = Number(msg.duration)*60000;\nmsg.input_for = 'mqtt_payload_input:valve_runtime';\nreturn msg;", "outputs": 1, "noerr": 0, "x": 1360, "y": 360, "wires": [ [ "45ab66be.c327d8", "d218008c.cdf128" ] ] }, { "id": "45ab66be.c327d8", "type": "delay", "z": "eb2695a2.969ba8", "name": "valve_runtime", "pauseType": "delayv", "timeout": "60", "timeoutUnits": "seconds", "rate": "1", "nbRateUnits": "1", "rateUnits": "second", "randomFirst": "1", "randomLast": "5", "randomUnits": "seconds", "drop": false, "x": 1660, "y": 460, "wires": [ [ "3320a73e.344e9", "d35a1804.7a838", "de0f35bc.97de" ] ] }, { "id": "b54910e0.81f498", "type": "mqtt out", "z": "eb2695a2.969ba8", "name": "mqtt_on_pub", "topic": "esp/test", "qos": "", "retain": "", "broker": "e6648714.e6bc9", "x": 1810, "y": 360, "wires": [] }, { "id": "d218008c.cdf128", "type": "function", "z": "eb2695a2.969ba8", "name": "mqtt_on_pub_input", "func": "msg.payload = '{\"valve\":' + msg.valve + ',\"state\":\"on\",\"msgid\":\"' + msg._msgid + '\"}';\nreturn msg;", "outputs": 1, "noerr": 0, "x": 1610, "y": 360, "wires": [ [ "b54910e0.81f498", "b45ff655.65ec9", "134f1382.e2242c" ] ] }, { "id": "4cbf551e.d2cdf4", "type": "simple-queue", "z": "eb2695a2.969ba8", "name": "irrigation_queue", "firstMessageBypass": false, "bypassInterval": "0", "x": 1260, "y": 680, "wires": [ [ "126ad87d.3d5868", "fc6a1cb9.d7b848" ] ] }, { "id": "d35a1804.7a838", "type": "change", "z": "eb2695a2.969ba8", "name": "queue_move_to_next", "rules": [ { "t": "set", "p": "trigger", "pt": "msg", "to": "1", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 840, "y": 680, "wires": [ [ "4cbf551e.d2cdf4" ] ] }, { "id": "173ca25d.3dba2e", "type": "delay", "z": "eb2695a2.969ba8", "name": "queue_delay", "pauseType": "delay", "timeout": "3", "timeoutUnits": "seconds", "rate": "1", "nbRateUnits": "1", "rateUnits": "second", "randomFirst": "1", "randomLast": "5", "randomUnits": "seconds", "drop": false, "x": 550, "y": 500, "wires": [ [ "d35a1804.7a838" ] ] }, { "id": "41ee38ad.2b09f", "type": "change", "z": "eb2695a2.969ba8", "name": "queue_reset", "rules": [ { "t": "set", "p": "reset", "pt": "msg", "to": "1", "tot": "str" }, { "t": "set", "p": "input_for", "pt": "msg", "to": "irrigation_queue", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 750, "y": 760, "wires": [ [ "4cbf551e.d2cdf4" ] ] }, { "id": "75f05eac.6c7988", "type": "api-call-service", "z": "eb2695a2.969ba8", "name": "valve_mode_to_auto", "server": "d7ce796e.9e4b", "service_domain": "input_text", "service": "set_value", "data": "", "mergecontext": "", "x": 1600, "y": 820, "wires": [ [] ] }, { "id": "efb10a97.af59b8", "type": "change", "z": "eb2695a2.969ba8", "name": "valve_mode_to_auto_input", "rules": [ { "t": "set", "p": "valve", "pt": "msg", "to": "payload.valve", "tot": "msg" }, { "t": "set", "p": "duration", "pt": "msg", "to": "payload.duration", "tot": "msg" }, { "t": "set", "p": "seq", "pt": "msg", "to": "payload.seq", "tot": "msg" }, { "t": "set", "p": "cnt", "pt": "msg", "to": "payload.cnt", "tot": "msg" }, { "t": "set", "p": "last", "pt": "msg", "to": "payload.last", "tot": "msg" }, { "t": "set", "p": "run_mode", "pt": "msg", "to": "payload.run_mode", "tot": "msg" }, { "t": "set", "p": "input_for", "pt": "msg", "to": "valve_mode_to_auto1", "tot": "str" }, { "t": "set", "p": "payload.data.value", "pt": "msg", "to": "Auto", "tot": "str" }, { "t": "set", "p": "payload.data.entity_id", "pt": "msg", "to": "'inputtext.valve' & $.valve & '_mode'", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 1680, "y": 680, "wires": [ [ "7f1cc316.74f034" ] ] }, { "id": "42c0b3b1.da5a54", "type": "api-call-service", "z": "eb2695a2.969ba8", "name": "valve_to_on", "server": "d7ce796e.9e4b", "service_domain": "input_boolean", "service": "turn_on", "data": "", "mergecontext": "", "x": 2330, "y": 680, "wires": [ [ "e07e7a61.a94798", "145d1464.e59794" ] ] }, { "id": "7f9985e2.b82ef4", "type": "change", "z": "eb2695a2.969ba8", "name": "valve_to_on_input", "rules": [ { "t": "delete", "p": "payload.domain", "pt": "msg" }, { "t": "delete", "p": "payload.service", "pt": "msg" }, { "t": "delete", "p": "payload.data.value", "pt": "msg" }, { "t": "set", "p": "payload.data.entity_id", "pt": "msg", "to": "'inputboolean.valve' & $.valve", "tot": "jsonata" }, { "t": "set", "p": "input_for", "pt": "msg", "to": "valve_to_on", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 2130, "y": 680, "wires": [ [ "42c0b3b1.da5a54" ] ] }, { "id": "6505c572.b094ac", "type": "api-call-service", "z": "eb2695a2.969ba8", "name": "valve_to_off", "server": "d7ce796e.9e4b", "service_domain": "input_boolean", "service": "turn_off", "data": "", "mergecontext": "", "x": 2070, "y": 460, "wires": [ [ "229c06bd.2a9a2a" ] ] }, { "id": "3320a73e.344e9", "type": "change", "z": "eb2695a2.969ba8", "name": "valve_to_off_input", "rules": [ { "t": "delete", "p": "payload", "pt": "msg" }, { "t": "set", "p": "payload.data.entity_id", "pt": "msg", "to": "'inputboolean.valve' & $.valve", "tot": "jsonata" }, { "t": "set", "p": "input_for", "pt": "msg", "to": "valve_to_off", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 1870, "y": 460, "wires": [ [ "6505c572.b094ac" ] ] }, { "id": "46f4cf80.9abc28", "type": "api-current-state", "z": "eb2695a2.969ba8", "name": "valve_mode", "server": "d7ce796e.9e4b", "halt_if": "", "override_topic": false, "override_payload": false, "entity_id": "", "x": 510, "y": 160, "wires": [ [ "7f0feb42.78496c" ] ] }, { "id": "86fe9ef6.8ee4e", "type": "server-state-changed", "z": "eb2695a2.969ba8", "name": "valve_1_on", "server": "d7ce796e.9e4b", "entityidfilter": "input_boolean.valve_1", "entityidfiltertype": "substring", "haltifstate": "off", "x": 100, "y": 60, "wires": [ [ "d7038ac9.6782a" ] ] }, { "id": "7f0feb42.78496c", "type": "switch", "z": "eb2695a2.969ba8", "name": "mode_auto", "property": "data.state", "propertyType": "msg", "rules": [ { "t": "eq", "v": "Auto", "vt": "str" }, { "t": "neq", "v": "Auto", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 670, "y": 160, "wires": [ [], [ "59e99842.4b6bf8" ] ], "outputLabels": [ "Auto", "NotAuto" ] }, { "id": "7c8760f0.89993", "type": "api-current-state", "z": "eb2695a2.969ba8", "name": "valve_duration", "server": "d7ce796e.9e4b", "halt_if": "", "override_topic": true, "override_payload": true, "entity_id": "", "x": 1100, "y": 160, "wires": [ [ "5dcf11a6.f29a2" ] ] }, { "id": "5dcf11a6.f29a2", "type": "change", "z": "eb2695a2.969ba8", "name": "duration_to_time_input", "rules": [ { "t": "set", "p": "duration", "pt": "msg", "to": "payload", "tot": "msg" }, { "t": "set", "p": "input_for", "pt": "msg", "to": "duration_to_minutes", "tot": "str" }, { "t": "delete", "p": "payload", "pt": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 1300, "y": 160, "wires": [ [ "e07e7a61.a94798", "ee9201e9.a9908" ] ] }, { "id": "59e99842.4b6bf8", "type": "change", "z": "eb2695a2.969ba8", "name": "valve_duration_input", "rules": [ { "t": "set", "p": "payload.entity_id", "pt": "msg", "to": "'inputnumber.valve' & $.valve & '_duration'", "tot": "jsonata" }, { "t": "set", "p": "input_for", "pt": "msg", "to": "valve_duration", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 880, "y": 160, "wires": [ [ "7c8760f0.89993" ] ] }, { "id": "d7038ac9.6782a", "type": "change", "z": "eb2695a2.969ba8", "name": "valve1_mode_input", "rules": [ { "t": "delete", "p": "payload", "pt": "msg" }, { "t": "set", "p": "payload.entity_id", "pt": "msg", "to": "input_text.valve_1_mode", "tot": "str" }, { "t": "set", "p": "valve", "pt": "msg", "to": "1", "tot": "num" }, { "t": "set", "p": "input_for", "pt": "msg", "to": "valve_mode", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 290, "y": 60, "wires": [ [ "46f4cf80.9abc28" ] ] }, { "id": "9ebd8697.2a5828", "type": "server-state-changed", "z": "eb2695a2.969ba8", "name": "valve_2_on", "server": "d7ce796e.9e4b", "entityidfilter": "input_boolean.valve_2", "entityidfiltertype": "substring", "haltifstate": "off", "x": 100, "y": 120, "wires": [ [ "a2d60197.7087e" ] ] }, { "id": "a2d60197.7087e", "type": "change", "z": "eb2695a2.969ba8", "name": "valve2_mode_input", "rules": [ { "t": "delete", "p": "payload", "pt": "msg" }, { "t": "set", "p": "payload.entity_id", "pt": "msg", "to": "input_text.valve_2_mode", "tot": "str" }, { "t": "set", "p": "valve", "pt": "msg", "to": "2", "tot": "num" }, { "t": "set", "p": "input_for", "pt": "msg", "to": "valve_mode", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 290, "y": 120, "wires": [ [ "46f4cf80.9abc28" ] ] }, { "id": "efbcf448.2ab55", "type": "api-call-service", "z": "eb2695a2.969ba8", "name": "valve_mode_to_man", "server": "d7ce796e.9e4b", "service_domain": "input_text", "service": "set_value", "data": "", "mergecontext": "", "x": 2560, "y": 460, "wires": [ [ "aead1d79.7b4e4" ] ] }, { "id": "229c06bd.2a9a2a", "type": "change", "z": "eb2695a2.969ba8", "name": "valve_mode_to_man_input", "rules": [ { "t": "set", "p": "payload.data.value", "pt": "msg", "to": "Man", "tot": "str" }, { "t": "set", "p": "payload.data.entity_id", "pt": "msg", "to": "'inputtext.valve' & $.valve & '_mode'", "tot": "jsonata" }, { "t": "delete", "p": "payload.domain", "pt": "msg" }, { "t": "delete", "p": "payload.service", "pt": "msg" }, { "t": "set", "p": "input_for", "pt": "msg", "to": "valve_mode_to_man", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 2300, "y": 460, "wires": [ [ "efbcf448.2ab55" ] ] }, { "id": "4f6de743.9cc5b8", "type": "catch", "z": "eb2695a2.969ba8", "name": "", "scope": null, "x": 1680, "y": 600, "wires": [ [ "b45ff655.65ec9" ] ] }, { "id": "7b320fa2.3f3ff8", "type": "server-state-changed", "z": "eb2695a2.969ba8", "name": "Reset", "server": "d7ce796e.9e4b", "entityidfilter": "input_boolean.irr_reset", "entityidfiltertype": "substring", "haltifstate": "off", "x": 70, "y": 820, "wires": [ [ "41ee38ad.2b09f", "8bce74a8.4e39b" ] ] }, { "id": "8bce74a8.4e39b", "type": "change", "z": "eb2695a2.969ba8", "name": "valve_runtime_input_reset", "rules": [ { "t": "set", "p": "reset", "pt": "msg", "to": "true", "tot": "str" }, { "t": "set", "p": "input_for", "pt": "msg", "to": "valve_runtime:reset", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 790, "y": 820, "wires": [ [ "45ab66be.c327d8", "23a15924.35e3ae" ] ] }, { "id": "2369b351.6d1424", "type": "api-call-service", "z": "eb2695a2.969ba8", "name": "irr_reset_boolean_to_off", "server": "d7ce796e.9e4b", "service_domain": "input_boolean", "service": "turn_off", "data": "{ \"entity_id\":\"input_boolean.irr_reset\" }", "mergecontext": "", "x": 1750, "y": 880, "wires": [ [] ] }, { "id": "dfe05e4.c749c2", "type": "server-state-changed", "z": "eb2695a2.969ba8", "name": "valve_1_off", "server": "d7ce796e.9e4b", "entityidfilter": "input_boolean.valve_1", "entityidfiltertype": "substring", "haltifstate": "on", "x": 80, "y": 1200, "wires": [ [ "5bf2ad7c.7c568c" ] ] }, { "id": "30b2f6a6.904bfa", "type": "mqtt out", "z": "eb2695a2.969ba8", "name": "", "topic": "esp/test", "qos": "", "retain": "", "broker": "e6648714.e6bc9", "x": 1160, "y": 1340, "wires": [] }, { "id": "145d1464.e59794", "type": "change", "z": "eb2695a2.969ba8", "name": "irr_auto_set_input", "rules": [ { "t": "delete", "p": "payload", "pt": "msg" }, { "t": "set", "p": "payload.data.entity_id", "pt": "msg", "to": "input_text.irr_auto", "tot": "str" }, { "t": "set", "p": "payload.data.value", "pt": "msg", "to": "$.valve & \":\" & $.duration", "tot": "jsonata" }, { "t": "set", "p": "input_for", "pt": "msg", "to": "irr_auto_set", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 2550, "y": 680, "wires": [ [ "572f4ee7.3dd29" ]am


        ]
    },
    {
        "id": "572f4ee7.3dd29",
        "type": "api-call-service",
        "z": "eb2695a2.969ba8",
        "name": "irr_auto_set",
        "server": "d7ce796e.9e4b",
        "service_domain": "input_text",
        "service": "set_value",
        "data": "",
        "mergecontext": "",
        "x": 2750,
        "y": 680,
        "wires": [
            []
        ]
    },
    {
        "id": "df1de25.422862",
        "type": "api-current-state",
        "z": "eb2695a2.969ba8",
        "name": "irr_auto_text_set",
        "server": "d7ce796e.9e4b",
        "halt_if": "",
        "override_topic": false,
        "override_payload": false,
        "entity_id": "",
        "x": 1410,
        "y": 940,
        "wires": [
            [
                "c6a1c6dd.42de7",
                "b0cf7536.a7966",
                "779c4c4b.452714",
                "2369b351.6d1424"
            ]
        ]
    },
    {
        "id": "23a15924.35e3ae",
        "type": "change",
        "z": "eb2695a2.969ba8",
        "name": "irr_auto_text_set_input",
        "rules": [
            {
                "t": "delete",
                "p": "payload",
                "pt": "msg"
            },
            {
                "t": "set",
                "p": "payload.entity_id",
                "pt": "msg",
                "to": "input_text.irr_auto",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "input_for",
                "pt": "msg",
                "to": "irr_auto_text_set",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1160,
        "y": 940,
        "wires": [
            [
                "df1de25.422862"
            ]
        ]
    },
    {
        "id": "c6a1c6dd.42de7",
        "type": "function",
        "z": "eb2695a2.969ba8",
        "name": "mqtt_reset_off_pub_input",
        "func": "var str = msg.data.state;\nvar res = str.split(\":\");\n\nif (res[0] == 1){\n    msg.payload = '14:off--reset';\n} else if (res[1] == 2) {\n    msg.payload = '16:off--reset';\n} else {\n    msg.payload = '0:off--reset';\n}\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 1750,
        "y": 940,
        "wires": [
            [
                "37b3dcbe.80389c"
            ]
        ]
    },
    {
        "id": "8dbc5412.fe6518",
        "type": "mqtt out",
        "z": "eb2695a2.969ba8",
        "name": "mqtt_off_pub_reset",
        "topic": "esp/test",
        "qos": "",
        "retain": "",
        "broker": "e6648714.e6bc9",
        "x": 1910,
        "y": 1000,
        "wires": []
    },
    {
        "id": "37b3dcbe.80389c",
        "type": "api-call-service",
        "z": "eb2695a2.969ba8",
        "name": "irr_auto_text_inactive",
        "server": "d7ce796e.9e4b",
        "service_domain": "input_text",
        "service": "set_value",
        "data": "{\"entity_id\":\"input_text.irr_auto\",\"value\":\"Inactive\"}",
        "mergecontext": "",
        "x": 2160,
        "y": 940,
        "wires": [
            []
        ]
    },
    {
        "id": "b0cf7536.a7966",
        "type": "change",
        "z": "eb2695a2.969ba8",
        "name": "valve_to_off_reset_input",
        "rules": [
            {
                "t": "delete",
                "p": "payload",
                "pt": "msg"
            },
            {
                "t": "set",
                "p": "payload.data.entity_id",
                "pt": "msg",
                "to": "'input_boolean.valve_' & $.valve",
                "tot": "jsonata"
            },
            {
                "t": "delete",
                "p": "data",
                "pt": "msg"
            },
            {
                "t": "set",
                "p": "input_for",
                "pt": "msg",
                "to": "valve_to_off_reset_input",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 2090,
        "y": 1080,
        "wires": [
            [
                "bd94a915.28df4"
            ]
        ]
    },
    {
        "id": "bd94a915.28df4",
        "type": "api-call-service",
        "z": "eb2695a2.969ba8",
        "name": "valve_to_off_reset",
        "server": "d7ce796e.9e4b",
        "service_domain": "input_boolean",
        "service": "turn_off",
        "data": "",
        "mergecontext": "",
        "x": 2450,
        "y": 1080,
        "wires": [
            []
        ]
    },
    {
        "id": "779c4c4b.452714",
        "type": "function",
        "z": "eb2695a2.969ba8",
        "name": "irr_auto_text_split",
        "func": "var str = msg.data.state;\nvar res = str.split(\":\");\n\nmsg.valve = res[0];\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 1810,
        "y": 1100,
        "wires": [
            [
                "b0cf7536.a7966",
                "3e0e33c1.d8e4ac"
            ]
        ]
    },
    {
        "id": "3e0e33c1.d8e4ac",
        "type": "change",
        "z": "eb2695a2.969ba8",
        "name": "valve_mode_to_man_reset_input",
        "rules": [
            {
                "t": "set",
                "p": "payload.data.value",
                "pt": "msg",
                "to": "Man",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.data.entity_id",
                "pt": "msg",
                "to": "'input_text.valve_' & $.valve & '_mode'",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "input_for",
                "pt": "msg",
                "to": "valve_mode_to_man_reset_input",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 2120,
        "y": 1140,
        "wires": [
            [
                "a3422726.3d9168"
            ]
        ]
    },
    {
        "id": "a3422726.3d9168",
        "type": "api-call-service",
        "z": "eb2695a2.969ba8",
        "name": "valve_mode_to_man_reset",
        "server": "d7ce796e.9e4b",
        "service_domain": "input_text",
        "service": "set_value",
        "data": "",
        "mergecontext": "",
        "x": 2480,
        "y": 1140,
        "wires": [
            []
        ]
    },
    {
        "id": "42468840.5d5e48",
        "type": "server-state-changed",
        "z": "eb2695a2.969ba8",
        "name": "valve_2_off",
        "server": "d7ce796e.9e4b",
        "entityidfilter": "input_boolean.valve_2",
        "entityidfiltertype": "substring",
        "haltifstate": "on",
        "x": 80,
        "y": 1280,
        "wires": [
            [
                "d963bb8b.a567d"
            ]
        ]
    },
    {
        "id": "126ad87d.3d5868",
        "type": "delay",
        "z": "eb2695a2.969ba8",
        "name": "queue_delay",
        "pauseType": "delay",
        "timeout": "3",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "x": 1450,
        "y": 680,
        "wires": [
            [
                "efb10a97.af59b8"
            ]
        ]
    },
    {
        "id": "aead1d79.7b4e4",
        "type": "switch",
        "z": "eb2695a2.969ba8",
        "name": "queue_last",
        "property": "last",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "true",
                "vt": "str"
            },
            {
                "t": "neq",
                "v": "true",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 2770,
        "y": 460,
        "wires": [
            [
                "9a3399b.b69eee8"
            ],
            []
        ],
        "outputLabels": [
            "true",
            "false"
        ]
    },
    {
        "id": "dd7dad3f.047b48",
        "type": "change",
        "z": "eb2695a2.969ba8",
        "name": "",
        "rules": [
            {
                "t": "delete",
                "p": "payload",
                "pt": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 3390,
        "y": 580,
        "wires": [
            [
                "37b3dcbe.80389c"
            ]
        ]
    },
    {
        "id": "743766d9.f23668",
        "type": "server-state-changed",
        "z": "eb2695a2.969ba8",
        "name": "irr_batch_on",
        "server": "d7ce796e.9e4b",
        "entityidfilter": "input_boolean.irr_batch",
        "entityidfiltertype": "substring",
        "haltifstate": "off",
        "x": 90,
        "y": 420,
        "wires": [
            [
                "f6bdfe0b.ea20b"
            ]
        ]
    },
    {
        "id": "f6bdfe0b.ea20b",
        "type": "api-current-state",
        "z": "eb2695a2.969ba8",
        "name": "batch_string_fetch",
        "server": "d7ce796e.9e4b",
        "halt_if": "",
        "override_topic": true,
        "override_payload": true,
        "entity_id": "input_text.irr_batch",
        "x": 310,
        "y": 420,
        "wires": [
            [
                "173ca25d.3dba2e",
                "cdafd5a0.afd758"
            ]
        ]
    },
    {
        "id": "ee551ee3.03a6a8",
        "type": "api-call-service",
        "z": "eb2695a2.969ba8",
        "name": "irr_batch_to_off",
        "server": "d7ce796e.9e4b",
        "service_domain": "input_boolean",
        "service": "turn_off",
        "data": "{\"entity_id\":\"input_boolean.irr_batch\"}",
        "mergecontext": "",
        "x": 3380,
        "y": 460,
        "wires": [
            []
        ]
    },
    {
        "id": "cdafd5a0.afd758",
        "type": "function",
        "z": "eb2695a2.969ba8",
        "name": "payload_to_JSON",
        "func": "var data = msg.payload;\nconsole.log(\"payload data: length = \" + data.length);\ndata = data.trim();\nconsole.log(\"trimmed data: length = \" + data.length);\n\nmsg.payload = JSON.parse(data);\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 570,
        "y": 420,
        "wires": [
            [
                "34ca82c4.08d86e"
            ]
        ]
    },
    {
        "id": "4e916861.af513",
        "type": "server-state-changed",
        "z": "eb2695a2.969ba8",
        "name": "skip",
        "server": "d7ce796e.9e4b",
        "entityidfilter": "input_boolean.irr_skip",
        "entityidfiltertype": "substring",
        "haltifstate": "off",
        "x": 70,
        "y": 560,
        "wires": [
            [
                "23a15924.35e3ae",
                "173ca25d.3dba2e",
                "52d0b072.d8bf68"
            ]
        ]
    },
    {
        "id": "52d0b072.d8bf68",
        "type": "api-call-service",
        "z": "eb2695a2.969ba8",
        "name": "irr_skip_boolean_to_off",
        "server": "d7ce796e.9e4b",
        "service_domain": "input_boolean",
        "service": "turn_off",
        "data": "{ \"entity_id\":\"input_boolean.irr_skip\" }",
        "mergecontext": "",
        "x": 470,
        "y": 560,
        "wires": [
            []
        ]
    },
    {
        "id": "34ca82c4.08d86e",
        "type": "change",
        "z": "eb2695a2.969ba8",
        "name": "run_mode_batch",
        "rules": [
            {
                "t": "set",
                "p": "run_mode",
                "pt": "msg",
                "to": "batch",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 790,
        "y": 420,
        "wires": [
            [
                "56377b03.cb17cc"
            ]
        ]
    },
    {
        "id": "9a3399b.b69eee8",
        "type": "switch",
        "z": "eb2695a2.969ba8",
        "name": "batch_last",
        "property": "run_mode",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "batch",
                "vt": "str"
            },
            {
                "t": "neq",
                "v": "batch",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 2950,
        "y": 460,
        "wires": [
            [
                "3646a0e7.598a4",
                "dd7dad3f.047b48"
            ],
            []
        ],
        "outputLabels": [
            "true",
            "false"
        ]
    },
    {
        "id": "3646a0e7.598a4",
        "type": "change",
        "z": "eb2695a2.969ba8",
        "name": "irr_batch_off_input",
        "rules": [
            {
                "t": "delete",
                "p": "payload",
                "pt": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 3170,
        "y": 460,
        "wires": [
            [
                "ee551ee3.03a6a8"
            ]
        ]
    },
    {
        "id": "d8ad0bef.b7a4a8",
        "type": "server-state-changed",
        "z": "eb2695a2.969ba8",
        "name": "irr_batch_off",
        "server": "d7ce796e.9e4b",
        "entityidfilter": "input_boolean.irr_batch",
        "entityidfiltertype": "substring",
        "haltifstate": "on",
        "x": 90,
        "y": 920,
        "wires": [
            [
                "25c337ca.f29d4"
            ]
        ]
    },
    {
        "id": "ee9201e9.a9908",
        "type": "change",
        "z": "eb2695a2.969ba8",
        "name": "valve_mode_to_man_input",
        "rules": [
            {
                "t": "set",
                "p": "payload.data.value",
                "pt": "msg",
                "to": "'On manually for ' & $.duration",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "payload.data.entity_id",
                "pt": "msg",
                "to": "'input_text.valve_' & $.valve & '_mode'",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "input_for",
                "pt": "msg",
                "to": "valve_mode_to_man",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1580,
        "y": 160,
        "wires": [
            [
                "3e110b79.bec794"
            ]
        ]
    },
    {
        "id": "3e110b79.bec794",
        "type": "api-call-service",
        "z": "eb2695a2.969ba8",
        "name": "valve_mode_to_man",
        "server": "d7ce796e.9e4b",
        "service_domain": "input_text",
        "service": "set_value",
        "data": "",
        "mergecontext": "",
        "x": 1840,
        "y": 160,
        "wires": [
            []
        ]
    },
    {
        "id": "5bf2ad7c.7c568c",
        "type": "change",
        "z": "eb2695a2.969ba8",
        "name": "valve_to_1",
        "rules": [
            {
                "t": "set",
                "p": "valve",
                "pt": "msg",
                "to": "1",
                "tot": "num"
            },
            {
                "t": "delete",
                "p": "payload",
                "pt": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 310,
        "y": 1200,
        "wires": [
            [
                "3e0e33c1.d8e4ac",
                "40b36a53.784b84"
            ]
        ]
    },
    {
        "id": "d963bb8b.a567d",
        "type": "change",
        "z": "eb2695a2.969ba8",
        "name": "valve_to_2",
        "rules": [
            {
                "t": "set",
                "p": "valve",
                "pt": "msg",
                "to": "2",
                "tot": "num"
            },
            {
                "t": "delete",
                "p": "payload",
                "pt": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 310,
        "y": 1280,
        "wires": [
            [
                "3e0e33c1.d8e4ac",
                "40b36a53.784b84"
            ]
        ]
    },
    {
        "id": "40b36a53.784b84",
        "type": "function",
        "z": "eb2695a2.969ba8",
        "name": "mqtt_off_pub_input",
        "func": "msg.payload = '{\"valve\":' + msg.valve + ',\"state\":\"off\",\"msgid\":\"' + msg._msgid + '\"}';\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 970,
        "y": 1340,
        "wires": [
            [
                "30b2f6a6.904bfa",
                "134f1382.e2242c"
            ]
        ]
    },
    {
        "id": "25c337ca.f29d4",
        "type": "api-current-state",
        "z": "eb2695a2.969ba8",
        "name": "irr_auto_text_set",
        "server": "d7ce796e.9e4b",
        "halt_if": "",
        "override_topic": false,
        "override_payload": false,
        "entity_id": "input_text.irr_auto",
        "x": 270,
        "y": 920,
        "wires": [
            [
                "fdff0902.6509c8"
            ]
        ]
    },
    {
        "id": "fdff0902.6509c8",
        "type": "switch",
        "z": "eb2695a2.969ba8",
        "name": "auto inactive",
        "property": "data.state",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "Inactive",
                "vt": "str"
            },
            {
                "t": "neq",
                "v": "Inactive",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 470,
        "y": 920,
        "wires": [
            [],
            [
                "8bce74a8.4e39b",
                "41ee38ad.2b09f"
            ]
        ],
        "outputLabels": [
            "Inactive",
            "NotInactive"
        ]
    },
    {
        "id": "fa653b4d.9bfa68",
        "type": "api-call-service",
        "z": "eb2695a2.969ba8",
        "name": "irr_auto_text_inactive",
        "server": "d7ce796e.9e4b",
        "service_domain": "input_text",
        "service": "set_value",
        "data": "{\"entity_id\":\"input_text.irr_auto\",\"value\":\"Starting next\"}",
        "mergecontext": "",
        "x": 2620,
        "y": 560,
        "wires": [
            []
        ]
    },
    {
        "id": "7f24e83b.470808",
        "type": "change",
        "z": "eb2695a2.969ba8",
        "name": "irr_batch_off_input",
        "rules": [
            {
                "t": "delete",
                "p": "payload",
                "pt": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 2390,
        "y": 560,
        "wires": [
            [
                "fa653b4d.9bfa68"
            ]
        ]
    },
    {
        "id": "de0f35bc.97de",
        "type": "switch",
        "z": "eb2695a2.969ba8",
        "name": "queue_last",
        "property": "last",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "true",
                "vt": "str"
            },
            {
                "t": "neq",
                "v": "true",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 2110,
        "y": 540,
        "wires": [
            [],
            [
                "7f24e83b.470808"
            ]
        ],
        "outputLabels": [
            "true",
            "false"
        ]
    },
    {
        "id": "7f1cc316.74f034",
        "type": "api-call-service",
        "z": "eb2695a2.969ba8",
        "name": "new",
        "server": "d7ce796e.9e4b",
        "service_domain": "input_text",
        "service": "set_value",
        "data": "",
        "mergecontext": "",
        "x": 1930,
        "y": 680,
        "wires": [
            [
                "7f9985e2.b82ef4"
            ]
        ]
    },
    {
        "id": "c0a7b051.df9568",
        "type": "inject",
        "z": "eb2695a2.969ba8",
        "name": "",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 300,
        "y": 280,
        "wires": [
            [
                "b4e33c91.38eae8"
            ]
        ]
    },
    {
        "id": "b4e33c91.38eae8",
        "type": "debug",
        "z": "eb2695a2.969ba8",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "x": 493,
        "y": 319,
        "wires": []
    },
    {
        "id": "134f1382.e2242c",
        "type": "file",
        "z": "eb2695a2.969ba8",
        "name": "",
        "filename": "node-red-ha-log.txt",
        "appendNewline": true,
        "createDir": false,
        "overwriteFile": "false",
        "x": 1184,
        "y": 1058,
        "wires": [
            []
        ]
    },
    {
        "id": "835597e.1f76fe8",
        "type": "server-state-changed",
        "z": "eb2695a2.969ba8",
        "name": "irr_caldav",
        "server": "d7ce796e.9e4b",
        "entityidfilter": "calendar.irrigation",
        "entityidfiltertype": "substring",
        "haltifstate": "off",
        "x": 100,
        "y": 1513.333251953125,
        "wires": [
            [
                "fc6a1cb9.d7b848",
                "78a82d38.ef71f4"
            ]
        ]
    },
    {
        "id": "fc6a1cb9.d7b848",
        "type": "file",
        "z": "eb2695a2.969ba8",
        "name": "node-red-ha-log",
        "filename": "node-red-ha-log.txt",
        "appendNewline": true,
        "createDir": false,
        "overwriteFile": "false",
        "x": 510,
        "y": 1509.9998779296875,
        "wires": [
            []
        ]
    },
    {
        "id": "d996d17f.8aac3",
        "type": "inject",
        "z": "eb2695a2.969ba8",
        "name": "",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 154.66668701171875,
        "y": 1452,
        "wires": [
            [
                "fc6a1cb9.d7b848"
            ]
        ]
    },
    {
        "id": "78a82d38.ef71f4",
        "type": "api-current-state",
        "z": "eb2695a2.969ba8",
        "name": "irr_loc",
        "server": "d7ce796e.9e4b",
        "halt_if": "",
        "override_topic": true,
        "override_payload": true,
        "entity_id": "sensor.irr_location",
        "x": 279.333251953125,
        "y": 1563.9998779296875,
        "wires": [
            [
                "fc6a1cb9.d7b848",
                "49331368.0db3a4"
            ]
        ]
    },
    {
        "id": "49331368.0db3a4",
        "type": "subflow:560d208.36001e",
        "z": "eb2695a2.969ba8",
        "name": "",
        "x": 713.3333333333329,
        "y": 1649.999999999999,
        "wires": []
    },
    {
        "id": "e6648714.e6bc9",
        "type": "mqtt-broker",
        "z": "",
        "name": "home",
        "broker": "mqttbroker",
        "port": "1883",
        "clientid": "",
        "usetls": false,
        "compatmode": true,
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "willTopic": "",
        "willQos": "0",
        "willPayload": ""
    },
    {
        "id": "d7ce796e.9e4b",
        "type": "server",
        "z": "",
        "name": "The North Wing",
        "url": "homeassistant@8123",
        "pass": "password",
        "llat": ""
    }
]
Spartan-II-117 commented 6 years ago

can you clarify which nodes require it to be payload.entity_id?