Tracking your Chevrolet using Home Assistant, MyChevrolet and Node-RED

I came up with a sort of a kludge to create a binary sensor in Home Assistant signifying if our truck is home or not.  In the MyChevrolet app, you can configure Share Location.  If you set up a Home location, you can have the app send you a notification whenever the vehicle arrives or departs.

The Node-RED flow:

Node-RED Flow JSON
[    {        "id": "41fb480a.963748",        "type": "server-state-changed",        "z": "5e8bada2.1ce6c4",        "name": "Vehicle location",        "server": "cacdccbf.2b6e9",        "version": 1,        "exposeToHomeAssistant": false,        "haConfig": [            {                "property": "name",                "value": ""            },            {                "property": "icon",                "value": ""            }        ],
        "entityidfilter": "sensor.your_phone_last_notification",
        "entityidfiltertype": "exact",
        "outputinitially": true,
        "state_type": "str",
        "haltifstate": "",
        "halt_if_type": "str",
        "halt_if_compare": "includes",
        "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": 244,
        "y": 226,
        "wires": [            [                "b248a35a.be4a1"            ]
        ],
        "info": "Change the Entity ID to your phone app entity for last_notification"
    },
    {
        "id": "b248a35a.be4a1",
        "type": "switch",
        "z": "5e8bada2.1ce6c4",
        "name": "MyChevrolet Location",
        "property": "payload",
        "propertyType": "msg",
        "rules": [            {                "t": "cont",                "v": "2021 Vehicle arrived at Home",                "vt": "str"            },            {                "t": "cont",                "v": "2011 Vehicle departed from Home",                "vt": "str"            }        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 551,
        "y": 225,
        "wires": [            [                "42eaff63.6ff08"            ],
            [                "58298151.bf20d"            ]
        ],
        "info": "Change \"2021 Vehicle\" to the name of your vehicle as reported by the MyChevrolet app"
    },
    {
        "id": "42eaff63.6ff08",
        "type": "change",
        "z": "5e8bada2.1ce6c4",
        "name": "Vehicle arrived home",
        "rules": [            {                "t": "set",                "p": "payload",                "pt": "msg",                "to": "true",                "tot": "bool"            }        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 857,
        "y": 200,
        "wires": [            [                "dcc47b41.2b3ac8"            ]
        ]
    },
    {
        "id": "58298151.bf20d",
        "type": "change",
        "z": "5e8bada2.1ce6c4",
        "name": "Vehicle departed home",
        "rules": [            {                "t": "set",                "p": "payload",                "pt": "msg",                "to": "false",                "tot": "bool"            }        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 850,
        "y": 269,
        "wires": [            [                "dcc47b41.2b3ac8"            ]
        ]
    },
    {
        "id": "590d1a88.43c664",
        "type": "inject",
        "z": "5e8bada2.1ce6c4",
        "name": "Inject Arrived",
        "props": [            {                "p": "payload"            },            {                "p": "topic",                "vt": "str"            }        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "Vehicle arrived at Home",
        "payloadType": "str",
        "x": 252,
        "y": 300,
        "wires": [            [                "b248a35a.be4a1"            ]
        ]
    },
    {
        "id": "254aa049.b72b9",
        "type": "inject",
        "z": "5e8bada2.1ce6c4",
        "name": "Inject Departed",
        "props": [            {                "p": "payload"            },            {                "p": "topic",                "vt": "str"            }        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "Vehicle departed from Home",
        "payloadType": "str",
        "x": 240,
        "y": 360,
        "wires": [            [                "b248a35a.be4a1"            ]
        ]
    },
    {
        "id": "dcc47b41.2b3ac8",
        "type": "ha-entity",
        "z": "5e8bada2.1ce6c4",
        "name": "Vehicle at Home",
        "server": "cacdccbf.2b6e9",
        "version": 1,
        "debugenabled": true,
        "outputs": 1,
        "entityType": "binary_sensor",
        "config": [            {                "property": "name",                "value": "vehicle_at_home"            },            {                "property": "device_class",                "value": "presence"            },            {                "property": "icon",                "value": "mdi:truck"            },            {                "property": "unit_of_measurement",                "value": ""            }        ],
        "state": "payload",
        "stateType": "msg",
        "attributes": [],
        "resend": true,
        "outputLocation": "",
        "outputLocationType": "none",
        "inputOverride": "allow",
        "outputOnStateChange": false,
        "outputPayload": "$entity().state ? \"on\": \"off\"",
        "outputPayloadType": "jsonata",
        "x": 1090,
        "y": 229,
        "wires": [            []
        ],
        "info": "Change the \"HA Config\" name to what you want the binary_sensor entity id to be."
    },
    {
        "id": "cacdccbf.2b6e9",
        "type": "server",
        "name": "Home Assistant",
        "legacy": false,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": true
    }
]

First up, configure your Home Assistant app to expose the Last Notification sensor.  Under App Configuration, select Manage Sensors and make sure Last Notification is enabled

Then, in the MyChevrolet App, click on Vehicle Locate: Share Location. Then click on Set Up Alerts and set up a location for Home, making sure to enable Notify Me

Finally, import the Node-Red flow.  Before deploying, edit  the vehicle name and especially the HA Config name in the entity.

After that, you should have a binary sensor in Home Assistant that updates whenever the MyChevrolet app sends a notification about arriving or departing home. There is usually a delay, and occasionally it does not update, but it’s kind of cool!

MyChevrolet app on the Google Play Store

 

Leave a Reply