Announcement

Collapse
No announcement yet.

Circular Behavior with HS Device

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Circular Behavior with HS Device

    I'm working on a flow that monitors and controls settings on a network device (digital audio mixer). The mixer must be the "gold" setting since it can be controlled by more than just NR/HS. HS devices need to sync to the mixer. I have a flow that polls a mixer setting and updates the HS device value. The HS device can also control the setting on the mixer by triggering a flow that sends a message to the mixer to update the setting.

    Here's where I'm having trouble. The initial poll updates the HS device but if the HS device is not the same value as the mixer that also triggers the flow to send an update back to the mixer. The mixer then responds which again causes the HS device to be updated. Since the two are now in sync the HS device doesn't get a value change update. The flows are part of a much larger project so I'll work on creating a simpler flow to post here.
    "if I have seen further [than others], it is by standing on the shoulders of giants." --Sir Isaac Newton (1675)

    #2
    Here is an image of the flow and the json export.
    Click image for larger version

Name:	Screen Shot 2022-11-27 at 2.59.49 PM.png
Views:	130
Size:	136.2 KB
ID:	1577586

    PHP Code:
    [
        {
            
    "id""26740965e0f4c4de",
            
    "type""inject",
            
    "z""5268f875de9e4f03",
            
    "name""",
            
    "props": [
                {
                    
    "p""topic",
                    
    "vt""str"
                
    },
                {
                    
    "p""payload"
                
    }
            ],
            
    "repeat""",
            
    "crontab""",
            
    "once"true,
            
    "onceDelay""2",
            
    "topic""/lr/mix/on",
            
    "payload""",
            
    "payloadType""str",
            
    "x"250,
            
    "y"280,
            
    "wires": [
                [
                    
    "f4ba21245ed76022"
                
    ]
            ]
        },
        {
            
    "id""f4ba21245ed76022",
            
    "type""osc",
            
    "z""5268f875de9e4f03",
            
    "name""OSC Encoder",
            
    "path""",
            
    "metadata"false,
            
    "x"560,
            
    "y"280,
            
    "wires": [
                [
                    
    "11cd4eeb9b9ddaf5"
                
    ]
            ]
        },
        {
            
    "id""11cd4eeb9b9ddaf5",
            
    "type""udp out",
            
    "z""5268f875de9e4f03",
            
    "name""Send OSC to Mixer",
            
    "addr""172.29.1.24",
            
    "iface""",
            
    "port""10024",
            
    "ipv""udp4",
            
    "outport""11220",
            
    "base64"false,
            
    "multicast""false",
            
    "x"830,
            
    "y"280,
            
    "wires": []
        },
        {
            
    "id""5278f063ce5850c0",
            
    "type""inject",
            
    "z""5268f875de9e4f03",
            
    "name""Request Updates",
            
    "props": [
                {
                    
    "p""payload"
                
    },
                {
                    
    "p""topic",
                    
    "vt""str"
                
    }
            ],
            
    "repeat""9",
            
    "crontab""",
            
    "once"true,
            
    "onceDelay""1",
            
    "topic""/xremote",
            
    "payload""",
            
    "payloadType""date",
            
    "x"230,
            
    "y"220,
            
    "wires": [
                [
                    
    "f4ba21245ed76022"
                
    ]
            ],
            
    "info""This note sends an /xremote message every 9 seconds that tells the mixer to send updates back to Node-RED.  These are updates for when changes are made from outside of Node-RED. "
        
    },
        {
            
    "id""30cfde01fba2e36b",
            
    "type""udp in",
            
    "z""5268f875de9e4f03",
            
    "name""Receive OSC from Mixer",
            
    "iface""",
            
    "port""11220",
            
    "ipv""udp4",
            
    "multicast""false",
            
    "group""",
            
    "datatype""buffer",
            
    "x"210,
            
    "y"460,
            
    "wires": [
                [
                    
    "18242b639a7e05b5"
                
    ]
            ]
        },
        {
            
    "id""18242b639a7e05b5",
            
    "type""osc",
            
    "z""5268f875de9e4f03",
            
    "name""OSC Decoder",
            
    "path""",
            
    "metadata"false,
            
    "x"420,
            
    "y"460,
            
    "wires": [
                [
                    
    "89a2e61647f2b31c",
                    
    "fde6fe15b2cd815a"
                
    ]
            ]
        },
        {
            
    "id""89a2e61647f2b31c",
            
    "type""debug",
            
    "z""5268f875de9e4f03",
            
    "name""Received OSC",
            
    "active"false,
            
    "tosidebar"true,
            
    "console"false,
            
    "tostatus"false,
            
    "complete""true",
            
    "targetType""full",
            
    "statusVal""",
            
    "statusType""auto",
            
    "x"660,
            
    "y"460,
            
    "wires": []
        },
        {
            
    "id""d2a4a85c6699927a",
            
    "type""inject",
            
    "z""5268f875de9e4f03",
            
    "name""",
            
    "props": [
                {
                    
    "p""topic",
                    
    "vt""str"
                
    },
                {
                    
    "p""payload"
                
    }
            ],
            
    "repeat""",
            
    "crontab""",
            
    "once"false,
            
    "onceDelay"0.1,
            
    "topic""/lr/mix/on",
            
    "payload""1",
            
    "payloadType""num",
            
    "x"250,
            
    "y"320,
            
    "wires": [
                [
                    
    "f4ba21245ed76022"
                
    ]
            ]
        },
        {
            
    "id""0fb4128fc8882f7e",
            
    "type""inject",
            
    "z""5268f875de9e4f03",
            
    "name""",
            
    "props": [
                {
                    
    "p""topic",
                    
    "vt""str"
                
    },
                {
                    
    "p""payload"
                
    }
            ],
            
    "repeat""",
            
    "crontab""",
            
    "once"false,
            
    "onceDelay"0.1,
            
    "topic""/lr/mix/on",
            
    "payload""0",
            
    "payloadType""num",
            
    "x"250,
            
    "y"360,
            
    "wires": [
                [
                    
    "f4ba21245ed76022"
                
    ]
            ]
        },
        {
            
    "id""fde6fe15b2cd815a",
            
    "type""function",
            
    "z""5268f875de9e4f03",
            
    "name""Filter",
            
    "func""if (msg.topic.match(/\\/lr\\/mix\\/on/)) { //LR Mute\n    //\n} else {\n    return; // Ignore Everything Else for Now\n}\nreturn msg;",
            
    "outputs"1,
            
    "noerr"0,
            
    "initialize""",
            
    "finalize""",
            
    "libs": [],
            
    "x"530,
            
    "y"520,
            
    "wires": [
                [
                    
    "eddcf883cf104b01",
                    
    "86ec48132bbec0a4"
                
    ]
            ]
        },
        {
            
    "id""eddcf883cf104b01",
            
    "type""debug",
            
    "z""5268f875de9e4f03",
            
    "name""LR Mute/Unmute",
            
    "active"true,
            
    "tosidebar"true,
            
    "console"false,
            
    "tostatus"false,
            
    "complete""true",
            
    "targetType""full",
            
    "statusVal""",
            
    "statusType""auto",
            
    "x"770,
            
    "y"520,
            
    "wires": []
        },
        {
            
    "id""24f6248fc85fd63d",
            
    "type""hs-device",
            
    "z""5268f875de9e4f03",
            
    "name""Main LR Mute",
            
    "device""81",
            
    "server""cca8073e1d5285f1",
            
    "feature""82",
            
    "reportonstartup"false,
            
    "x"420,
            
    "y"660,
            
    "wires": [
                [
                    
    "08481145cb8dc9ac",
                    
    "ca6311612aac4a76"
                
    ]
            ]
        },
        {
            
    "id""08481145cb8dc9ac",
            
    "type""debug",
            
    "z""5268f875de9e4f03",
            
    "name""LR Mute from HS",
            
    "active"true,
            
    "tosidebar"true,
            
    "console"false,
            
    "tostatus"false,
            
    "complete""true",
            
    "targetType""full",
            
    "statusVal""",
            
    "statusType""auto",
            
    "x"630,
            
    "y"600,
            
    "wires": []
        },
        {
            
    "id""ca6311612aac4a76",
            
    "type""switch",
            
    "z""5268f875de9e4f03",
            
    "name""",
            
    "property""payload.status",
            
    "propertyType""msg",
            
    "rules": [
                {
                    
    "t""eq",
                    
    "v""Muted",
                    
    "vt""str"
                
    },
                {
                    
    "t""eq",
                    
    "v""Unmuted",
                    
    "vt""str"
                
    }
            ],
            
    "checkall""true",
            
    "repair"false,
            
    "outputs"2,
            
    "x"610,
            
    "y"660,
            
    "wires": [
                [
                    
    "2b85fb244cdde2d2",
                    
    "4d9ae0b5d13e014e"
                
    ],
                [
                    
    "d907a8e005e01042",
                    
    "c88ea5bf9177554c"
                
    ]
            ]
        },
        {
            
    "id""d907a8e005e01042",
            
    "type""debug",
            
    "z""5268f875de9e4f03",
            
    "name""Unmute",
            
    "active"false,
            
    "tosidebar"true,
            
    "console"false,
            
    "tostatus"false,
            
    "complete""payload",
            
    "targetType""msg",
            
    "statusVal""",
            
    "statusType""auto",
            
    "x"820,
            
    "y"720,
            
    "wires": []
        },
        {
            
    "id""2b85fb244cdde2d2",
            
    "type""function",
            
    "z""5268f875de9e4f03",
            
    "name""LR Mute",
            
    "func""msg.topic = '/lr/mix/on';\nmsg.payload = 0;\nreturn msg;",
            
    "outputs"1,
            
    "noerr"0,
            
    "initialize""",
            
    "finalize""",
            
    "libs": [],
            
    "x"820,
            
    "y"680,
            
    "wires": [
                [
                    
    "d835a71d914fbebd"
                
    ]
            ]
        },
        {
            
    "id""c88ea5bf9177554c",
            
    "type""function",
            
    "z""5268f875de9e4f03",
            
    "name""LR Unmute",
            
    "func""msg.topic = '/lr/mix/on';\nmsg.payload = 1;\nreturn msg;",
            
    "outputs"1,
            
    "noerr"0,
            
    "initialize""",
            
    "finalize""",
            
    "libs": [],
            
    "x"810,
            
    "y"760,
            
    "wires": [
                [
                    
    "d835a71d914fbebd"
                
    ]
            ]
        },
        {
            
    "id""4d9ae0b5d13e014e",
            
    "type""debug",
            
    "z""5268f875de9e4f03",
            
    "name""Mute",
            
    "active"false,
            
    "tosidebar"true,
            
    "console"false,
            
    "tostatus"false,
            
    "complete""payload",
            
    "targetType""msg",
            
    "statusVal""",
            
    "statusType""auto",
            
    "x"830,
            
    "y"640,
            
    "wires": []
        },
        {
            
    "id""43a305581c8389b9",
            
    "type""debug",
            
    "z""5268f875de9e4f03",
            
    "name""Debug: Message to HS",
            
    "active"true,
            
    "tosidebar"true,
            
    "console"false,
            
    "tostatus"false,
            
    "complete""true",
            
    "targetType""full",
            
    "statusVal""",
            
    "statusType""auto",
            
    "x"410,
            
    "y"720,
            
    "wires": []
        },
        {
            
    "id""86ec48132bbec0a4",
            
    "type""change",
            
    "z""5268f875de9e4f03",
            
    "name""Prep HS Update",
            
    "rules": [
                {
                    
    "t""set",
                    
    "p""value",
                    
    "pt""flow",
                    
    "to""payload",
                    
    "tot""msg"
                
    },
                {
                    
    "t""delete",
                    
    "p""payload",
                    
    "pt""msg"
                
    },
                {
                    
    "t""set",
                    
    "p""payload.value",
                    
    "pt""msg",
                    
    "to""value",
                    
    "tot""flow"
                
    },
                {
                    
    "t""set",
                    
    "p""topic",
                    
    "pt""msg",
                    
    "to""update",
                    
    "tot""str"
                
    }
            ],
            
    "action""",
            
    "property""",
            
    "from""",
            
    "to""",
            
    "reg"false,
            
    "x"200,
            
    "y"660,
            
    "wires": [
                [
                    
    "24f6248fc85fd63d",
                    
    "43a305581c8389b9"
                
    ]
            ]
        },
        {
            
    "id""d835a71d914fbebd",
            
    "type""link out",
            
    "z""5268f875de9e4f03",
            
    "name""link out 1",
            
    "mode""link",
            
    "links": [
                
    "fb103cd7cdd97a07"
            
    ],
            
    "x"945,
            
    "y"720,
            
    "wires": []
        },
        {
            
    "id""fb103cd7cdd97a07",
            
    "type""link in",
            
    "z""5268f875de9e4f03",
            
    "name""link in 1",
            
    "links": [
                
    "d835a71d914fbebd"
            
    ],
            
    "x"465,
            
    "y"360,
            
    "wires": [
                [
                    
    "f4ba21245ed76022"
                
    ]
            ]
        },
        {
            
    "id""cca8073e1d5285f1",
            
    "type""hs-server",
            
    "name""HS4Pi",
            
    "host""172.29.1.17",
            
    "port""80"
        
    }
    ]
    ​ 
    "if I have seen further [than others], it is by standing on the shoulders of giants." --Sir Isaac Newton (1675)

    Comment


      #3
      Have you tried the Filter (formerly called RBE) node instead of your function? Placing that, followed by a Switch node filtering out anything with msg.topic = control will likely get you what you need. Testing the flow shown below results in no messages getting to the debug node when I use the Injecvt nodes, but if HomeSeer changes the device, a message goes to the debug node. I also included an Export of the rbe (now called a Filter node) and Switch nodes. Change the rbe to filter on msg.payload.value if you are sending the value to HomeSeer vs sending the status.

      Click image for larger version

Name:	image.png
Views:	64
Size:	15.2 KB
ID:	1577740

      Exported Nodes:
      Code:
      [{"id":"258a996a9edf02db","type":"switch","z":"a3655017.81a92","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"control","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1070,"y":1080,"wires":[[],["b4869e03d72d714d"]]},{"id":"f97573a227556c77","type":"rbe","z":"a3655017.81a92","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload.status","topi":"topic","x":930,"y":1080,"wires":[["258a996a9edf02db"]]}]
      Karl S
      HS4Pro on Windows 10
      1070 Devices
      56 Z-Wave Nodes
      104 Events
      HSTouch Clients: 3 Android, 1 iOS
      Google Home: 3 Mini units, 1 Pair Audios, 2 Displays

      Comment


        #4
        Thanks ksum for the guidance. Off to do some reading and experimentation.
        "if I have seen further [than others], it is by standing on the shoulders of giants." --Sir Isaac Newton (1675)

        Comment


          #5
          Thanks again ksum. The RBE (aka filter node) helped immensely but I still have some tweaking to do. Not having the root device name (i.e. the channel) for the features (i.e. mute, level, etc) in the message is forcing me to rely on the "ref" for each feature device. Not ideal, but it's working.
          "if I have seen further [than others], it is by standing on the shoulders of giants." --Sir Isaac Newton (1675)

          Comment

          Working...
          X