NEWS
Zwei Werte aus Nachricht filtern
-
Hallo,
wie schaffe ich es 2 Werte aus einer Nachricht (z.B. msg.payload und msg.payload.irgendwas) zu filtern.
Also es soll nur der payload weitergegeben werden, wenn einer der beiden Werte sich geändert hat, beide Werte gleich dann nichts ausgeben?Wie macht man sowas?
Lg
-
@hpgo Mach beide payload ins ein Objekt und dann schau mal hier: https://forum.iobroker.net/post/1013387
-
Leider nicht zu Hause sonst würde ich das gleich mal ausprobieren.
Glaube aber das das so nicht funktioniert oder ich verstehe es nicht richtig was noch wahrscheinlicher istEs geht um eine Jalousie - ich bekomme vom Knoten die msg.payload (irgendwas zw. 0-100) und die msg.paylaoad.slat (irgendwas zw. 0-100)
Wenn der Knoten in eine andere Zeitschaltung spring und dabei die msg.payload und msg.paylaod.slat gleich wie zuvor ist soll der payload gefiltert werden - sonst durchlaufen.
Is schwer zu erklären, gebe mein bestes.
Lg -
@hpgo du musst halt beide Werte in ein Objekt überführen und daraus eine neue payload generieren, dann funktioniert auch der verlinkte Switch Node.
-
@mickym
Ich hab das jetzt mal für mich angepasst - glaub ich.
Jetzt wird die Nachricht nur durchgereicht wenn payload und slat anders sind als zuvor, jedoch müsste nicht wenn man zwei mal den gleichen payload sendet beim Ausgang/Debug "paylaod gleich (wahr)" die Nachricht erscheinen.[{"id":"8dd77fc4b1875654","type":"tab","label":"Test","disabled":false,"info":"","env":[]},{"id":"d4e5d14fe4b0f7a0","type":"blind-control","z":"8dd77fc4b1875654","name":"Fenster","topic":"","addIdType":"none","addId":"","positionConfig":"d836509a.67bc4","autoTrigger":true,"autoTriggerTime":"900000","startDelayTime":10000,"contextStore":"","results":[{"p":"","pt":"msgTopic","v":"","vt":"topic"},{"p":"","pt":"msgPayload","v":"","vt":"level"},{"p":"slat","pt":"msg","v":"","vt":"slat"},{"p":"blindCtrl","pt":"msg","v":"","vt":"ctrlObj"}],"blindIncrement":"25","blindOpenPos":"0","blindClosedPos":"100","blindPosReverse":false,"blindPosDefault":"open (max)","blindPosDefaultType":"levelFixed","slatPosDefault":"","slatPosDefaultType":"none","overwriteExpire":"10800000","rules":[],"sunControlMode":"16","sunFloorLengthType":"num","sunFloorLength":"50","sunMinDelta":"","blindPosMin":"closed (min)","blindPosMinType":"levelFixed","blindPosMax":"open (max)","blindPosMaxType":"levelFixed","blindOpenPosOffset":"","blindClosedPosOffset":"","sunSlat":"25","sunSlatType":"num","smoothTime":"3600000","sunTopic":"","windowTopType":"num","windowTop":"225","windowBottomType":"num","windowBottom":"0","windowAzimuthStartType":"numAzimuth","windowAzimuthStart":"135","windowAzimuthEndType":"numAzimuth","windowAzimuthEnd":"260","oversteers":[],"oversteerTopic":"","x":680,"y":440,"wires":[["8bf6496d13006282"],[]]},{"id":"8a7e64e1c145bd1e","type":"change","z":"8dd77fc4b1875654","name":"p100 / s 25","rules":[{"t":"set","p":"payload","pt":"msg","to":"100","tot":"num"},{"t":"set","p":"slat","pt":"msg","to":"25","tot":"num"},{"t":"set","p":"topic","pt":"msg","to":"levelOverwrite","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":390,"y":420,"wires":[["d4e5d14fe4b0f7a0"]]},{"id":"5f444d118f024a4d","type":"inject","z":"8dd77fc4b1875654","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":420,"wires":[["8a7e64e1c145bd1e"]]},{"id":"967c64ba19640b7a","type":"debug","z":"8dd77fc4b1875654","name":"payload unterschiedlich (falsch)","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1170,"y":420,"wires":[]},{"id":"8bf6496d13006282","type":"switch","z":"8dd77fc4b1875654","name":"Filter","property":"(payload = payload) and (payload.slat = payload.slat)","propertyType":"jsonata","rules":[{"t":"false"},{"t":"true"}],"checkall":"true","repair":false,"outputs":2,"x":870,"y":440,"wires":[["967c64ba19640b7a"],["cc572d62703e09a2"]]},{"id":"cc572d62703e09a2","type":"debug","z":"8dd77fc4b1875654","name":"payload gleich (wahr)","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1140,"y":460,"wires":[]},{"id":"744f4975df73b6c1","type":"change","z":"8dd77fc4b1875654","name":"p 100 / s 35","rules":[{"t":"set","p":"payload","pt":"msg","to":"100","tot":"num"},{"t":"set","p":"slat","pt":"msg","to":"35","tot":"num"},{"t":"set","p":"topic","pt":"msg","to":"levelOverwrite","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":390,"y":460,"wires":[["d4e5d14fe4b0f7a0"]]},{"id":"a4408b97151be03d","type":"inject","z":"8dd77fc4b1875654","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":460,"wires":[["744f4975df73b6c1"]]},{"id":"e57b23aeec869881","type":"time-inject","z":"8dd77fc4b1875654","name":"Auto reset all overwrite","nameInt":"⏲ 07:45↷ = undefined=undefined","positionConfig":"d836509a.67bc4","props":[{"p":"","pt":"msgTopic","v":"resetOverwrite","vt":"str","o":"","oT":"none","oM":"60000","f":0,"fS":0,"fT":"Millisekunden UNIX-Zeit","fI":"0","next":false,"days":"*","months":"*","onlyOddDays":false,"onlyEvenDays":false,"onlyOddWeeks":false,"onlyEvenWeeks":false}],"injectTypeSelect":"time","intervalCount":"2","intervalCountType":"num","intervalCountMultiplier":60000,"time":"07:45","timeType":"entered","offset":"16","offsetType":"num","offsetMultiplier":60000,"timeEnd":"sunriseStart","timeEndType":"pdsTime","timeEndOffset":"-5","timeEndOffsetType":"num","timeEndOffsetMultiplier":60000,"timeDays":"*","timeOnlyOddDays":false,"timeOnlyEvenDays":false,"timeOnlyOddWeeks":false,"timeOnlyEvenWeeks":false,"timeMonths":"*","timedatestart":"","timedateend":"","property":"","propertyType":"none","propertyCompare":"true","propertyThreshold":"","propertyThresholdType":"num","timeAlt":"","timeAltType":"entered","timeAltDays":"*","timeAltOnlyOddDays":false,"timeAltOnlyEvenDays":false,"timeAltOnlyOddWeeks":false,"timeAltOnlyEvenWeeks":false,"timeAltMonths":"*","timeAltOffset":0,"timeAltOffsetType":"none","timeAltOffsetMultiplier":60000,"once":false,"onceDelay":"","recalcTime":2,"x":220,"y":140,"wires":[["d4e5d14fe4b0f7a0"]]},{"id":"d836509a.67bc4","type":"position-config","name":"Johnsdorf/Brunn","isValide":"true","angleType":"deg","timeZoneOffset":"99","timeZoneDST":"0","stateTimeFormat":"3","stateDateFormat":"3","contextStore":""}]
Ich hab nur leider die node-red-contrib-sun-position Rolladen Knoten mit drin den du nicht haben wirst. Weiß nicht wie ich das sonst zeigen sollte.
Lg -
geht viel einfacher: - Eine Filternode tuts auch.
-
@mickym Spitze, danke!
Zu meinem Verständnis, du setzt die msg.payload auf msg.overallStatus und mit json wird payload und slat verglichen und zu "normalen" Filter Node weitergeleitet.
Lg
-
@hpgo sagte in Zwei Werte aus Nachricht filtern:
@mickym Spitze, danke!
Zu meinem Verständnis, du setzt die msg.payload auf msg.overallStatus und mit json wird payload und slat verglichen und zu "normalen" Filter Node weitergeleitet.
Lg
overallStatus ist EIN Objekt das 2 Eigenschaftten hat, die payload und slat
{ overallStatus: { "payload":payload, "slat": slat } }
Und es wird auf Werteänderung dieses Objektes in der filter Node geprüft. Die Prüfung des Objektes beinhaltet natürlich auch jede Eigenschaft des Objektes (payload und slat).