HDL Smartbus via NodeRed and MQTT

hi linax
I have tried to use it. During the use, I found a small bug. When the system is in the initial stage, if I use the auto mode to start the air conditioner, it will jump to the cool mode, but it will be normal when I click it again. After careful analysis of the data packets, this problem should be caused by hdl. When I sent 0x03 (auto) to my gateway for the first time, the feedback was actually 0x00. I tried a lot, and the first boot after the system reset will appear. Now The solution is to send the packet twice when the setupmode is auto, and only send it once in other modes. I don’t know yet how to return msg twice through the function, I’m just using hdl buspro tools to send packet.

Is it possible to capture click of a button? I.e on a DLP or iTouch 4btn. I would like to turn on a Hue lamp or perform other actions when pressing a button on the iTouch.

The Universal switch could work - but it’s a bit more flexible to use the button directly in HA.

Is this something you have any experience with @Linax ? :slight_smile:

Not really in a good way, as the buttons does not broadcast current state.

I would not recomend US for lights as you do not get any dimming possibility. I would recomend programing the switch to turn on a light in your nodered instance. (Point the DLP to the device id that you have set nodered up to). You will have to send the answerback message to stop the switch from sending the message 3 times and flashing the status led 3 times.

I have control over some “ikea tradfri” cabinet lights from DLP and iTouch 4btn, also status updates to switch when light is turned on from HA or Ikea switches. It is done straight in nodered as HA would make it more complex and add more time delay.

Here is how i have it made for 2x ikea lights, you should be able to use the flow to make the same for Hue lamps with for example the pallet " node-red-contrib-huemagic".

[{"id":"476aa68f8e4864eb","type":"tab","label":"Ikea to HDL","disabled":false,"info":"","env":[]},{"id":"03fccca7aa2e5fa0","type":"comment","z":"476aa68f8e4864eb","name":"Send answerback msg to HDL","info":"","x":700,"y":120,"wires":[]},{"id":"e8447e63c013754d","type":"switch","z":"476aa68f8e4864eb","name":"code","property":"code","propertyType":"msg","rules":[{"t":"eq","v":"49","vt":"str"}],"checkall":"false","repair":false,"outputs":1,"x":490,"y":240,"wires":[["e18770fce674959d","dd79a7bb86381d9a"]]},{"id":"68706f16b9eb163a","type":"hdl-raw-in","z":"476aa68f8e4864eb","controller":"","name":"From HDL","x":220,"y":240,"wires":[["7123909ca623ed81"]]},{"id":"7123909ca623ed81","type":"switch","z":"476aa68f8e4864eb","name":"target","property":"target","propertyType":"msg","rules":[{"t":"eq","v":"1.98","vt":"str"},{"t":"eq","v":"1.63","vt":"str"}],"checkall":"false","repair":false,"outputs":2,"x":350,"y":240,"wires":[["e8447e63c013754d"],[]]},{"id":"8ee1c84d2d65a743","type":"tradfri-light-control","z":"476aa68f8e4864eb","gateway":"","name":"","action":"{}","accessories":[],"groups":[],"logInputErrors":true,"x":1030,"y":280,"wires":[]},{"id":"e18770fce674959d","type":"function","z":"476aa68f8e4864eb","name":"Build and send Response","func":"//Save to var\nvar target = msg.target\nvar sender = msg.sender\n\n//Reverse msg.target and msg.sender to vars\nmsg.target = sender\nmsg.sender = target\n\n//Change code to responce single channel\nmsg.code = 50\n\n//Insert success\nmsg.payload.success = true\n\n//Return msg\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":710,"y":160,"wires":[["a8e40829f3de5426","506e37ad5e6b5963"]]},{"id":"02a994e86f70d93c","type":"comment","z":"476aa68f8e4864eb","name":"Command from HDL to Ikea","info":"","x":260,"y":200,"wires":[]},{"id":"a2dbe32501bca54b","type":"comment","z":"476aa68f8e4864eb","name":"Reconfigure command for Ikea light","info":"","x":720,"y":240,"wires":[]},{"id":"a8e40829f3de5426","type":"hdl-raw-out","z":"476aa68f8e4864eb","controller":"","name":"","x":990,"y":160,"wires":[]},{"id":"dd79a7bb86381d9a","type":"switch","z":"476aa68f8e4864eb","name":"channel","property":"payload.channel","propertyType":"msg","rules":[{"t":"eq","v":"25","vt":"num"},{"t":"eq","v":"26","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":660,"y":300,"wires":[["8e6ddd87fb3c6597"],["44f39b504b89b85c"]]},{"id":"44396640c077d6c9","type":"tradfri-monitor","z":"476aa68f8e4864eb","gateway":"","name":"","x":230,"y":460,"wires":[["bf5162f2ec55b930","5a04ab1401b60719"]]},{"id":"bf5162f2ec55b930","type":"debug","z":"476aa68f8e4864eb","name":"tradfri monitor","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":400,"y":520,"wires":[]},{"id":"44f39b504b89b85c","type":"function","z":"476aa68f8e4864eb","name":"65539","func":"// Insert Ikea device id as msg.topic\nmsg.topic = 65539\n\n//Change light % to var\nvar dim_level = Number(msg.payload.level);\n\n//If off change to Off\nif (dim_level == 0) {\n    msg.payload =  {\n        onOff: false,\n        }\n    } \n\n//Of on change to on\nif (dim_level <= 1) {\n    msg.payload =  {\n        onOff: true,\n        }\n    }\n\n// Update dim level\nmsg.payload.brightness = dim_level\n\n//Return msg\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":810,"y":340,"wires":[["8ee1c84d2d65a743"]]},{"id":"8e6ddd87fb3c6597","type":"function","z":"476aa68f8e4864eb","name":"65537","func":"// Insert Ikea device id as msg.topic\nmsg.topic = 65537\n\n//Change light % to var\nvar dim_level = Number(msg.payload.level);\n\n//If off change to Off\nif (dim_level == 0) {\n    msg.payload =  {\n        onOff: false,\n        }\n    } \n\n//Of on change to on\nif (dim_level <= 1) {\n    msg.payload =  {\n        onOff: true,\n        }\n    }\n\n// Update dim level\nmsg.payload.brightness = dim_level\n\n//Return msg\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":810,"y":280,"wires":[["8ee1c84d2d65a743"]]},{"id":"94891ae6d0cd64c1","type":"comment","z":"476aa68f8e4864eb","name":"Feedback from Ikea to HDL","info":"","x":260,"y":400,"wires":[]},{"id":"e4e2b3eb5f75ae7c","type":"switch","z":"476aa68f8e4864eb","name":"topic","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"65537","vt":"num"},{"t":"eq","v":"65539","vt":"num"}],"checkall":"false","repair":false,"outputs":2,"x":630,"y":460,"wires":[["7894333b5f4b6075"],["bab4eeaa498c7e5b"]]},{"id":"5a04ab1401b60719","type":"switch","z":"476aa68f8e4864eb","name":"","property":"payload.event","propertyType":"msg","rules":[{"t":"eq","v":"device updated","vt":"str"}],"checkall":"false","repair":false,"outputs":1,"x":390,"y":460,"wires":[["435a4cf40fd44815"]]},{"id":"7894333b5f4b6075","type":"function","z":"476aa68f8e4864eb","name":"Change","func":"// Insert msg.code\nmsg.code = 50\n\n//Add target\nmsg.target = \"1.118\"\n\n//Add payload channel\nmsg.payload = {\n    channel: 25,\n    level: 29,\n    success: true,\n};\n\n//Add level\nif (msg.olddata.lightbulb.isOn == false) {\n    msg.payload.level = 0\n    }\nif (msg.olddata.lightbulb.isOn == true) {\n    msg.payload.level = msg.olddata.lightbulb.dimmer\n    }    \n\n//Insert success\nmsg.payload.success = true\n\n//Return msg\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":780,"y":440,"wires":[["d57ede79754f77fd"]]},{"id":"d57ede79754f77fd","type":"hdl-raw-out","z":"476aa68f8e4864eb","controller":"","name":"","x":970,"y":460,"wires":[]},{"id":"435a4cf40fd44815","type":"change","z":"476aa68f8e4864eb","name":"Move","rules":[{"t":"set","p":"olddata","pt":"msg","to":"payload","tot":"msg"},{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":460,"wires":[["e4e2b3eb5f75ae7c"]]},{"id":"bab4eeaa498c7e5b","type":"function","z":"476aa68f8e4864eb","name":"Change","func":"// Insert msg.code\nmsg.code = 50\n\n//Add target\nmsg.target = \"1.118\"\n\n//Add payload channel\nmsg.payload = {\n    channel: 25,\n    level: 29,\n    success: true,\n};\n\n//Add level\nif (msg.olddata.lightbulb.isOn == false) {\n    msg.payload.level = 0\n    }\nif (msg.olddata.lightbulb.isOn == true) {\n    msg.payload.level = msg.olddata.lightbulb.dimmer\n    }    \n\n//Insert success\nmsg.payload.success = true\n\n//Return msg\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":780,"y":500,"wires":[["d57ede79754f77fd"]]},{"id":"506e37ad5e6b5963","type":"debug","z":"476aa68f8e4864eb","name":"answeerback to HDL","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":980,"y":100,"wires":[]}]

It is possible to make a flow check if the answerback message is the same as the command message and if not resend the command. You would have to share you current setup if you would like me to make an example.

I checked with HDL support regarding the status reporting from the curtain controller. The answer was:

For curtain module, it just support OPEN/CLOSE/STOP, it does not have position. When you stop the curtain in 50%, curtain module will feedback Stop command.

Would it be possible to work around this somehow? Since we know how long it takes for the screen to move from full UP position to full DOWN - maybe NodeRed could keep track of the time spent in OPEN or CLOSE status? That way a variable could be created to reflect actual position of the screen (0-100%) - moving x amount of % pr sec (depending on time to run from OPEN to CLOSE as programmed in HDL Buspro Setup Tool).

The goal is to command the curtain to a position (based on slider or % in HA) . NodeRed would know the position of the screen based on a variable - and command the screen up or down as applicable.

Yes this would be possible. I have been planing to do the same for the tilt on my RF blinds as they only have UP Down Stop aswell(and then use a suntracker for automatic control), but not had time to look into it yet. Should be easy to reuse it for HDL once i get around to it.

Have been looking for a premade palette or solution with the function described but not found any i can use yet. (I am sure that other people must have made this before) It would be possible to make it with scrips etc. from scratch but this could be more complicated and might need different flow for each blind.

Have seen this post where they made support for the same function back in 2017 but not had time to check if this is implementable to the MQTT covers or what the current status is there. I do not have that good understanding of how HA works.

Update:

Did they happen to have a new firmware for you module?

Just found this thread where the needed function is premade for Nodered UI. Will try to see if i get some time to try and modify it for HA - HDL tomorrow.

I have now suggested a custom firmware that implements position. Will report back here when I get a reply from HDL.

Thanks again Linax😎

I guess the position feature is available in other curtain relays (i.e Fibaro Roller Shutter) - but it would be nice to use the HDL relays to maintain native control of screens from other HDL devices.

Yes i belive so to, that is why my RF blinds are controlled from HDL via a somfy RS-232 gateway.

I only have 2x normal roller curtains connected to 12i1 sensors instead of the curtain module saw a need for the curtain controller as the 12i1 in the same rooms had 2 relays awailable.

Never saw the need for setting it to other than 100% or 0% as it is only in bedrooms and only open or closed was needed, but when i found the shutter card i desided to implement % for my wired blinds to :slight_smile:

My logic is a bit different than your codes for the curtain module so did some copy paste and not 100% it will work for you.

To test you will have to do the following:

  • Add a file to HA config folder named “cover.yaml” with following inside:
#### Test % blinds ####

#

# Test Blind 1

- platform: mqtt

 name: "Test Blind 1"

 device_class: shade

 # Description for command_topic and set_position_topic: hdl/cp/"subnet"."deviceid"/"curtain ch"."milliseconds to open"."milliseconds to close."steps"/"topic"

 command_topic: "hdl/cp/1.5/1.10000.10000.10/set"

 set_position_topic: "hdl/cp/1.5/1.10000.10000.10/set"

 state_topic: "hdl/cp/1.5/1/state"

 position_closed: 0

 position_open: 100

 position_topic: "hdl/cp/1.5/1/position"

#

# Test Blind 2

- platform: mqtt

 name: "Test Blind 2"

 device_class: shade

 # Description for command_topic and set_position_topic: hdl/cp/"subnet"."deviceid"/"curtain ch"."milliseconds to open"."milliseconds to close."steps"/"topic"

 command_topic: "hdl/cp/1.5/2.10000.10000.10/set"

 set_position_topic: "hdl/cp/1.5/2.20000.20000.10/set"

 state_topic: "hdl/cp/1.5/2/state"

 position_closed: 0

 position_open: 100

 position_topic: "hdl/cp/1.5/2/position"
  • Add the following to the configuration.yaml file:

cover: !include cover.yaml

  • You might have to disable your current blinds if you have them in the configuration.yaml file, or reformat the above code to work in the config file.

  • I used custom cards as i dont like the default setup for the original one and did not bother with trying to figure out the automatins etc for getting a slider to work for something other than lights. So you will have to install: Shutter Card and slider-entity-row and, easyest way is via HACS.

  • Refresh browser and add a “grid card” to a dashboard. Click “Show code editor” and replace text with:

square: false
columns: 1
type: grid
cards:
  - type: entities
    title: Test Original Card
    entities:
      - entity: cover.test_blind_1
    show_header_toggle: true
  - type: custom:shutter-card
    title: Shutter Card
    entities:
      - entity: cover.test_blind_1
        name: Test Blinds 1
        buttons_position: left
        title_position: top
        invert_percentage: false
  - type: entities
    title: Slider Entity Row
    entities:
      - type: custom:slider-entity-row
        action: position
        entity: cover.test_blind_1
        tap_action:
          action: toggle
        hold_action:
          action: more-info
        step: 1

This should get you to a setup like this:

*Disable your current curtains flow in nodered and import this test flow:

[{"id":"82db28d3b515ed99","type":"tab","label":"Curtain % test HDL","disabled":false,"info":"","env":[]},{"id":"7fc939ac40505a15","type":"delay","z":"82db28d3b515ed99","name":"Timer","pauseType":"delayv","timeout":"10","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":990,"y":200,"wires":[["f8e11707c0d06f97"]]},{"id":"3599854728e07619","type":"switch","z":"82db28d3b515ed99","name":"Done?","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"done","vt":"str"},{"t":"nnull"}],"checkall":"false","repair":false,"outputs":2,"x":870,"y":200,"wires":[[],["7fc939ac40505a15","4b845feef20b42df"]]},{"id":"349a563976f14f1c","type":"inject","z":"82db28d3b515ed99","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"25","payloadType":"num","x":330,"y":540,"wires":[["dae29e6fb35d8854"]]},{"id":"59d0cb87d2480f08","type":"inject","z":"82db28d3b515ed99","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":330,"y":460,"wires":[["dae29e6fb35d8854"]]},{"id":"6e31adcc2e24f461","type":"inject","z":"82db28d3b515ed99","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"50","payloadType":"num","x":330,"y":580,"wires":[["dae29e6fb35d8854"]]},{"id":"dae29e6fb35d8854","type":"function","z":"82db28d3b515ed99","name":"Save Target","func":"//Save target to context data\nflow.set(msg.contextaddress + \".target\", msg.payload);\n\n//return\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":650,"y":280,"wires":[["f8e11707c0d06f97","64b7480343fc651e"]]},{"id":"f8e11707c0d06f97","type":"function","z":"82db28d3b515ed99","name":"Set direction","func":"//Load current position from context data\nvar current = flow.get(msg.contextaddress + \".current\")||0;\n\n//Load target position from context data\nvar target = flow.get(msg.contextaddress + \".target\")||0;\n\n//Calculate difference\nvar dif = target - current\n\n//Save diference to context data\nflow.set(msg.contextaddress + \".dif\",dif);\n\n// Check if target is Up\nif (dif > 0){msg.topic=\"increment\";}\n\n//Check if target is Down\nelse if (dif < 0){msg.topic=\"decrement\";}\n\n//Check if target is current possition and stop loop\nelse if (dif === 0){msg.topic=\"done\";}\n\n//Check if Loop Stopped\n\n\n//Return message\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":850,"y":280,"wires":[["16899ed749c6eb89","4a652905eb4e03c3"]]},{"id":"1015f12f6c351678","type":"function","z":"82db28d3b515ed99","name":"Reset","func":"//Set current to payload\nvar current = msg.payload\n\n//Save current\nflow.set(\"hdl/cp/1.5/1.current\",current);\n\n//Save target to context data\nflow.set(\"hdl/cp/1.5/1.target\", current);\n\n//Save difference\nflow.set (\"hdl/cp/1.5/1.dif\",0)\n\n//address\nmsg.contextaddress = \"hdl/cp/1.5/1\"\n\n//Return msg\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":490,"y":760,"wires":[["72c4e2cd54603d8f","f8e11707c0d06f97"]]},{"id":"16899ed749c6eb89","type":"function","z":"82db28d3b515ed99","name":"counter","func":"//Load current position from context data\nvar current = flow.get(msg.contextaddress + \".current\")||0;\n\n//Load target position from context data\nvar abstarget = flow.get(msg.contextaddress + \".target\")||0;\n\n//Load diference from context data\nvar dif = flow.get(msg.contextaddress + \".dif\")||0;\n\n// add 1 to count\nif (dif > 0){current++} \n\n// Retract 1 from count\nelse if (dif < 0){current--}\n\n// Save current count to context data\nflow.set(msg.contextaddress + \".current\", current);\n\n// Update current count to payload\nmsg.payload = current\n\n//Return msg\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1000,"y":280,"wires":[["fda5e6017b7c63c1","942346186622525e","3599854728e07619","ca77ce671bc2cc38"]]},{"id":"ea0a79b4ef3acbc5","type":"inject","z":"82db28d3b515ed99","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"75","payloadType":"num","x":330,"y":620,"wires":[["dae29e6fb35d8854"]]},{"id":"b9fc6bf74c200209","type":"inject","z":"82db28d3b515ed99","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"100","payloadType":"num","x":330,"y":660,"wires":[["dae29e6fb35d8854"]]},{"id":"5b625ac097747ae1","type":"mqtt in","z":"82db28d3b515ed99","name":"","topic":"hdl/cp/+/+/set","qos":"2","datatype":"auto","broker":"","nl":false,"rap":true,"rh":0,"inputs":0,"x":110,"y":300,"wires":[["ab38dab9a71fa36c"]]},{"id":"63ac6586a9963c9c","type":"comment","z":"82db28d3b515ed99","name":"Test %","info":"","x":290,"y":420,"wires":[]},{"id":"3551dbe141235cd4","type":"comment","z":"82db28d3b515ed99","name":"From MQTT","info":"","x":90,"y":260,"wires":[]},{"id":"f0776094225c6b84","type":"function","z":"82db28d3b515ed99","name":"Split","func":"//Define Payload as number\nmsg.payload = Number(msg.payload)\n\n\n//Split from main topic\nchtimesandsplit = msg.topic.split(\"/\")[3]\n\n\n//Split CH, Open Time, Close Time and Steps\nmsg.channel = Number(chtimesandsplit.split(\".\")[0])\nopentime = Number(chtimesandsplit.split(\".\")[1])\n//msg.closetime = Number(chtimesandsplit.split(\".\")[2])\n//msg.steps = Number(chtimesandsplit.split(\".\")[3])\n\n\n//Calculate and enter time to message for delay node\nmsg.delay = opentime / 100\n\n//Build Context Data address\nmsg.contextaddress = \"hdl/cp/\" + msg.topic.split(\"/\")[2] + \"/\" + msg.channel;\n\n\n//Return\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":490,"y":280,"wires":[["dae29e6fb35d8854"]]},{"id":"ef028066edde1eb7","type":"inject","z":"82db28d3b515ed99","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":330,"y":800,"wires":[["1015f12f6c351678"]]},{"id":"216d5ae88e8d1aba","type":"inject","z":"82db28d3b515ed99","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":330,"y":760,"wires":[["1015f12f6c351678"]]},{"id":"45687093f3ecb89c","type":"inject","z":"82db28d3b515ed99","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"50","payloadType":"num","x":330,"y":880,"wires":[["1015f12f6c351678"]]},{"id":"5a98cf9db1ce6104","type":"inject","z":"82db28d3b515ed99","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"75","payloadType":"num","x":330,"y":920,"wires":[["1015f12f6c351678"]]},{"id":"262aea74cde73dad","type":"inject","z":"82db28d3b515ed99","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"100","payloadType":"num","x":330,"y":960,"wires":[["1015f12f6c351678"]]},{"id":"1ec8a2d96703e81a","type":"comment","z":"82db28d3b515ed99","name":"Calibrate % and stop loop","info":"","x":350,"y":720,"wires":[]},{"id":"fda5e6017b7c63c1","type":"debug","z":"82db28d3b515ed99","name":"Update Current Position ","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1210,"y":420,"wires":[]},{"id":"72c4e2cd54603d8f","type":"debug","z":"82db28d3b515ed99","name":"Reset","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":650,"y":760,"wires":[]},{"id":"3eb68746ac2e435a","type":"inject","z":"82db28d3b515ed99","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"25","payloadType":"num","x":330,"y":840,"wires":[["1015f12f6c351678"]]},{"id":"9f0ec1a267c23e3a","type":"inject","z":"82db28d3b515ed99","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":330,"y":500,"wires":[["dae29e6fb35d8854"]]},{"id":"a153e4ccc14a521b","type":"inject","z":"82db28d3b515ed99","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":330,"y":1100,"wires":[["3eab082f88a132a1"]]},{"id":"9dbf71f20f2f79c1","type":"inject","z":"82db28d3b515ed99","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":330,"y":1060,"wires":[["3eab082f88a132a1"]]},{"id":"ca03ea107cc1869f","type":"inject","z":"82db28d3b515ed99","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"50","payloadType":"num","x":330,"y":1180,"wires":[["3eab082f88a132a1"]]},{"id":"a32340308243d8fe","type":"inject","z":"82db28d3b515ed99","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"75","payloadType":"num","x":330,"y":1220,"wires":[["3eab082f88a132a1"]]},{"id":"90c85758d0fa83cc","type":"inject","z":"82db28d3b515ed99","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"100","payloadType":"num","x":330,"y":1260,"wires":[["3eab082f88a132a1"]]},{"id":"f1787e464728407d","type":"comment","z":"82db28d3b515ed99","name":"Manually Change MQTT feedback value","info":"","x":390,"y":1020,"wires":[]},{"id":"4ce3b8ea0bcb4b1d","type":"inject","z":"82db28d3b515ed99","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"25","payloadType":"num","x":330,"y":1140,"wires":[["3eab082f88a132a1"]]},{"id":"3eab082f88a132a1","type":"function","z":"82db28d3b515ed99","name":"Insert topic","func":"msg.topic = \"hdl/cp/1.5/1/position\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":530,"y":1160,"wires":[["5aaa0e452489ef82"]]},{"id":"5aaa0e452489ef82","type":"mqtt out","z":"82db28d3b515ed99","name":"Status updates to MQTT","topic":"","qos":"0","retain":"true","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"","x":1590,"y":1500,"wires":[]},{"id":"942346186622525e","type":"function","z":"82db28d3b515ed99","name":"Send Updated % Position to MQTT","func":"msg.topic = msg.contextaddress + \"/position\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1280,"y":360,"wires":[["503d8a0c109fd582","5aaa0e452489ef82"]]},{"id":"503d8a0c109fd582","type":"debug","z":"82db28d3b515ed99","name":"To MQTT","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1660,"y":400,"wires":[]},{"id":"ab38dab9a71fa36c","type":"switch","z":"82db28d3b515ed99","name":"Type","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"STOP","vt":"str"},{"t":"btwn","v":"0","vt":"num","v2":"100","v2t":"num"},{"t":"eq","v":"OPEN","vt":"str"},{"t":"eq","v":"CLOSE","vt":"str"}],"checkall":"false","repair":false,"outputs":4,"x":250,"y":300,"wires":[["1a1b769f0fe8298e"],["f0776094225c6b84"],["103cc782e9ec590f"],["103cc782e9ec590f"]]},{"id":"103cc782e9ec590f","type":"change","z":"82db28d3b515ed99","name":"% set","rules":[{"t":"change","p":"payload","pt":"msg","from":"OPEN","fromt":"str","to":"100","tot":"num"},{"t":"change","p":"payload","pt":"msg","from":"CLOSE","fromt":"str","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":320,"wires":[["f0776094225c6b84"]]},{"id":"1a1b769f0fe8298e","type":"function","z":"82db28d3b515ed99","name":"Manual Stop of the Blinds / Loop","func":"//Split from main topic\nchtimesandsplit = msg.topic.split(\"/\")[3]\n\n//Split CH\nmsg.channel = Number(chtimesandsplit.split(\".\")[0])\n\n\n//Build Context Data address\nmsg.contextaddress = \"hdl/cp/\" + msg.topic.split(\"/\")[2] + \"/\" + msg.channel;\n\n\n//Load current position from context data\nvar current = flow.get(msg.contextaddress + \".current\");\n\n//Save target to context data\nflow.set(msg.contextaddress + \".target\", current);\n\n//Change Payload to current \nmsg.payload = current\n\n//return\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":570,"y":240,"wires":[["f8e11707c0d06f97","44f76b6ea9e26658"]]},{"id":"44f76b6ea9e26658","type":"debug","z":"82db28d3b515ed99","name":"Stop inject","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":690,"y":140,"wires":[]},{"id":"4a652905eb4e03c3","type":"debug","z":"82db28d3b515ed99","name":"Set dir","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":990,"y":340,"wires":[]},{"id":"64b7480343fc651e","type":"debug","z":"82db28d3b515ed99","name":"Save tar","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":840,"y":340,"wires":[]},{"id":"4b845feef20b42df","type":"debug","z":"82db28d3b515ed99","name":"delay","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":990,"y":160,"wires":[]},{"id":"f5a817c3812feedd","type":"switch","z":"82db28d3b515ed99","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"done","vt":"str"},{"t":"eq","v":"increment","vt":"str"},{"t":"eq","v":"decrement","vt":"str"}],"checkall":"false","repair":false,"outputs":3,"x":1310,"y":220,"wires":[["f808e16c36f4734a","cc6779fb5888f1e0"],["82e983fa2e017282","f808e16c36f4734a"],["4c33d7ddc2a03df1","f808e16c36f4734a"]]},{"id":"82e983fa2e017282","type":"function","z":"82db28d3b515ed99","name":"Open","func":"//Build new open message\nmsg.code = 58336;\nmsg.target = msg.contextaddress.split(\"/\")[2];\nmsg.payload = {\n    curtain: Number(msg.contextaddress.split(\"/\")[3]),\n    status: 1,\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1450,"y":220,"wires":[["ca09e63223db2cb8","1df5758fb4fa0a46"]],"info":"msg.topic = \"hdl/us/\" + msg.sender + \"/\" + msg.payload.switch;\nvar status = msg.payload.status\nif (status === true) \n    {\n    msg.payload = \"ON\";\n    } \n    else \n    {\n    msg.payload = \"OFF\";\n    }\nreturn msg;"},{"id":"cc6779fb5888f1e0","type":"function","z":"82db28d3b515ed99","name":"Done?","func":"//Build new stop message if target is not 0% or 100%\nif (msg.payload >= 1 && msg.payload <= 99) {\nmsg.code = 58336;\nmsg.target = msg.contextaddress.split(\"/\")[2];\nmsg.payload = {\n    curtain: Number(msg.contextaddress.split(\"/\")[3]),\n    status: 0,\n};\nreturn msg;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1450,"y":180,"wires":[["ca09e63223db2cb8","1df5758fb4fa0a46"]],"info":"msg.topic = \"hdl/us/\" + msg.sender + \"/\" + msg.payload.switch;\nvar status = msg.payload.status\nif (status === true) \n    {\n    msg.payload = \"ON\";\n    } \n    else \n    {\n    msg.payload = \"OFF\";\n    }\nreturn msg;"},{"id":"4c33d7ddc2a03df1","type":"function","z":"82db28d3b515ed99","name":"Close","func":"//Build new close message\nmsg.code = 58336;\nmsg.target = msg.contextaddress.split(\"/\")[2];\nmsg.payload = {\n    curtain: Number(msg.contextaddress.split(\"/\")[3]),\n    status: 2,\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1450,"y":260,"wires":[["ca09e63223db2cb8","1df5758fb4fa0a46"]],"info":"msg.topic = \"hdl/us/\" + msg.sender + \"/\" + msg.payload.switch;\nvar status = msg.payload.status\nif (status === true) \n    {\n    msg.payload = \"ON\";\n    } \n    else \n    {\n    msg.payload = \"OFF\";\n    }\nreturn msg;"},{"id":"1df5758fb4fa0a46","type":"debug","z":"82db28d3b515ed99","name":"To HDL","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1660,"y":300,"wires":[]},{"id":"f808e16c36f4734a","type":"debug","z":"82db28d3b515ed99","name":"Pre HDL","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1400,"y":300,"wires":[]},{"id":"ca77ce671bc2cc38","type":"rbe","z":"82db28d3b515ed99","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"topic","topi":"topic","x":1190,"y":220,"wires":[["f5a817c3812feedd"]]},{"id":"4dddb4cca5626055","type":"hdl-raw-in","z":"82db28d3b515ed99","controller":"","name":"From HDL","x":120,"y":1520,"wires":[["6bd1d8770e547348"]]},{"id":"4caf94421826f615","type":"comment","z":"82db28d3b515ed99","name":"Feedback from HDL to MQTT","info":"","x":140,"y":1360,"wires":[]},{"id":"6bd1d8770e547348","type":"switch","z":"82db28d3b515ed99","name":"","property":"code","propertyType":"msg","rules":[{"t":"eq","v":"50","vt":"str"},{"t":"eq","v":"52","vt":"str"},{"t":"eq","v":"57373","vt":"str"},{"t":"eq","v":"57369","vt":"str"},{"t":"eq","v":"5703","vt":"str"},{"t":"eq","v":"5637","vt":"str"},{"t":"eq","v":"58341","vt":"str"},{"t":"eq","v":"6471","vt":"str"},{"t":"eq","v":"6469","vt":"str"},{"t":"eq","v":"7263","vt":"str"},{"t":"eq","v":"7261","vt":"str"},{"t":"eq","v":"6457","vt":"str"},{"t":"eq","v":"6459","vt":"str"},{"t":"eq","v":"58337","vt":"str"},{"t":"eq","v":"58340","vt":"str"}],"checkall":"false","repair":false,"outputs":15,"x":250,"y":1520,"wires":[[],[],[],[],[],[],[],[],[],[],[],[],[],[],["e4f4cb87d2b737f2","8edfb163d135a32b","435fd4cd25251e42"]]},{"id":"2c9d83557a597e80","type":"comment","z":"82db28d3b515ed99","name":"Motorized Curtain Control Module","info":"","x":570,"y":1500,"wires":[]},{"id":"54bd9f96d12d1d74","type":"debug","z":"82db28d3b515ed99","name":"To MQTT","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1040,"y":1520,"wires":[]},{"id":"89bbf8cae1491e59","type":"inject","z":"82db28d3b515ed99","name":"Broadcast 1 close","props":[{"p":"sender","v":"1.5","vt":"str"},{"p":"target","v":"255.255","vt":"str"},{"p":"code","v":"58340","vt":"num"},{"p":"payload.curtains.0.number","v":"1","vt":"num"},{"p":"payload.curtains.0.level","v":"2","vt":"num"},{"p":"payload.curtains.0.status","v":"2","vt":"num"},{"p":"payload.curtains.1.number","v":"2","vt":"num"},{"p":"payload.curtains.1.level","v":"0","vt":"num"},{"p":"payload.curtains.1.status","v":"0","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":130,"y":1720,"wires":[["435fd4cd25251e42","8edfb163d135a32b"]]},{"id":"a2d54fda76338620","type":"inject","z":"82db28d3b515ed99","name":"Broadcast 1 stop","props":[{"p":"sender","v":"1.5","vt":"str"},{"p":"target","v":"255.255","vt":"str"},{"p":"code","v":"58340","vt":"num"},{"p":"payload.curtains.0.number","v":"1","vt":"num"},{"p":"payload.curtains.0.level","v":"0","vt":"num"},{"p":"payload.curtains.0.status","v":"0","vt":"num"},{"p":"payload.curtains.1.number","v":"2","vt":"num"},{"p":"payload.curtains.1.level","v":"0","vt":"num"},{"p":"payload.curtains.1.status","v":"0","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":120,"y":1760,"wires":[["435fd4cd25251e42","8edfb163d135a32b"]]},{"id":"6011aae9e84a5f04","type":"inject","z":"82db28d3b515ed99","name":"Broadcast 1 open","props":[{"p":"sender","v":"1.5","vt":"str"},{"p":"target","v":"255.255","vt":"str"},{"p":"code","v":"58340","vt":"num"},{"p":"payload.curtains.0.number","v":"1","vt":"num"},{"p":"payload.curtains.0.level","v":"1","vt":"num"},{"p":"payload.curtains.0.status","v":"1","vt":"num"},{"p":"payload.curtains.1.number","v":"2","vt":"num"},{"p":"payload.curtains.1.level","v":"0","vt":"num"},{"p":"payload.curtains.1.status","v":"0","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":120,"y":1680,"wires":[["435fd4cd25251e42","8edfb163d135a32b"]]},{"id":"eefd437a5ada659e","type":"function","z":"82db28d3b515ed99","name":"Curtain Opening","func":"msg.topic = \"hdl/cp/\" + msg.sender + \"/\" + msg.payload.number + \"/state\";\nmsg.payload = \"opening\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":860,"y":1580,"wires":[["54bd9f96d12d1d74","fbbba0f3ce4c2c8d"]]},{"id":"4d708a73ad7fe217","type":"switch","z":"82db28d3b515ed99","name":"status","property":"payload.status","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"num"},{"t":"eq","v":"0","vt":"num"}],"checkall":"false","repair":false,"outputs":3,"x":670,"y":1620,"wires":[["eefd437a5ada659e"],["ae5b0bba02fab653"],["d5ca2eb1f80aa017"]]},{"id":"ae5b0bba02fab653","type":"function","z":"82db28d3b515ed99","name":"Curtain Closing","func":"msg.topic = \"hdl/cp/\" + msg.sender + \"/\" + msg.payload.number + \"/state\";\nmsg.payload = \"closing\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":860,"y":1620,"wires":[["54bd9f96d12d1d74","fbbba0f3ce4c2c8d"]]},{"id":"d5ca2eb1f80aa017","type":"function","z":"82db28d3b515ed99","name":"Curtain Stopped","func":"msg.topic = \"hdl/cp/\" + msg.sender + \"/\" + msg.payload.number + \"/state\";\nmsg.payload = \"stopped\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":860,"y":1660,"wires":[["54bd9f96d12d1d74","fbbba0f3ce4c2c8d"]]},{"id":"1500e6abd0573001","type":"comment","z":"82db28d3b515ed99","name":"Broadcast msg","info":"","x":560,"y":1560,"wires":[]},{"id":"435fd4cd25251e42","type":"debug","z":"82db28d3b515ed99","name":"To MQTT","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":340,"y":1800,"wires":[]},{"id":"e4f4cb87d2b737f2","type":"change","z":"82db28d3b515ed99","name":"CH 2","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.curtains.1","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":1760,"wires":[["473009273b725054"]]},{"id":"8edfb163d135a32b","type":"change","z":"82db28d3b515ed99","name":"CH 1","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.curtains.0","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":1620,"wires":[["4d708a73ad7fe217"]]},{"id":"92c99617936cc788","type":"function","z":"82db28d3b515ed99","name":"Curtain Opening","func":"msg.topic = \"hdl/cp/\" + msg.sender + \"/\" + msg.payload.number + \"/state\";\nmsg.payload = \"opening\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":860,"y":1720,"wires":[["a0b30cf2d8793001"]]},{"id":"3341897c03f479b6","type":"function","z":"82db28d3b515ed99","name":"Curtain Closing","func":"msg.topic = \"hdl/cp/\" + msg.sender + \"/\" + msg.payload.number + \"/state\";\nmsg.payload = \"closing\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":860,"y":1760,"wires":[["a0b30cf2d8793001"]]},{"id":"656fc12b6e98a667","type":"function","z":"82db28d3b515ed99","name":"Curtain Stopped","func":"msg.topic = \"hdl/cp/\" + msg.sender + \"/\" + msg.payload.number + \"/state\";\nmsg.payload = \"stopped\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":860,"y":1800,"wires":[["a0b30cf2d8793001"]]},{"id":"473009273b725054","type":"switch","z":"82db28d3b515ed99","name":"status","property":"payload.status","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"num"},{"t":"eq","v":"0","vt":"num"}],"checkall":"false","repair":false,"outputs":3,"x":670,"y":1760,"wires":[["92c99617936cc788"],["3341897c03f479b6"],["656fc12b6e98a667"]]},{"id":"a0b30cf2d8793001","type":"rbe","z":"82db28d3b515ed99","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","topi":"topic","x":1030,"y":1760,"wires":[["5aaa0e452489ef82"]]},{"id":"fbbba0f3ce4c2c8d","type":"rbe","z":"82db28d3b515ed99","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","topi":"topic","x":1030,"y":1620,"wires":[["5aaa0e452489ef82"]]},{"id":"ca09e63223db2cb8","type":"hdl-raw-out","z":"82db28d3b515ed99","controller":"","name":"","x":1680,"y":220,"wires":[]}]
  • Change the 4x in and out nodes to match your setup.

For info it is important that you enter the opening time in milliseconds(in the cover.yaml file) if it is entered in secounds the loop might go crazy fast and it could overload the CPU depending on your hardware.
Also time to close and steps are not in use at the moment and is ignored in the flow (But dont remove the values as this might corrupt something).

Think the % calibration(to avoid drift after lots of on the sliders) should be done by it self now everytime the blind is in 100% or 0% but have not done any testing on this yet.
Let me know what does not work for your setup, have left all the debug nodes in there if some debuging is needed :smiley:

Wow - that worked - almost perfect!! I´m impressed😎

The only issue seems to be that the two (or more) shutters will not run at the same time. For some reason if I command both screens up or down the first shutter will start - do it´s thing by moving to the correct position - and then the second screen will run.

The status update issues we discussed in a previous post also seemn to be resolved by this new solution :+1::+1:

Will the second screen run to the correct position or just for a short while?

Is the blinds moving at the same time in the GUI?

Status updates are a bit different now with HDL broadcast only changing to opening, closing and stopped. The Open/Closed and % is handled with the loop. And should calibrate possible drift by it self everytime the blind is set to 0% or 100%.

Think the error must be in the output filter. Modified the flow with one filter for each channel instead of only the one for both.

[{"id":"82db28d3b515ed99","type":"tab","label":"Curtain % test HDL","disabled":false,"info":"","env":[]},{"id":"7fc939ac40505a15","type":"delay","z":"82db28d3b515ed99","name":"Timer","pauseType":"delayv","timeout":"10","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":990,"y":200,"wires":[["f8e11707c0d06f97"]]},{"id":"3599854728e07619","type":"switch","z":"82db28d3b515ed99","name":"Done?","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"done","vt":"str"},{"t":"nnull"}],"checkall":"false","repair":false,"outputs":2,"x":870,"y":200,"wires":[[],["7fc939ac40505a15"]]},{"id":"dae29e6fb35d8854","type":"function","z":"82db28d3b515ed99","name":"Save Target","func":"//Save target to context data\nflow.set(msg.contextaddress + \".target\", msg.payload);\n\n//return\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":650,"y":280,"wires":[["f8e11707c0d06f97"]]},{"id":"f8e11707c0d06f97","type":"function","z":"82db28d3b515ed99","name":"Set direction","func":"//Load current position from context data\nvar current = flow.get(msg.contextaddress + \".current\")||0;\n\n//Load target position from context data\nvar target = flow.get(msg.contextaddress + \".target\")||0;\n\n//Calculate difference\nvar dif = target - current\n\n//Save diference to context data\nflow.set(msg.contextaddress + \".dif\",dif);\n\n// Check if target is Up\nif (dif > 0){msg.topic=\"increment\";}\n\n//Check if target is Down\nelse if (dif < 0){msg.topic=\"decrement\";}\n\n//Check if target is current possition and stop loop\nelse if (dif === 0){msg.topic=\"done\";}\n\n//Check if Loop Stopped\n\n\n//Return message\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":850,"y":280,"wires":[["16899ed749c6eb89"]]},{"id":"16899ed749c6eb89","type":"function","z":"82db28d3b515ed99","name":"counter","func":"//Load current position from context data\nvar current = flow.get(msg.contextaddress + \".current\")||0;\n\n//Load target position from context data\nvar abstarget = flow.get(msg.contextaddress + \".target\")||0;\n\n//Load diference from context data\nvar dif = flow.get(msg.contextaddress + \".dif\")||0;\n\n// add 1 to count\nif (dif > 0){current++} \n\n// Retract 1 from count\nelse if (dif < 0){current--}\n\n// Save current count to context data\nflow.set(msg.contextaddress + \".current\", current);\n\n// Update current count to payload\nmsg.payload = current\n\n//Return msg\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1000,"y":280,"wires":[["942346186622525e","3599854728e07619","bdc9ac219151cdad","010debd8a061f808"]]},{"id":"5b625ac097747ae1","type":"mqtt in","z":"82db28d3b515ed99","name":"","topic":"hdl/cp/+/+/set","qos":"2","datatype":"auto","broker":"","nl":false,"rap":true,"rh":0,"inputs":0,"x":110,"y":300,"wires":[["ab38dab9a71fa36c"]]},{"id":"3551dbe141235cd4","type":"comment","z":"82db28d3b515ed99","name":"From MQTT","info":"","x":90,"y":260,"wires":[]},{"id":"f0776094225c6b84","type":"function","z":"82db28d3b515ed99","name":"Split","func":"//Define Payload as number\nmsg.payload = Number(msg.payload)\n\n\n//Split from main topic\nchtimesandsplit = msg.topic.split(\"/\")[3]\n\n\n//Split CH, Open Time, Close Time and Steps\nmsg.channel = Number(chtimesandsplit.split(\".\")[0])\nopentime = Number(chtimesandsplit.split(\".\")[1])\n//msg.closetime = Number(chtimesandsplit.split(\".\")[2])\n//msg.steps = Number(chtimesandsplit.split(\".\")[3])\n\n\n//Calculate and enter time to message for delay node\nmsg.delay = opentime / 100\n\n//Build Context Data address\nmsg.contextaddress = \"hdl/cp/\" + msg.topic.split(\"/\")[2] + \"/\" + msg.channel;\n\n\n//Return\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":490,"y":280,"wires":[["dae29e6fb35d8854"]]},{"id":"5aaa0e452489ef82","type":"mqtt out","z":"82db28d3b515ed99","name":"Status updates to MQTT","topic":"","qos":"0","retain":"true","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"","x":1730,"y":700,"wires":[]},{"id":"942346186622525e","type":"function","z":"82db28d3b515ed99","name":"Send Updated % Position to MQTT","func":"msg.topic = msg.contextaddress + \"/position\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1240,"y":440,"wires":[["5aaa0e452489ef82"]]},{"id":"ab38dab9a71fa36c","type":"switch","z":"82db28d3b515ed99","name":"Type","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"STOP","vt":"str"},{"t":"btwn","v":"0","vt":"num","v2":"100","v2t":"num"},{"t":"eq","v":"OPEN","vt":"str"},{"t":"eq","v":"CLOSE","vt":"str"}],"checkall":"false","repair":false,"outputs":4,"x":250,"y":300,"wires":[["1a1b769f0fe8298e"],["f0776094225c6b84"],["103cc782e9ec590f"],["103cc782e9ec590f"]]},{"id":"103cc782e9ec590f","type":"change","z":"82db28d3b515ed99","name":"% set","rules":[{"t":"change","p":"payload","pt":"msg","from":"OPEN","fromt":"str","to":"100","tot":"num"},{"t":"change","p":"payload","pt":"msg","from":"CLOSE","fromt":"str","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":320,"wires":[["f0776094225c6b84"]]},{"id":"1a1b769f0fe8298e","type":"function","z":"82db28d3b515ed99","name":"Manual Stop of the Blinds / Loop","func":"//Split from main topic\nchtimesandsplit = msg.topic.split(\"/\")[3]\n\n//Split CH\nmsg.channel = Number(chtimesandsplit.split(\".\")[0])\n\n\n//Build Context Data address\nmsg.contextaddress = \"hdl/cp/\" + msg.topic.split(\"/\")[2] + \"/\" + msg.channel;\n\n\n//Load current position from context data\nvar current = flow.get(msg.contextaddress + \".current\");\n\n//Save target to context data\nflow.set(msg.contextaddress + \".target\", current);\n\n//Change Payload to current \nmsg.payload = current\n\n//return\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":570,"y":240,"wires":[["f8e11707c0d06f97"]]},{"id":"f5a817c3812feedd","type":"switch","z":"82db28d3b515ed99","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"done","vt":"str"},{"t":"eq","v":"increment","vt":"str"},{"t":"eq","v":"decrement","vt":"str"}],"checkall":"false","repair":false,"outputs":3,"x":1470,"y":280,"wires":[["cc6779fb5888f1e0"],["82e983fa2e017282"],["4c33d7ddc2a03df1"]]},{"id":"82e983fa2e017282","type":"function","z":"82db28d3b515ed99","name":"Open","func":"//Build new open message\nmsg.code = 58336;\nmsg.target = msg.contextaddress.split(\"/\")[2];\nmsg.payload = {\n    curtain: Number(msg.contextaddress.split(\"/\")[3]),\n    status: 1,\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1610,"y":280,"wires":[["ca09e63223db2cb8"]],"info":"msg.topic = \"hdl/us/\" + msg.sender + \"/\" + msg.payload.switch;\nvar status = msg.payload.status\nif (status === true) \n    {\n    msg.payload = \"ON\";\n    } \n    else \n    {\n    msg.payload = \"OFF\";\n    }\nreturn msg;"},{"id":"cc6779fb5888f1e0","type":"function","z":"82db28d3b515ed99","name":"Done?","func":"//Build new stop message if target is not 0% or 100%\nif (msg.payload >= 1 && msg.payload <= 99) {\nmsg.code = 58336;\nmsg.target = msg.contextaddress.split(\"/\")[2];\nmsg.payload = {\n    curtain: Number(msg.contextaddress.split(\"/\")[3]),\n    status: 0,\n};\nreturn msg;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1610,"y":240,"wires":[["ca09e63223db2cb8"]],"info":"msg.topic = \"hdl/us/\" + msg.sender + \"/\" + msg.payload.switch;\nvar status = msg.payload.status\nif (status === true) \n    {\n    msg.payload = \"ON\";\n    } \n    else \n    {\n    msg.payload = \"OFF\";\n    }\nreturn msg;"},{"id":"4c33d7ddc2a03df1","type":"function","z":"82db28d3b515ed99","name":"Close","func":"//Build new close message\nmsg.code = 58336;\nmsg.target = msg.contextaddress.split(\"/\")[2];\nmsg.payload = {\n    curtain: Number(msg.contextaddress.split(\"/\")[3]),\n    status: 2,\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1610,"y":320,"wires":[["ca09e63223db2cb8"]],"info":"msg.topic = \"hdl/us/\" + msg.sender + \"/\" + msg.payload.switch;\nvar status = msg.payload.status\nif (status === true) \n    {\n    msg.payload = \"ON\";\n    } \n    else \n    {\n    msg.payload = \"OFF\";\n    }\nreturn msg;"},{"id":"ca77ce671bc2cc38","type":"rbe","z":"82db28d3b515ed99","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"topic","topi":"topic","x":1330,"y":260,"wires":[["f5a817c3812feedd","e783bae58a8f9654"]]},{"id":"4dddb4cca5626055","type":"hdl-raw-in","z":"82db28d3b515ed99","controller":"","name":"From HDL","x":100,"y":660,"wires":[["6bd1d8770e547348"]]},{"id":"4caf94421826f615","type":"comment","z":"82db28d3b515ed99","name":"Feedback from HDL to MQTT","info":"","x":140,"y":500,"wires":[]},{"id":"6bd1d8770e547348","type":"switch","z":"82db28d3b515ed99","name":"","property":"code","propertyType":"msg","rules":[{"t":"eq","v":"58340","vt":"str"}],"checkall":"false","repair":false,"outputs":1,"x":230,"y":660,"wires":[["e4f4cb87d2b737f2","8edfb163d135a32b"]]},{"id":"2c9d83557a597e80","type":"comment","z":"82db28d3b515ed99","name":"Motorized Curtain Control Module","info":"","x":570,"y":540,"wires":[]},{"id":"eefd437a5ada659e","type":"function","z":"82db28d3b515ed99","name":"Curtain Opening","func":"msg.topic = \"hdl/cp/\" + msg.sender + \"/\" + msg.payload.number + \"/state\";\nmsg.payload = \"opening\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":860,"y":620,"wires":[["fbbba0f3ce4c2c8d"]]},{"id":"4d708a73ad7fe217","type":"switch","z":"82db28d3b515ed99","name":"status","property":"payload.status","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"num"},{"t":"eq","v":"0","vt":"num"}],"checkall":"false","repair":false,"outputs":3,"x":670,"y":660,"wires":[["eefd437a5ada659e"],["ae5b0bba02fab653"],["d5ca2eb1f80aa017"]]},{"id":"ae5b0bba02fab653","type":"function","z":"82db28d3b515ed99","name":"Curtain Closing","func":"msg.topic = \"hdl/cp/\" + msg.sender + \"/\" + msg.payload.number + \"/state\";\nmsg.payload = \"closing\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":860,"y":660,"wires":[["fbbba0f3ce4c2c8d"]]},{"id":"d5ca2eb1f80aa017","type":"function","z":"82db28d3b515ed99","name":"Curtain Stopped","func":"msg.topic = \"hdl/cp/\" + msg.sender + \"/\" + msg.payload.number + \"/state\";\nmsg.payload = \"stopped\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":860,"y":700,"wires":[["fbbba0f3ce4c2c8d"]]},{"id":"1500e6abd0573001","type":"comment","z":"82db28d3b515ed99","name":"Broadcast msg","info":"","x":560,"y":600,"wires":[]},{"id":"e4f4cb87d2b737f2","type":"change","z":"82db28d3b515ed99","name":"CH 2","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.curtains.1","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":800,"wires":[["473009273b725054"]]},{"id":"8edfb163d135a32b","type":"change","z":"82db28d3b515ed99","name":"CH 1","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.curtains.0","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":660,"wires":[["4d708a73ad7fe217"]]},{"id":"92c99617936cc788","type":"function","z":"82db28d3b515ed99","name":"Curtain Opening","func":"msg.topic = \"hdl/cp/\" + msg.sender + \"/\" + msg.payload.number + \"/state\";\nmsg.payload = \"opening\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":860,"y":760,"wires":[["a0b30cf2d8793001"]]},{"id":"3341897c03f479b6","type":"function","z":"82db28d3b515ed99","name":"Curtain Closing","func":"msg.topic = \"hdl/cp/\" + msg.sender + \"/\" + msg.payload.number + \"/state\";\nmsg.payload = \"closing\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":860,"y":800,"wires":[["a0b30cf2d8793001"]]},{"id":"656fc12b6e98a667","type":"function","z":"82db28d3b515ed99","name":"Curtain Stopped","func":"msg.topic = \"hdl/cp/\" + msg.sender + \"/\" + msg.payload.number + \"/state\";\nmsg.payload = \"stopped\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":860,"y":840,"wires":[["a0b30cf2d8793001"]]},{"id":"473009273b725054","type":"switch","z":"82db28d3b515ed99","name":"status","property":"payload.status","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"num"},{"t":"eq","v":"0","vt":"num"}],"checkall":"false","repair":false,"outputs":3,"x":670,"y":800,"wires":[["92c99617936cc788"],["3341897c03f479b6"],["656fc12b6e98a667"]]},{"id":"a0b30cf2d8793001","type":"rbe","z":"82db28d3b515ed99","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","topi":"topic","x":1030,"y":800,"wires":[["5aaa0e452489ef82"]]},{"id":"fbbba0f3ce4c2c8d","type":"rbe","z":"82db28d3b515ed99","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","topi":"topic","x":1030,"y":660,"wires":[["5aaa0e452489ef82"]]},{"id":"ca09e63223db2cb8","type":"hdl-raw-out","z":"82db28d3b515ed99","controller":"","name":"","x":1770,"y":280,"wires":[]},{"id":"bdc9ac219151cdad","type":"debug","z":"82db28d3b515ed99","name":"raw","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1170,"y":220,"wires":[]},{"id":"010debd8a061f808","type":"switch","z":"82db28d3b515ed99","name":"channel","property":"channel","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"num"}],"checkall":"false","repair":false,"outputs":2,"x":1160,"y":280,"wires":[["ca77ce671bc2cc38","788e2a6e99422b1a","c5a13cccfba63188"],["abc4c9a88311066f"]]},{"id":"abc4c9a88311066f","type":"rbe","z":"82db28d3b515ed99","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"topic","topi":"topic","x":1330,"y":300,"wires":[["f5a817c3812feedd","d0df16fb9a0e3e45"]]},{"id":"788e2a6e99422b1a","type":"debug","z":"82db28d3b515ed99","name":"1","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1330,"y":220,"wires":[]},{"id":"c5a13cccfba63188","type":"debug","z":"82db28d3b515ed99","name":"2","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1330,"y":340,"wires":[]},{"id":"e783bae58a8f9654","type":"debug","z":"82db28d3b515ed99","name":"1 filter","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1520,"y":200,"wires":[]},{"id":"d0df16fb9a0e3e45","type":"debug","z":"82db28d3b515ed99","name":"2 filter","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1510,"y":400,"wires":[]}]

I did this integration. everthing is working fine. The swiches does not show the current status of hdl relays after reboot of the homeassistant. If hdl relay is on and we restart the system the front end switch will show off.

You will have to read the status of each relay module seperatly if you want the startup status to be synced, check out my second post on this thread.

thanks a lot. its working

i have 2 hdl ip gateway. Both form two seperate networks. so i have used two different flows. I am not able to get status of one network.

the first hdl network consist of 12 channel relay(1.1) and a hdl controller ip gateway (1.0) 192,168.3.143
the second network consist of hdl home controller MHRCU.433 (200.1) it has inbuilt hdl controller ip 192.168.3.142 gateway+relay channels+dimmer channels + curtains.

So in node red has 4 flows:
first hdl network: status flow and hdl test flow
second hdl network: status flow and hdl test flow
I dont understand why does the MHRCU.433 does not give status. Am I worng in using 2 flows?

Are the two network modules connected to separate hdl-bus networks or are they not connected by bus cable?

Idealy i would use 2 flows if they are not connected by bus wire, but I am not 100% sure the nodered paklet is able to communicate with 2 modules at one time as i have never tried it.

If you disable 1 of the flows does the other one work ok?

Both the networks are seperate from each other. The first hdl network and second hdl network are not connected by hdl bus. Currently i am able to control both the networks without any issue. Only the second network does not give status at start up.Processing: UM_HDL-MHRCU-433.pdf…

Is the problem due to MHRCU.433 since it is the mix module?. This module has inbuilt relays, dimmers, and curtains and hdl ip controller.

I disabled the status flow which is giving status at startup. But still the second status flow (MHRCU.433) does not give status.

Now I disabled the first network flows(status flow of the first network and the hdl control flow). But still MHRC.433 does not give status at startup.

I have found out the problem.
Setup 1:
First Network:
Hdl Ip Controller 192.168.3.143 (1.0)
Hdl 12 Channel RelaY (1.1)
node red flow 1 for controlling
node red flow 2 for status of channels at start up

Second Network:
Hdl Ip Controller mix module (MHRCU.443) 192.168.3.1432 (200.1)

node red flow 1 for controlling
node red flow 2 for status of channels at start up

Setup 2:
I wired both the hdl bus networks into a single hdl bus network
Single network
Hdl Ip Controller 192.168.3.143 (1.0)
Hdl 12 Channel RelaY (1.1)
hdl mix module MHRCU.433 (1.2)
node red flow 1 for controlling
node red flow 2 for status of channels at start up

Here in setup 2 I get all the statuses including MHRCU.433
In setup 1 I get only the status of first network and not of second network.

So there is the problem when I add second status flow. Please need help…

Can you send screenshots of the config for your 2 gateways?

Also can you share the flow where you request the startup status?