I’ve been trying to accomplish this for the past few days and a lot of googling but can’t find a solution.
I have my ford vehicle integrated with HA. I’m trying to create a flow that does the following:
When Ignition is turned on, take the specified current entity states and hold onto the values (ODO, EV Battery Level and Fuel Level). Once the ignition is turned off, take the same readings, subtract them and send a push message to my phone with the values listed for that trip.
I have this working great with just one entity value, but I can’t figure it out with multiple. I tried adding multiple “current sate” nodes but it just pushes multiple payloads out.
I also tried using a change node with the variables set to the expression “$number($entities(“sensor.fordpass_ev_battery_level”).state)” but that node doesn’t like the $entitites function.
I want to modify this working code to allow for more then one entity:
[{"id":"8673e30f.fb9b4","type":"tab","label":"Ford","disabled":false,"info":""},{"id":"4b26a5671d9bbfa5","type":"server-state-changed","z":"8673e30f.fb9b4","name":"Ford Ignition","server":"df9a019b.0518b","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.fordpass_ignition_status","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"x":210,"y":180,"wires":[["8e637a32a2637047"]]},{"id":"8e637a32a2637047","type":"switch","z":"8673e30f.fb9b4","name":"State","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Run","vt":"str"},{"t":"eq","v":"Off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":380,"y":210,"wires":[["834e5742fe22dab2","eba2a8cce5ed34f8"],["834e5742fe22dab2"]]},{"id":"834e5742fe22dab2","type":"trigger","z":"8673e30f.fb9b4","d":true,"name":"15 Minute Timer","op1":"","op2":"Run","op1type":"nul","op2type":"str","duration":"1","extend":false,"overrideDelay":false,"units":"min","reset":"Off","bytopic":"all","topic":"topic","outputs":1,"x":560,"y":250,"wires":[["32f399696e69cabe"]]},{"id":"32f399696e69cabe","type":"api-call-service","z":"8673e30f.fb9b4","name":"Ford Refresh","server":"df9a019b.0518b","version":5,"debugenabled":false,"domain":"fordpass","service":"refresh_status","areaId":[],"deviceId":[],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":550,"y":290,"wires":[["834e5742fe22dab2"]]},{"id":"eba2a8cce5ed34f8","type":"api-current-state","z":"8673e30f.fb9b4","name":"ODO Reading","server":"df9a019b.0518b","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.fordpass_odometer","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"start_odo","propertyType":"msg","value":"","valueType":"entityState"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":570,"y":170,"wires":[["6f1d245538571712"]]},{"id":"6f1d245538571712","type":"ha-wait-until","z":"8673e30f.fb9b4","name":"Wait","server":"df9a019b.0518b","version":1,"outputs":1,"entityId":"sensor.fordpass_ignition_status","entityIdFilterType":"exact","property":"state","comparator":"is","value":"Off","valueType":"str","timeout":"","timeoutType":"num","timeoutUnits":"seconds","entityLocation":"data","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":750,"y":170,"wires":[["2fd0c8c47d655072"]]},{"id":"2fd0c8c47d655072","type":"api-current-state","z":"8673e30f.fb9b4","name":"ODO Reading","server":"df9a019b.0518b","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.fordpass_odometer","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"end_odo","propertyType":"msg","value":"$sum($number($entities(\"sensor.fordpass_odometer\").state) - $.start_odo)","valueType":"jsonata"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":920,"y":170,"wires":[["28e8cd08cd8aa253"]]},{"id":"ef18aadc28abb60f","type":"api-call-service","z":"8673e30f.fb9b4","name":"Notify Phone","server":"df9a019b.0518b","version":5,"debugenabled":false,"domain":"notify","service":"mobile_app_m_iphone","areaId":[],"deviceId":[],"entityId":[],"data":"{\"message\":\"Your trip was {{end_odo}} miles!\",\"title\":\"Your Trip Results\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1130,"y":220,"wires":[[]]},{"id":"28e8cd08cd8aa253","type":"switch","z":"8673e30f.fb9b4","name":"Result Validate","property":"end_odo","propertyType":"msg","rules":[{"t":"gt","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":1130,"y":170,"wires":[["ef18aadc28abb60f"]]},{"id":"6661b045f64bf0e0","type":"inject","z":"8673e30f.fb9b4","name":"Test (Ignition On)","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Run","payloadType":"str","x":200,"y":260,"wires":[["8e637a32a2637047"]]},{"id":"df9a019b.0518b","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]