[{"id":"8b061b60.4dc888","type":"tab","label":"汽车控制与记录","disabled":false,"info":"# 连接\n * 汽车在线时连接\n * 当汽车在线时手机位置出现变化\n \n \n\n# 断开\n * 汽车在线18分钟后一直是P档,且不在充电\n * 汽车离线"},{"id":"1e68a659.4bcfca","type":"server-state-changed","z":"8b061b60.4dc888","name":"汽车已连接","server":"4379efdc.d0568","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.pi_pi_gou_online_sensor","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":"","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":100,"y":100,"wires":[["d80c5b5e.35d848"],["a4ee7e38.50e07"]]},{"id":"cdc0d2d5.718af","type":"api-call-service","z":"8b061b60.4dc888","name":"打开更新开关","server":"4379efdc.d0568","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.pi_pi_gou_update_switch","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":540,"y":40,"wires":[["cc4bb488.73957"]]},{"id":"934819ae.2f7608","type":"api-call-service","z":"8b061b60.4dc888","name":"关闭更新开关","server":"4379efdc.d0568","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.pi_pi_gou_update_switch","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":500,"y":220,"wires":[[]]},{"id":"d80c5b5e.35d848","type":"link out","z":"8b061b60.4dc888","name":"","links":["b14943ee.a327e"],"x":215,"y":80,"wires":[]},{"id":"a4ee7e38.50e07","type":"link out","z":"8b061b60.4dc888","name":"","links":["5e92a01b.4f465","ffb6dd16.0cfc"],"x":215,"y":120,"wires":[]},{"id":"b14943ee.a327e","type":"link in","z":"8b061b60.4dc888","name":"","links":["d80c5b5e.35d848","6ddec3a8.5e919c"],"x":415,"y":40,"wires":[["cdc0d2d5.718af"]]},{"id":"5e92a01b.4f465","type":"link in","z":"8b061b60.4dc888","name":"","links":["a4ee7e38.50e07","a3c5486c.c6d6f8"],"x":375,"y":220,"wires":[["934819ae.2f7608"]]},{"id":"6675f036.e8f1f","type":"server-state-changed","z":"8b061b60.4dc888","name":"手机位置变化","server":"4379efdc.d0568","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor._iphone_geocoded_location","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":"","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":110,"y":320,"wires":[["29247f4.99d668"]]},{"id":"29247f4.99d668","type":"api-current-state","z":"8b061b60.4dc888","name":"汽车连接状态","server":"4379efdc.d0568","version":1,"outputs":2,"halt_if":"true","halt_if_type":"bool","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.pi_pi_gou_online_sensor","state_type":"habool","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":460,"y":320,"wires":[["6ddec3a8.5e919c"],[]]},{"id":"6ddec3a8.5e919c","type":"link out","z":"8b061b60.4dc888","name":"","links":["b14943ee.a327e"],"x":595,"y":320,"wires":[]},{"id":"ce8743ef.5f133","type":"server-state-changed","z":"8b061b60.4dc888","name":"车辆驻车","server":"4379efdc.d0568","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.pi_pi_gou_parking_brake_sensor","entityidfiltertype":"exact","outputinitially":false,"state_type":"habool","haltifstate":"true","halt_if_type":"bool","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":360,"y":80,"wires":[["cc4bb488.73957"],["3e1d87ee.e51cf8"]]},{"id":"85594c44.18f09","type":"api-current-state","z":"8b061b60.4dc888","name":"驻车","server":"4379efdc.d0568","version":1,"outputs":2,"halt_if":"true","halt_if_type":"bool","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.pi_pi_gou_parking_brake_sensor","state_type":"habool","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":850,"y":100,"wires":[["87a3dc26.68a5b"],[]]},{"id":"a3c5486c.c6d6f8","type":"link out","z":"8b061b60.4dc888","name":"","links":["5e92a01b.4f465","ffb6dd16.0cfc"],"x":1255,"y":100,"wires":[]},{"id":"8959a4b4.005ba8","type":"api-current-state","z":"8b061b60.4dc888","name":"记录里程表","server":"4379efdc.d0568","version":1,"outputs":1,"halt_if":"","halt_if_type":"num","halt_if_compare":"is_not","override_topic":true,"entity_id":"sensor.pi_pi_gou_mileage_sensor","state_type":"num","state_location":"lcblast","override_payload":"global","entity_location":"data","override_data":"msg","blockInputOverrides":true,"x":290,"y":500,"wires":[["ba3d36a5.f34678"]]},{"id":"8f1895e.582ac68","type":"api-render-template","z":"8b061b60.4dc888","name":"","server":"4379efdc.d0568","template":"{{state_attr('binary_sensor.pi_pi_gou_charger_sensor', 'charging_state')}}","resultsLocation":"payload","resultsLocationType":"msg","templateLocation":"template","templateLocationType":"msg","x":330,"y":800,"wires":[[]]},{"id":"b0d54c79.7c43d","type":"function","z":"8b061b60.4dc888","name":"计算已增加里程","func":"//var count = context.get('count')||0;\n//如果count不存在就初始化为0,已存在则获取count的值\n//count += 1;\n//context.set('count',count);\n//执行完+1操作以后保存count的值\n//msg.payload = count;\n//return msg;\n\n\n\nvar lcbnow = flow.get('lcbnow',lcbnow);\nvar lcblast = global.get('lcblast',lcblast);\nvar lcb = lcbnow - lcblast;\nmsg.payload = lcb;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":640,"y":580,"wires":[["6b0ff4b.fdf8b0c"]]},{"id":"5dbe8ad0.a60854","type":"api-current-state","z":"8b061b60.4dc888","name":"当前里程表","server":"4379efdc.d0568","version":1,"outputs":1,"halt_if":"","halt_if_type":"num","halt_if_compare":"is_not","override_topic":true,"entity_id":"sensor.pi_pi_gou_mileage_sensor","state_type":"num","state_location":"lcbnow","override_payload":"flow","entity_location":"data","override_data":"msg","blockInputOverrides":true,"x":450,"y":580,"wires":[["b0d54c79.7c43d"]]},{"id":"4665965b.c85fa8","type":"server-state-changed","z":"8b061b60.4dc888","name":"剩余里程变化","server":"4379efdc.d0568","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.pi_pi_gou_range_sensor","entityidfiltertype":"exact","outputinitially":true,"state_type":"num","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":110,"y":640,"wires":[["a4f0eecd.52368"]]},{"id":"a4f0eecd.52368","type":"delay","z":"8b061b60.4dc888","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":280,"y":640,"wires":[["5dbe8ad0.a60854","a05f7d1b.340dc","3827fea2.c864f2"]]},{"id":"b58fe2a4.9fc32","type":"server-state-changed","z":"8b061b60.4dc888","name":"拔下充电枪","server":"4379efdc.d0568","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.pi_pi_gou_charger_sensor","entityidfiltertype":"exact","outputinitially":false,"state_type":"habool","haltifstate":"false","halt_if_type":"bool","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":100,"y":500,"wires":[["8959a4b4.005ba8"],[]]},{"id":"ba3d36a5.f34678","type":"api-current-state","z":"8b061b60.4dc888","name":"记录剩余里程","server":"4379efdc.d0568","version":1,"outputs":1,"halt_if":"","halt_if_type":"num","halt_if_compare":"is_not","override_topic":true,"entity_id":"sensor.pi_pi_gou_range_sensor","state_type":"num","state_location":"sylclast","override_payload":"global","entity_location":"data","override_data":"msg","blockInputOverrides":true,"x":480,"y":500,"wires":[[]]},{"id":"a05f7d1b.340dc","type":"api-current-state","z":"8b061b60.4dc888","name":"当前剩余里程","server":"4379efdc.d0568","version":1,"outputs":1,"halt_if":"","halt_if_type":"num","halt_if_compare":"is_not","override_topic":true,"entity_id":"sensor.pi_pi_gou_range_sensor","state_type":"num","state_location":"sylcnow","override_payload":"flow","entity_location":"data","override_data":"msg","blockInputOverrides":true,"x":460,"y":700,"wires":[["e4cbee9e.a9cc2"]]},{"id":"e4cbee9e.a9cc2","type":"function","z":"8b061b60.4dc888","name":"计算已消耗里程","func":"//var count = context.get('count')||0;\n//如果count不存在就初始化为0,已存在则获取count的值\n//count += 1;\n//context.set('count',count);\n//执行完+1操作以后保存count的值\n//msg.payload = count;\n//return msg;\n\n\n\nvar sylcnow = flow.get('sylcnow',sylcnow);\nvar sylclast = global.get('sylclast',sylclast);\nvar sylc = sylclast - sylcnow;\nmsg.payload = sylc;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":640,"y":700,"wires":[["97fddefa.f74a"]]},{"id":"6b0ff4b.fdf8b0c","type":"change","z":"8b061b60.4dc888","name":"","rules":[{"t":"set","p":"sjlc","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":580,"wires":[["c13d159a.2741c8"]]},{"id":"97fddefa.f74a","type":"change","z":"8b061b60.4dc888","name":"","rules":[{"t":"set","p":"xhlc","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":700,"wires":[["6b969eed.67933"]]},{"id":"310925f7.17d16a","type":"function","z":"8b061b60.4dc888","name":"计算能耗效率","func":"//var count = context.get('count')||0;\n//如果count不存在就初始化为0,已存在则获取count的值\n//count += 1;\n//context.set('count',count);\n//执行完+1操作以后保存count的值\n//msg.payload = count;\n//return msg;\n\n\n\n\n\nvar sjlc = flow.get('sjlc',sjlc);\nvar xhlc = flow.get('xhlc',xhlc);\nvar nhb = sjlc / xhlc;\nmsg.payload = nhb;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":640,"y":640,"wires":[["4167892c.b5c648"]]},{"id":"3827fea2.c864f2","type":"delay","z":"8b061b60.4dc888","name":"","pauseType":"delay","timeout":"10","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":440,"y":640,"wires":[["310925f7.17d16a"]]},{"id":"acb2c3c3.f27b6","type":"comment","z":"8b061b60.4dc888","name":"控制汽车状态在合适的时间更新","info":"","x":170,"y":40,"wires":[]},{"id":"64803ff7.e1951","type":"comment","z":"8b061b60.4dc888","name":"获取能耗效率信息","info":"","x":130,"y":460,"wires":[]},{"id":"87a3dc26.68a5b","type":"api-current-state","z":"8b061b60.4dc888","name":"充电","server":"4379efdc.d0568","version":1,"outputs":2,"halt_if":"true","halt_if_type":"bool","halt_if_compare":"is","override_topic":false,"entity_id":"switch.pi_pi_gou_charger_switch","state_type":"habool","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":990,"y":100,"wires":[[],["5fd009c4.0ad8c"]]},{"id":"b1d5931c.c0b5b","type":"ha-entity","z":"8b061b60.4dc888","name":"消耗里程","server":"4379efdc.d0568","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"充电后消耗里程"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:gauge"},{"property":"unit_of_measurement","value":"km"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":1120,"y":700,"wires":[[]]},{"id":"c13d159a.2741c8","type":"range","z":"8b061b60.4dc888","minin":"0","maxin":"1000","minout":"0","maxout":"1000","action":"scale","round":true,"property":"payload","name":"转换整数","x":980,"y":580,"wires":[["ea5af436.4fc0f8"]]},{"id":"6b969eed.67933","type":"range","z":"8b061b60.4dc888","minin":"0","maxin":"1000","minout":"0","maxout":"1000","action":"scale","round":true,"property":"payload","name":"转换整数","x":980,"y":700,"wires":[["b1d5931c.c0b5b"]]},{"id":"4167892c.b5c648","type":"range","z":"8b061b60.4dc888","minin":"0","maxin":"2","minout":"0","maxout":"200","action":"scale","round":true,"property":"payload","name":"转换整数","x":800,"y":640,"wires":[["18fb553d.ec0b5b"]]},{"id":"41978c22.aad804","type":"ha-entity","z":"8b061b60.4dc888","name":"能耗效率","server":"4379efdc.d0568","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"能耗效率"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:chart-areaspline"},{"property":"unit_of_measurement","value":"%"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":1120,"y":640,"wires":[[]]},{"id":"18fb553d.ec0b5b","type":"switch","z":"8b061b60.4dc888","name":"大于0","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":930,"y":640,"wires":[["41978c22.aad804"]]},{"id":"ea5af436.4fc0f8","type":"ha-entity","z":"8b061b60.4dc888","name":"行驶里程","server":"4379efdc.d0568","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"充电后行驶里程"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:gauge"},{"property":"unit_of_measurement","value":"km"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":1120,"y":580,"wires":[[]]},{"id":"3e1d87ee.e51cf8","type":"change","z":"8b061b60.4dc888","name":"reset","rules":[{"t":"set","p":"payload","pt":"msg","to":"stop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":100,"wires":[["cc4bb488.73957"]]},{"id":"5fd009c4.0ad8c","type":"api-current-state","z":"8b061b60.4dc888","name":"空调开着","server":"4379efdc.d0568","version":1,"outputs":2,"halt_if":"heat_cool","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"climate.pi_pi_gou_hvac_climate_system","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1140,"y":100,"wires":[[],["a3c5486c.c6d6f8"]]},{"id":"f701d167.7cb858","type":"server-state-changed","z":"8b061b60.4dc888","name":"空调开启","server":"4379efdc.d0568","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"climate.pi_pi_gou_hvac_climate_system","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"heat_cool","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":560,"y":160,"wires":[[],["cc4bb488.73957"]]},{"id":"20d3623f.646c7e","type":"comment","z":"8b061b60.4dc888","name":"开始更新后主动休眠","info":"","x":890,"y":40,"wires":[]},{"id":"cc4bb488.73957","type":"stoptimer","z":"8b061b60.4dc888","duration":"5","units":"Minute","payloadtype":"num","payloadval":"0","name":"5m","x":710,"y":100,"wires":[["85594c44.18f09"],[]]},{"id":"4379efdc.d0568","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]