I thought it was time I shared something with this GREAT community. What drove me to install Home Assistant in the first place. It’s my first share so go easy please.
I wanted to be reminded to lock my car if either my wife or I forgot (usually distracted by screaming children). However, as I started to think more an more about this problem, I decided I also wanted to add to the notification, the following:
- still image from camera for where the car is parked on the road
- notification action so I can lock the car directly from the iOS notification
- trigger this automation only when I open my front door (Wyze door sensor) with the car unlocked
I hope that my yaml below, might be able to help people to tackle similar problems. Shout if any questions and I’ll try to help where I can.
Config (required) for bmw_connected integration (Read only access, if set to true, will not allow the update_state service to run below to get the updated info)
bmw_connected_drive:
name:
username: !secret bmw_connected_drive_username
password: !secret bmw_connected_drive_password
region: rest_of_world
Config: Optional - so that ‘Camera with Actions’ Category will be synced in the iOS companion App Configuration, it needs to be in your config.
Actionable notifications code for iOS notifications from DrZZZs Youtube Channel
ios:
push:
categories:
- name: Camera with Actions
identifier: 'camera'
actions:
- identifier: 'LOCK'
title: 'Lock Car'
destructive: 'true'"
Automation: Update status (required in order to get more up to date information about the car)
alias: BMW Update State
description: BMW Update State every 10 seconds
trigger:
- platform: time_pattern
seconds: '10'
condition: []
action:
- data: {}
service: bmw_connected_drive.update_state
mode: single"
Note: this can easily be setup in the automations UI, if that is preffered to automations yaml. you can choose how frequently you want the data from the car to be updated. I am using unlock entity so I need a fairly up to date state of this entity.
Bear in mind that although I have not had BMW limit my accounts API calls YET!!!, this could happen if you set the seconds too low. "
Automation: Lock the car automation for iOS notification action - OPTIONAL if you want to have an action available in the iOS notifcation which will unlock the car. actions need to also be added in the config. check the companion app documentation for more detail.
alias: Lock the Car
trigger:
- event_data:
actionName: LOCK
event_type: ios.notification_action_fired
platform: event
action:
- entity_id: lock.i3_94_rex_lock
service: lock.lock
mode: single
Automation - car unlocked reminder: Optional elements are the device tracker condition and the wyze door sensor (this could be replaced with presence detection such as my device is home OR something else like car is unlocked for a set amount of time)
alias: Front Door Open Car Unlocked Notification
description: Notify me when my front door is opened and my car is unlocked
trigger:
- entity_id: binary_sensor.wyzesense_77939752
from: 'on'
platform: state
to: 'off'
condition:
- condition: state
entity_id: lock.i3_94_rex_lock
state: unlocked
- condition: and
conditions:
- condition: state
entity_id: device_tracker.i3_94_rex
state: home
action:
- data:
data:
attachment:
content-type: jpeg
entity_id: camera.nest_cam
push:
category: camera
message: Remember to lock the car
title: Car Unlocked
service: notify.mobile_app_iphone_sk
mode: single
Other bmw automations
I also have a bunch of other notification automations if anyone is interested let me know.
Examples:
- Send ios notification with charge level when charging starts
- Send ios notification when charge level reaches 80%
- Send ios notification of what the charge level is when charging is complete
- If it’s after 8pm and the car is at home and unlocked, remind me to unlock it