lovelace.yaml
- title: Volvo Mobile
path: mobile-car
icon: mdi:car-connected
badges: []
cards:
- type: picture-elements
elements:
- type: state-icon
entity: lock.volvo_xc60_yv1uzh5v4p1357593_lock_status
style:
This file has been truncated. show original
node-red-flow.json
[{"id":"b6e164fe.1d31e8","type":"subflow","name":"Bogdan mobile notification","info":"","category":"","in":[{"x":100,"y":80,"wires":[{"id":"af896d84.97285"}]}],"out":[{"x":600,"y":80,"wires":[{"id":"fe75d18.e659d3","port":0}]}],"env":[{"name":"message","type":"str","value":""},{"name":"title","type":"str","value":""},{"name":"notificationUrl","type":"str","value":""},{"name":"notificationActions","type":"str","value":""}],"meta":{},"color":"#A5C13D","icon":"font-awesome/fa-mobile-phone"},{"id":"fe75d18.e659d3","type":"api-call-service","z":"b6e164fe.1d31e8","name":"Send notification","server":"8501408e.93b69","version":1,"debugenabled":true,"service_domain":"notify","service":"mobile_app_s22ultra","entityId":"","data":"msg.data","dataType":"jsonata","mergecontext":"","output_location":"payload","output_location_type":"none","mustacheAltTags":false,"x":430,"y":80,"wires":[[]]},{"id":"af896d84.97285","type":"function","z":"b6e164fe.1d31e8","name":"","func":"var message = env.get(\"message\") || msg.message || global.get('BogdanPhoneNotificationMessage');\nvar title = env.get(\"title\") || msg.title || global.get('BogdanPhoneNotificationTitle');\nvar notificationUrl = env.get(\"notificationUrl\") || msg.notificationUrl || global.get('BogdanPhoneNotificationUrl');\nvar actions = env.get(\"notificationActions\") || msg.notificationActions || global.get('BogdanPhoneNotificationActions');\n\nmsg.data = {\n message,\n title\n};\nif(notificationUrl){\n msg.data.data = {\n clickAction: notificationUrl\n };\n}\nnode.warn(actions);\nif (actions){\n msg.data.data = {\n actions: actions\n }\n}\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":240,"y":80,"wires":[["fe75d18.e659d3","67780e1d.47e76"]]},{"id":"67780e1d.47e76","type":"debug","z":"b6e164fe.1d31e8","name":"Notification data","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":450,"y":140,"wires":[]},{"id":"e62d7df1fc1e2ee0","type":"server-state-changed","z":"d2cb442102b53dce","name":"Front left door opened","server":"8501408e.93b69","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.volvo_xc60_yv1uzh5v4p1357593_door_front_left","entityidfiltertype":"exact","outputinitially":true,"state_type":"habool","haltifstate":"true","halt_if_type":"bool","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"x":120,"y":40,"wires":[["490f62a0dd2ce9b7"],[]]},{"id":"71b0d972cd5c3353","type":"server-state-changed","z":"d2cb442102b53dce","name":"Front right door opened","server":"8501408e.93b69","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.volvo_xc60_yv1uzh5v4p1357593_door_front_right","entityidfiltertype":"exact","outputinitially":true,"state_type":"habool","haltifstate":"true","halt_if_type":"bool","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"x":120,"y":100,"wires":[["490f62a0dd2ce9b7"],[]]},{"id":"6589f93e0826ae45","type":"server-state-changed","z":"d2cb442102b53dce","name":"Rear left door opened","server":"8501408e.93b69","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.volvo_xc60_yv1uzh5v4p1357593_door_rear_left","entityidfiltertype":"exact","outputinitially":true,"state_type":"habool","haltifstate":"true","halt_if_type":"bool","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"x":120,"y":160,"wires":[["490f62a0dd2ce9b7"],[]]},{"id":"1c44dcea8b685fee","type":"server-state-changed","z":"d2cb442102b53dce","name":"Rear right door opened","server":"8501408e.93b69","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.volvo_xc60_yv1uzh5v4p1357593_door_rear_right","entityidfiltertype":"exact","outputinitially":true,"state_type":"habool","haltifstate":"true","halt_if_type":"bool","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"x":120,"y":220,"wires":[["490f62a0dd2ce9b7"],[]]},{"id":"24a06175b03daee2","type":"server-state-changed","z":"d2cb442102b53dce","name":"Tailgate opened","server":"8501408e.93b69","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.volvo_xc60_yv1uzh5v4p1357593_tailgate","entityidfiltertype":"exact","outputinitially":true,"state_type":"habool","haltifstate":"true","halt_if_type":"bool","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"x":100,"y":280,"wires":[["490f62a0dd2ce9b7"],[]]},{"id":"bc6280919623783e","type":"server-state-changed","z":"d2cb442102b53dce","name":"Front left window opened","server":"8501408e.93b69","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.volvo_xc60_yv1uzh5v4p1357593_window_front_left","entityidfiltertype":"exact","outputinitially":true,"state_type":"habool","haltifstate":"true","halt_if_type":"bool","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"x":130,"y":340,"wires":[["490f62a0dd2ce9b7"],[]]},{"id":"83bac681c2358ecd","type":"server-state-changed","z":"d2cb442102b53dce","name":"Front right window opened","server":"8501408e.93b69","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.volvo_xc60_yv1uzh5v4p1357593_window_front_right","entityidfiltertype":"exact","outputinitially":true,"state_type":"habool","haltifstate":"true","halt_if_type":"bool","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"x":130,"y":400,"wires":[["490f62a0dd2ce9b7"],[]]},{"id":"b9890b1efab48689","type":"server-state-changed","z":"d2cb442102b53dce","name":"Rear left window opened","server":"8501408e.93b69","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.volvo_xc60_yv1uzh5v4p1357593_window_rear_left","entityidfiltertype":"exact","outputinitially":true,"state_type":"habool","haltifstate":"true","halt_if_type":"bool","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"x":130,"y":460,"wires":[["490f62a0dd2ce9b7"],[]]},{"id":"d45c3c30ef756b13","type":"server-state-changed","z":"d2cb442102b53dce","name":"Rear right window opened","server":"8501408e.93b69","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.volvo_xc60_yv1uzh5v4p1357593_window_rear_right","entityidfiltertype":"exact","outputinitially":true,"state_type":"habool","haltifstate":"true","halt_if_type":"bool","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"x":130,"y":520,"wires":[["490f62a0dd2ce9b7"],[]]},{"id":"490f62a0dd2ce9b7","type":"api-current-state","z":"d2cb442102b53dce","name":"Volvo alarm is on","server":"8501408e.93b69","version":1,"outputs":2,"halt_if":"true","halt_if_type":"bool","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.volvo_xc60_alarm","state_type":"habool","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":490,"y":260,"wires":[["baa1909d630bb402"],[]]},{"id":"77922bd19e8167fb","type":"subflow:b6e164fe.1d31e8","z":"d2cb442102b53dce","name":"Notify car breach","x":1390,"y":260,"wires":[[]]},{"id":"e811dfe4d2b352fe","type":"switch","z":"d2cb442102b53dce","name":"If should notify","property":"shouldNotify","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":1100,"y":260,"wires":[["77922bd19e8167fb"]]},{"id":"baa1909d630bb402","type":"function","z":"d2cb442102b53dce","name":"Set notification","func":"const globalHomeAssistant = global.get('homeassistant');\n\nvar carEntity = globalHomeAssistant.homeAssistant.states[msg.topic];\n\nmsg.message = carEntity.attributes.friendly_name + \" is opened\";\nmsg.title = \"Volvo alarm triggered\";\nmsg.shouldNotify = false;\nvar alarmBooleanEntity = globalHomeAssistant.homeAssistant.states[msg.topic];\nif(alarmBooleanEntity.state === \"on\" && carEntity.state == \"on\"){\n msg.shouldNotify = true;\n}\nmsg.notificationUrl = \"/lovelace-personal/mobile-car\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":800,"y":260,"wires":[["e811dfe4d2b352fe"]]},{"id":"8919b7521d257d7d","type":"server-state-changed","z":"d2cb442102b53dce","name":"Battery level changed","server":"8501408e.93b69","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.volvo_xc60_battery_charge_level","entityidfiltertype":"exact","outputinitially":true,"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":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":140,"y":1720,"wires":[["76395e229c98a020"]]},{"id":"f1852d997f11b1fd","type":"api-call-service","z":"d2cb442102b53dce","name":"Set km at last charge","server":"8501408e.93b69","version":1,"debugenabled":false,"service_domain":"var","service":"set","entityId":"var.volvo_odometer_at_last_charge","data":"{\"value\": msg.payload}","dataType":"jsonata","mergecontext":"","output_location":"payload","output_location_type":"none","mustacheAltTags":false,"x":960,"y":1680,"wires":[["e30c962b577b8d9a"]]},{"id":"76395e229c98a020","type":"switch","z":"d2cb442102b53dce","name":"Check battery level","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"100","vt":"num"},{"t":"lt","v":"5","vt":"num"},{"t":"lte","v":"60","vt":"num"}],"checkall":"true","repair":false,"outputs":3,"x":370,"y":1720,"wires":[["b4811fcd6141b4b2"],["8db4ed2d25cb7ced"],["607fd79eaafa3c62"]]},{"id":"8db4ed2d25cb7ced","type":"api-call-service","z":"d2cb442102b53dce","name":"Set full discharge time","server":"8501408e.93b69","version":1,"debugenabled":false,"service_domain":"var","service":"set","entityId":"var.volvo_last_battery_discharge","data":"{\"value\": msg.data.new_state.last_changed}","dataType":"jsonata","mergecontext":"","output_location":"payload","output_location_type":"none","mustacheAltTags":false,"x":700,"y":1740,"wires":[[]]},{"id":"c9c0026d793f3f84","type":"server-state-changed","z":"d2cb442102b53dce","name":"Tank fill","server":"8501408e.93b69","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.volvo_xc60_yv1uzh5v4p1357593_fuel_level","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"71","halt_if_type":"num","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":90,"y":1820,"wires":[[],[]]},{"id":"4d76230cd2394d9a","type":"function","z":"d2cb442102b53dce","name":"Set finished trip details","func":"const globalHomeAssistant = global.get('homeassistant');\n\nvar startTripKm = parseFloat(globalHomeAssistant.homeAssistant.states[\"var.volvo_start_trip_km\"].state);\nvar geocodedLocation = globalHomeAssistant.homeAssistant.states[\"sensor.volvo_geocoded_location\"].state;\nvar startTripBattery = parseFloat(globalHomeAssistant.homeAssistant.states[\"var.volvo_start_trip_battery\"].state);\nvar startTripFuel = parseFloat(globalHomeAssistant.homeAssistant.states[\"var.volvo_start_trip_fuel\"].state);\nvar totalBatteryConsumption = parseFloat(globalHomeAssistant.homeAssistant.states[\"var.volvo_total_battery_consumption\"].state);\n\nvar endTripKm = parseFloat(globalHomeAssistant.homeAssistant.states[\"sensor.volvo_xc60_yv1uzh5v4p1357593_odometer\"].state);\nvar endTripBattery = parseFloat(globalHomeAssistant.homeAssistant.states[\"sensor.volvo_xc60_battery_charge_level\"].state);\nvar endTripFuel = parseFloat(globalHomeAssistant.homeAssistant.states[\"sensor.volvo_xc60_yv1uzh5v4p1357593_fuel_level\"].state);\n\nvar km = endTripKm - startTripKm;\nvar battery = endTripBattery - startTripBattery;\nvar fuel = parseFloat((endTripFuel - startTripFuel).toFixed(2));\nfuel*=-1;\nbattery*=-1;\nif (fuel < 0 || km < 30){\n fuel = 0;\n}\nif(battery < 0){\n battery = 0;\n}\n\n// start\nmsg.startTripKm = startTripKm;\nmsg.startTripBattery = startTripBattery;\nmsg.startTripFuel = startTripFuel;\n\n// end\nmsg.endTripKm = endTripKm;\nmsg.endTripBattery = endTripBattery;\nmsg.endTripFuel = endTripFuel;\n\n// end - start\nmsg.km = km;\nmsg.battery = battery;\nmsg.fuel = fuel;\n\n\nmsg.currentFuelLevel = parseFloat(globalHomeAssistant.homeAssistant.states[\"sensor.volvo_xc60_yv1uzh5v4p1357593_fuel_level\"].state);\nmsg.fuelAtLastCharge = parseFloat(globalHomeAssistant.homeAssistant.states[\"var.volvo_fuel_at_last_charge\"].state);\nmsg.current_odometer_value = parseFloat(globalHomeAssistant.homeAssistant.states[\"sensor.volvo_xc60_yv1uzh5v4p1357593_odometer\"].state);\nmsg.odometer_at_last_charge = parseFloat(globalHomeAssistant.homeAssistant.states[\"var.volvo_odometer_at_last_charge\"].state);\nmsg.last_battery_charge_level = parseFloat(globalHomeAssistant.homeAssistant.states[\"var.volvo_last_battery_charge_level\"].state);\nmsg.last_refuel_price_per_liter = parseFloat(globalHomeAssistant.homeAssistant.states[\"var.volvo_last_refuel_price_per_liter\"].state);\n\nmsg.fuel_consumed = msg.currentFuelLevel - msg.fuelAtLastCharge;\nmsg.totalDistance = msg.current_odometer_value - msg.odometer_at_last_charge;\nmsg.fuelCost = msg.fuel_consumed * msg.last_refuel_price_per_liter;\nif (msg.fuel_consumed < 0) {\n msg.fuel_consumed = 0;\n msg.fuelCost = 0;\n}\nvar kwhUsed = (msg.last_battery_charge_level - endTripBattery) * 18.8 / 100;\nmsg.energyCost = kwhUsed * 1;\nmsg.totalCost = msg.fuelCost + msg.energyCost;\nif (msg.totalDistance > 0) {\n msg.pricePerKmSinceLastCharge = msg.totalCost / msg.totalDistance;\n}\nelse {\n msg.pricePerKmSinceLastCharge = 0;\n}\n\nvar last_refuel_price_per_liter = parseFloat(globalHomeAssistant.homeAssistant.states[\"var.volvo_last_refuel_price_per_liter\"].state);\nvar fuelCost = fuel * last_refuel_price_per_liter;\nvar kwhUsedInLastTrip = battery * 18.8 / 100;\nvar energyCost = kwhUsedInLastTrip * 1;\nmsg.costForLastTrip = fuelCost + energyCost;\nmsg.totalBatteryConsumption = totalBatteryConsumption + kwhUsedInLastTrip;\n\n\nmsg.title = msg.km + \"km trip finished!\"\nmsg.message = \"Battery: \" + msg.battery + \"%, fuel: \" + msg.fuel + \"L, total cost: \" + msg.costForLastTrip + \"RON\" + \", energy cost: \" + energyCost + \" RON\";\nmsg.notificationUrl = \"/lovelace-personal/mobile-car\";\nnode.warn(msg);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":960,"wires":[["ffc2550bfc51c841","4353a38174d59f72","1b2b17e2f93a225c","0ba5ee048e516461","f3b95fb3c5b430ef","b56ef04d9754e252","9f243285571b1c1e","738d3252d73f3a91","d99412927d8fe96c","31afff54eb06b307"]]},{"id":"ffc2550bfc51c841","type":"api-call-service","z":"d2cb442102b53dce","name":"Set km after trip","server":"8501408e.93b69","version":1,"debugenabled":false,"service_domain":"var","service":"set","entityId":"var.volvo_last_trip_km","data":"{\"value\": msg.km}","dataType":"jsonata","mergecontext":"","output_location":"payload","output_location_type":"none","mustacheAltTags":false,"x":600,"y":740,"wires":[[]]},{"id":"1b2b17e2f93a225c","type":"api-call-service","z":"d2cb442102b53dce","name":"Set battery after trip","server":"8501408e.93b69","version":1,"debugenabled":false,"service_domain":"var","service":"set","entityId":"var.volvo_last_trip_battery","data":"{\"value\": msg.battery}","dataType":"jsonata","mergecontext":"","output_location":"payload","output_location_type":"none","mustacheAltTags":false,"x":610,"y":860,"wires":[[]]},{"id":"4353a38174d59f72","type":"api-call-service","z":"d2cb442102b53dce","name":"Set fuel after trip","server":"8501408e.93b69","version":1,"debugenabled":false,"service_domain":"var","service":"set","entityId":"var.volvo_last_trip_fuel","data":"{\"value\": msg.fuel}","dataType":"jsonata","mergecontext":"","output_location":"payload","output_location_type":"none","mustacheAltTags":false,"x":600,"y":800,"wires":[[]]},{"id":"30172fe3c0b432b8","type":"api-call-service","z":"d2cb442102b53dce","name":"Set odometer start value","server":"8501408e.93b69","version":1,"debugenabled":false,"service_domain":"var","service":"set","entityId":"var.volvo_start_trip_km","data":"{\"value\": msg.currentOdometer}","dataType":"jsonata","mergecontext":"","output_location":"payload","output_location_type":"none","mustacheAltTags":false,"x":630,"y":1320,"wires":[[]]},{"id":"5c48918270516617","type":"api-call-service","z":"d2cb442102b53dce","name":"Set battery start value","server":"8501408e.93b69","version":1,"debugenabled":false,"service_domain":"var","service":"set","entityId":"var.volvo_start_trip_battery","data":"{\"value\": msg.currentBattery}","dataType":"jsonata","mergecontext":"","output_location":"payload","output_location_type":"none","mustacheAltTags":false,"x":620,"y":1400,"wires":[[]]},{"id":"8b282b77933472aa","type":"api-call-service","z":"d2cb442102b53dce","name":"Set start trip fuel value","server":"8501408e.93b69","version":1,"debugenabled":false,"service_domain":"var","service":"set","entityId":"var.volvo_start_trip_fuel","data":"{\"value\": msg.currentFuel}","dataType":"jsonata","mergecontext":"","output_location":"payload","output_location_type":"none","mustacheAltTags":false,"x":620,"y":1480,"wires":[[]]},{"id":"db3d9398d2acc50f","type":"link in","z":"d2cb442102b53dce","name":"Finish trip","links":["fd2cff91c184540b"],"x":80,"y":960,"wires":[["4d76230cd2394d9a"]],"l":true},{"id":"fd2cff91c184540b","type":"link out","z":"d2cb442102b53dce","name":"Finshed a trip","mode":"link","links":["db3d9398d2acc50f"],"x":2300,"y":1340,"wires":[],"icon":"font-awesome/fa-flag-checkered","l":true},{"id":"72ea9ce4726072c1","type":"link in","z":"d2cb442102b53dce","name":"Start new trip","links":["cd324c555a042a7b","edec506eeda08966"],"x":90,"y":1460,"wires":[["3b34c8222bff5a60"]],"l":true},{"id":"cd324c555a042a7b","type":"link out","z":"d2cb442102b53dce","name":"Starting a new trip","mode":"link","links":["72ea9ce4726072c1"],"x":1750,"y":1040,"wires":[],"icon":"font-awesome/fa-car","l":true},{"id":"b56ef04d9754e252","type":"api-call-service","z":"d2cb442102b53dce","name":"Set odometer stop value","server":"8501408e.93b69","version":1,"debugenabled":false,"service_domain":"var","service":"set","entityId":"var.volvo_stop_trip_km","data":"{\"value\": msg.endTripKm}","dataType":"jsonata","mergecontext":"","output_location":"payload","output_location_type":"none","mustacheAltTags":false,"x":630,"y":1260,"wires":[[]]},{"id":"f3b95fb3c5b430ef","type":"api-call-service","z":"d2cb442102b53dce","name":"Set battery stop value","server":"8501408e.93b69","version":1,"debugenabled":false,"service_domain":"var","service":"set","entityId":"var.volvo_stop_trip_battery","data":"{\"value\": msg.endTripBattery}","dataType":"jsonata","mergecontext":"","output_location":"payload","output_location_type":"none","mustacheAltTags":false,"x":620,"y":1140,"wires":[[]]},{"id":"9f243285571b1c1e","type":"api-call-service","z":"d2cb442102b53dce","name":"Set fuel stop value","server":"8501408e.93b69","version":1,"debugenabled":false,"service_domain":"var","service":"set","entityId":"var.volvo_stop_trip_fuel","data":"{\"value\": msg.endTripFuel}","dataType":"jsonata","mergecontext":"","output_location":"payload","output_location_type":"none","mustacheAltTags":false,"x":610,"y":1200,"wires":[[]]},{"id":"607fd79eaafa3c62","type":"api-call-service","z":"d2cb442102b53dce","name":"Turn on charger","server":"8501408e.93b69","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.car_charger","data":"","dataType":"jsonata","mergecontext":"","output_location":"payload","output_location_type":"none","mustacheAltTags":false,"x":700,"y":1800,"wires":[[]]},{"id":"e30c962b577b8d9a","type":"api-call-service","z":"d2cb442102b53dce","name":"Set full charge time","server":"8501408e.93b69","version":1,"debugenabled":false,"service_domain":"var","service":"set","entityId":"var.volvo_last_battery_charge","data":"{\"value\": msg.data.new_state.last_changed}","dataType":"jsonata","mergecontext":"","output_location":"payload","output_location_type":"none","mustacheAltTags":false,"x":1230,"y":1680,"wires":[[]]},{"id":"b4811fcd6141b4b2","type":"api-current-state","z":"d2cb442102b53dce","name":"Get odometer reading","server":"8501408e.93b69","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"sensor.volvo_xc60_yv1uzh5v4p1357593_odometer","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":700,"y":1680,"wires":[["f1852d997f11b1fd","5c8da9c383d02532"]]},{"id":"5c8da9c383d02532","type":"api-current-state","z":"d2cb442102b53dce","name":"Get fuel level","server":"8501408e.93b69","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"sensor.volvo_xc60_yv1uzh5v4p1357593_fuel_level","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":950,"y":1740,"wires":[["3eeb0369c8b9110e"]]},{"id":"3eeb0369c8b9110e","type":"api-call-service","z":"d2cb442102b53dce","name":"Set fuel value at last charge","server":"8501408e.93b69","version":1,"debugenabled":true,"service_domain":"var","service":"set","entityId":"var.volvo_fuel_at_last_charge","data":"{\"value\": msg.payload}","dataType":"jsonata","mergecontext":"","output_location":"payload","output_location_type":"none","mustacheAltTags":false,"x":1220,"y":1740,"wires":[[]]},{"id":"276dda294ec97e8d","type":"server-state-changed","z":"d2cb442102b53dce","name":"Fuel level changed","server":"8501408e.93b69","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.volvo_xc60_yv1uzh5v4p1357593_fuel_level","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":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":110,"y":1940,"wires":[["b23c137e463aa768"]]},{"id":"f77b21a3f3bf317c","type":"switch","z":"d2cb442102b53dce","name":"fuelConsumptionUntilNow is valid","property":"fuelConsumptionUntilNow","propertyType":"msg","rules":[{"t":"gt","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":920,"y":2000,"wires":[["e9e2bc0f6d9c498f"]]},{"id":"ef4e6c643dcb38b1","type":"function","z":"d2cb442102b53dce","name":"Calculate fuel consumption","func":"const globalHomeAssistant = global.get('homeassistant');\n\nvar currentFuelLevel = parseFloat(msg.payload);\n\nvar totalRefuelLiters = parseFloat(globalHomeAssistant.homeAssistant.states[\"var.volvo_fuel_total_refill\"].state);\n\nvar fuelConsumptionUntilNow = totalRefuelLiters - currentFuelLevel;\nmsg.currentTankFuelConsumptionUntilNow = 71 - currentFuelLevel;\nmsg.currentFuelLevel = msg.payload;\nmsg.totalRefill = totalRefuelLiters;\nmsg.fuelConsumptionUntilNow = fuelConsumptionUntilNow;\nvar totalConsumptionVar = parseFloat(globalHomeAssistant.homeAssistant.states[\"var.volvo_fuel_total_consumption\"].state);\n\nnode.warn(msg);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":620,"y":2000,"wires":[["f77b21a3f3bf317c"]]},{"id":"e9e2bc0f6d9c498f","type":"api-call-service","z":"d2cb442102b53dce","name":"Set fuel consumption until now","server":"8501408e.93b69","version":1,"debugenabled":true,"service_domain":"var","service":"set","entityId":"var.volvo_fuel_total_consumption","data":"{\"value\": msg.fuelConsumptionUntilNow}","dataType":"jsonata","mergecontext":"","output_location":"payload","output_location_type":"none","mustacheAltTags":false,"x":1230,"y":2000,"wires":[[]]},{"id":"76a1bfd88d884659","type":"server-events","z":"d2cb442102b53dce","name":"Catch mobile app notifications","server":"8501408e.93b69","event_type":"mobile_app_notification_action","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"waitForRunning":true,"x":180,"y":2160,"wires":[["d5876679e7ca9648"]]},{"id":"d5876679e7ca9648","type":"switch","z":"d2cb442102b53dce","name":"Check action","property":"payload.event.action","propertyType":"msg","rules":[{"t":"eq","v":"LOCK_CAR","vt":"str"},{"t":"eq","v":"CAR_REFUEL","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":490,"y":2160,"wires":[["aeebbb8b98aad769"],[]]},{"id":"aeebbb8b98aad769","type":"api-call-service","z":"d2cb442102b53dce","name":"Lock car","server":"8501408e.93b69","version":1,"debugenabled":false,"service_domain":"lock","service":"lock","entityId":"lock.volvo_xc60_yv1uzh5v4p1357593_lock_status","data":"","dataType":"jsonata","mergecontext":"","output_location":"payload","output_location_type":"none","mustacheAltTags":false,"x":760,"y":2140,"wires":[[]]},{"id":"2eac1056dd56cccb","type":"api-current-state","z":"d2cb442102b53dce","name":"Get battery charge","server":"8501408e.93b69","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"sensor.volvo_xc60_battery_charge_level","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":650,"y":1580,"wires":[["faea6ae695a25bcd"]]},{"id":"faea6ae695a25bcd","type":"api-call-service","z":"d2cb442102b53dce","name":"Set battery last charge level","server":"8501408e.93b69","version":1,"debugenabled":false,"service_domain":"var","service":"set","entityId":"var.volvo_last_battery_charge_level","data":"{\"value\": msg.payload}","dataType":"jsonata","mergecontext":"","output_location":"payload","output_location_type":"none","mustacheAltTags":false,"x":900,"y":1580,"wires":[[]]},{"id":"80d38457cce64cb8","type":"function","z":"d2cb442102b53dce","name":"Set cost per km since last charge","func":"const globalHomeAssistant = global.get('homeassistant');\n\nmsg.currentFuelLevel = parseFloat(globalHomeAssistant.homeAssistant.states[\"sensor.volvo_xc60_yv1uzh5v4p1357593_fuel_level\"].state);\nmsg.fuelAtLastCharge = parseFloat(globalHomeAssistant.homeAssistant.states[\"var.volvo_fuel_at_last_charge\"].state);\nmsg.current_odometer_value = parseFloat(globalHomeAssistant.homeAssistant.states[\"sensor.volvo_xc60_yv1uzh5v4p1357593_odometer\"].state);\nmsg.odometer_at_last_charge = parseFloat(globalHomeAssistant.homeAssistant.states[\"var.volvo_odometer_at_last_charge\"].state);\nmsg.last_battery_charge_level = parseFloat(globalHomeAssistant.homeAssistant.states[\"var.volvo_last_battery_charge_level\"].state);\nmsg.last_refuel_price_per_liter = parseFloat(globalHomeAssistant.homeAssistant.states[\"var.volvo_last_refuel_price_per_liter\"].state);\nmsg.stop_trip_battery = parseFloat(globalHomeAssistant.homeAssistant.states[\"var.volvo_stop_trip_battery\"].state);\n\nmsg.fuel_consumed = msg.currentFuelLevel - msg.fuelAtLastCharge;\nmsg.totalDistance = msg.current_odometer_value - msg.odometer_at_last_charge;\nmsg.fuelCost = msg.fuel_consumed * msg.last_refuel_price_per_liter;\nif (msg.fuel_consumed < 0){\n msg.fuel_consumed = 0;\n msg.fuelCost = 0;\n}\nvar kwhUsed = (msg.last_battery_charge_level - msg.stop_trip_battery) *18.8/100;\nmsg.energyCost = kwhUsed * 1;\nmsg.totalCost = msg.fuelCost + msg.energyCost;\nif(msg.totalDistance > 0){\n msg.pricePerKmSinceLastCharge = msg.totalCost / msg.totalDistance;\n}\nelse{\n msg.pricePerKmSinceLastCharge = 0;\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":280,"y":1240,"wires":[[]]},{"id":"e671627bf67410db","type":"inject","z":"d2cb442102b53dce","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":1060,"wires":[["4d76230cd2394d9a","3b34c8222bff5a60"]]},{"id":"0ba5ee048e516461","type":"api-call-service","z":"d2cb442102b53dce","name":"Set price per km since last charge","server":"8501408e.93b69","version":1,"debugenabled":false,"service_domain":"var","service":"set","entityId":"var.volvo_price_per_km_since_last_charge","data":"{\"value\": msg.pricePerKmSinceLastCharge}","dataType":"jsonata","mergecontext":"","output_location":"payload","output_location_type":"none","mustacheAltTags":false,"x":660,"y":920,"wires":[[]]},{"id":"fd4d022348816c1e","type":"debug","z":"d2cb442102b53dce","name":"Start trip details","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":380,"y":1520,"wires":[]},{"id":"3b34c8222bff5a60","type":"function","z":"d2cb442102b53dce","name":"Set start trip details","func":"const globalHomeAssistant = global.get('homeassistant');\n\nvar currentOdometer = parseFloat(globalHomeAssistant.homeAssistant.states[\"sensor.volvo_xc60_yv1uzh5v4p1357593_odometer\"].state);\nvar currentBattery = parseFloat(globalHomeAssistant.homeAssistant.states[\"sensor.volvo_xc60_battery_charge_level\"].state);\nvar currentFuel = parseFloat(globalHomeAssistant.homeAssistant.states[\"sensor.volvo_xc60_yv1uzh5v4p1357593_fuel_level\"].state);\n\nmsg.currentOdometer = parseFloat((currentOdometer).toFixed(2));\nmsg.currentBattery = parseFloat((currentBattery).toFixed(2));\nmsg.currentFuel = parseFloat((currentFuel).toFixed(2));\nnode.warn(msg);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":1340,"wires":[["30172fe3c0b432b8","5c48918270516617","8b282b77933472aa","68886a896955941e"]]},{"id":"7753424e3c04efb3","type":"server-state-changed","z":"d2cb442102b53dce","name":"Car unlocked","server":"8501408e.93b69","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"lock.volvo_xc60_yv1uzh5v4p1357593_lock_status","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"unlocked","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":830,"y":780,"wires":[["353f42c37da0ef07"],[]]},{"id":"49c30dc3011f9783","type":"delay","z":"d2cb442102b53dce","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1240,"y":780,"wires":[["86c888abf13244b2"]]},{"id":"86c888abf13244b2","type":"subflow:b6e164fe.1d31e8","z":"d2cb442102b53dce","name":"Notify car is unlocked","env":[{"name":"message","value":"Would you like to lock it?","type":"str"},{"name":"title","value":"The car is unlocked for more than 2 minutes","type":"str"},{"name":"notificationActions","value":"[{\"action\":\"LOCK_CAR\",\"title\":\"Lock Car\",\"icon\":\"sfsymbols:lock.fill\"}]","type":"json"}],"x":1460,"y":780,"wires":[[]]},{"id":"353f42c37da0ef07","type":"api-current-state","z":"d2cb442102b53dce","name":"If engine is off","server":"8501408e.93b69","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.volvo_yv1uzh5v4p1357593_engine_state","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1040,"y":780,"wires":[["49c30dc3011f9783"],[]]},{"id":"044a2c4c44a9def3","type":"change","z":"d2cb442102b53dce","name":"Reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1050,"y":900,"wires":[["49c30dc3011f9783"]]},{"id":"b23c137e463aa768","type":"switch","z":"d2cb442102b53dce","name":"Tank was filled","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"71","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":340,"y":1940,"wires":[["ecf8b2938d6e8596"],["ef4e6c643dcb38b1"]]},{"id":"ecf8b2938d6e8596","type":"subflow:b6e164fe.1d31e8","z":"d2cb442102b53dce","name":"Notify tank was filled","env":[{"name":"message","value":"Did you just filled your tank?","type":"str"},{"name":"title","value":"Fuel level is 71L","type":"str"},{"name":"notificationActions","value":"[{\"action\":\"CAR_REFUEL\",\"title\":\"Yes\",\"icon\":\"sfsymbols:lock.fill\"}]","type":"json"}],"x":600,"y":1880,"wires":[[]]},{"id":"ec8c547bed529876","type":"delay","z":"d2cb442102b53dce","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1600,"y":1220,"wires":[["9c4559f741c0aafa"]]},{"id":"49d114d959106372","type":"change","z":"d2cb442102b53dce","name":"Reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1350,"y":1240,"wires":[["ec8c547bed529876"]]},{"id":"112fa6eab75a309d","type":"server-state-changed","z":"d2cb442102b53dce","name":"Engine","server":"8501408e.93b69","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.volvo_yv1uzh5v4p1357593_engine_state","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"x":1050,"y":1080,"wires":[["044a2c4c44a9def3","71984400929a0273","49d114d959106372","38cab4acd1d248f6"],["2238a9f6b0c5d829","189597cbebc54591"]]},{"id":"71984400929a0273","type":"subflow:b6e164fe.1d31e8","z":"d2cb442102b53dce","name":"Engine on notification","env":[{"name":"message","value":"Volvo engine turned on","type":"str"},{"name":"title","value":"Volvo engine","type":"str"},{"name":"notificationActions","value":"/lovelace-personal/mobile-car","type":"str"}],"x":1260,"y":960,"wires":[[]]},{"id":"2238a9f6b0c5d829","type":"subflow:b6e164fe.1d31e8","z":"d2cb442102b53dce","name":"Engine off notification","env":[{"name":"message","value":"Volvo engine turned off","type":"str"},{"name":"title","value":"Volvo engine","type":"str"},{"name":"notificationActions","value":"/lovelace-personal/mobile-car","type":"str"}],"x":1260,"y":1360,"wires":[[]]},{"id":"738d3252d73f3a91","type":"subflow:b6e164fe.1d31e8","z":"d2cb442102b53dce","name":"Stop trip notification","x":610,"y":1040,"wires":[[]]},{"id":"9c4559f741c0aafa","type":"function","z":"d2cb442102b53dce","name":"Calculate odometer difference","func":"const globalHomeAssistant = global.get('homeassistant');\n\nvar startTripKm = parseFloat(globalHomeAssistant.homeAssistant.states[\"var.volvo_start_trip_km\"].state);\nvar odometerState = parseFloat(globalHomeAssistant.homeAssistant.states[\"sensor.volvo_xc60_yv1uzh5v4p1357593_odometer\"].state);\n\nmsg.distance = odometerState - startTripKm;\n\nnode.warn(msg);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1650,"y":1360,"wires":[["b858bd360fa43a77","9c9512f4e3c0f4e6"]]},{"id":"b858bd360fa43a77","type":"switch","z":"d2cb442102b53dce","name":"Distance is greater than 2 km","property":"distance","propertyType":"msg","rules":[{"t":"gte","v":"3","vt":"str"},{"t":"lte","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":2020,"y":1340,"wires":[["fd2cff91c184540b"],[]]},{"id":"9c9512f4e3c0f4e6","type":"debug","z":"d2cb442102b53dce","name":"distance","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1960,"y":1400,"wires":[]},{"id":"38cab4acd1d248f6","type":"api-current-state","z":"d2cb442102b53dce","name":"Is there a trip in progress?","server":"8501408e.93b69","version":1,"outputs":2,"halt_if":"true","halt_if_type":"bool","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.volvo_trip_in_progress","state_type":"habool","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1450,"y":1060,"wires":[[],["cd324c555a042a7b"]]},{"id":"189597cbebc54591","type":"api-current-state","z":"d2cb442102b53dce","name":"Is there a trip in progress?","server":"8501408e.93b69","version":1,"outputs":2,"halt_if":"true","halt_if_type":"bool","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.volvo_trip_in_progress","state_type":"habool","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1450,"y":1120,"wires":[["ec8c547bed529876"],[]]},{"id":"d99412927d8fe96c","type":"api-call-service","z":"d2cb442102b53dce","name":"Stop current trip","server":"8501408e.93b69","version":1,"debugenabled":false,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.volvo_trip_in_progress","data":"","dataType":"jsonata","mergecontext":"","output_location":"payload","output_location_type":"none","mustacheAltTags":false,"x":600,"y":980,"wires":[[]]},{"id":"0ec7c6032112abf3","type":"function","z":"d2cb442102b53dce","name":"Set finished trip details","func":"const globalHomeAssistant = global.get('homeassistant');\n\nmsg.geocodedLocation = globalHomeAssistant.homeAssistant.states[\"sensor.volvo_geocoded_location\"].state;\nif (msg.geocodedLocation.indexOf('IaČi') != -1){\n msg.isInIasi = true;\n}\nelse{\n msg.isInIasi = false;\n}\n\nnode.warn(msg);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1100,"y":1480,"wires":[["1b01efe8b9d0fa74"]]},{"id":"021674c88dd28e3a","type":"inject","z":"d2cb442102b53dce","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":900,"y":1460,"wires":[["0ec7c6032112abf3"]]},{"id":"1b01efe8b9d0fa74","type":"debug","z":"d2cb442102b53dce","name":"det","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1330,"y":1480,"wires":[]},{"id":"68886a896955941e","type":"api-call-service","z":"d2cb442102b53dce","name":"Start current trip","server":"8501408e.93b69","version":1,"debugenabled":false,"service_domain":"input_boolean","service":"turn_on","entityId":"input_boolean.volvo_trip_in_progress","data":"","dataType":"jsonata","mergecontext":"","output_location":"payload","output_location_type":"none","mustacheAltTags":false,"x":360,"y":1440,"wires":[["fd4d022348816c1e"]]},{"id":"b7bc301534d2dc5b","type":"server-state-changed","z":"d2cb442102b53dce","name":"Charging status changed","server":"8501408e.93b69","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.volvo_charging_status","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"Unplugged","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":150,"y":1580,"wires":[["b6e546104681bbd1"],[]]},{"id":"b6e546104681bbd1","type":"switch","z":"d2cb442102b53dce","name":"Check charging status","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Charging","vt":"str"},{"t":"eq","v":"Unplugged","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":400,"y":1580,"wires":[["2eac1056dd56cccb","189597cbebc54591"],[],[]]},{"id":"31afff54eb06b307","type":"api-call-service","z":"d2cb442102b53dce","name":"Set battery total consumption","server":"8501408e.93b69","version":1,"debugenabled":false,"service_domain":"var","service":"set","entityId":"var.volvo_total_battery_consumption","data":"{\"value\": msg.totalBatteryConsumption}","dataType":"jsonata","mergecontext":"","output_location":"payload","output_location_type":"none","mustacheAltTags":false,"x":640,"y":1100,"wires":[[]]},{"id":"8501408e.93b69","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
template-sensors.yaml
- sensor:
- name: "Volvo Last Refuel Level"
unit_of_measurement: 'liters'
state_class: measurement
state: "{{ states('var.volvo_last_refuel_level') }}"
- name: "Volvo Last Refuel Odometer"
state_class: total_increasing
unit_of_measurement: 'km'
state: "{{ states('var.volvo_odometer_at_last_refuel') }}"
- name: "Volvo Last Refuel Price Per Liter"
This file has been truncated. show original