Hi,
I have a flow with two inputs. One counter and one sensor input. I want to subtract the sensor value from the counter and write the result into the counter. I don’t get the function to work. Can someone help me?
Thanks.
[{"id":"b0f1329d53fd4f4c","type":"api-current-state","z":"292bbd722256ac0f","name":"Fläche bis Mopp waschen","server":"d6e1a14d.333e1","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"counter.staubsauger_restflache_bis_mopp_waschen","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":520,"y":100,"wires":[["87f1300c41162117"]]},{"id":"c142f475c883f893","type":"api-current-state","z":"292bbd722256ac0f","name":"Fläche der letzten Reinigung","server":"d6e1a14d.333e1","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.roborock_s6_maxv_letzte_reinigung_flache","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":520,"y":160,"wires":[["87f1300c41162117"]]},{"id":"87f1300c41162117","type":"function","z":"292bbd722256ac0f","name":"function 2","func":"","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":780,"y":120,"wires":[["fd1c1b3b4fde4276"]]},{"id":"2d5b99a243d8c4d7","type":"inject","z":"292bbd722256ac0f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":260,"y":120,"wires":[["b0f1329d53fd4f4c","c142f475c883f893"]]},{"id":"fd1c1b3b4fde4276","type":"api-call-service","z":"292bbd722256ac0f","name":"Berechneter Wert in Zähler eintragen","server":"d6e1a14d.333e1","version":5,"debugenabled":false,"domain":"counter","service":"set_value","areaId":[],"deviceId":[],"entityId":[],"data":"{\"value\":\"msg.payload\"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1050,"y":120,"wires":[[]]},{"id":"d6e1a14d.333e1","type":"server","name":"Home Assistant","addon":true}]