|
| 1 | +--- |
| 2 | +tags: |
| 3 | + - package |
| 4 | + - automated |
| 5 | +version: 2.0.3 |
| 6 | +--- |
| 7 | + |
| 8 | +# Package: Car |
| 9 | + |
| 10 | +**Version:** 2.0.3 |
| 11 | +**Description:** Unified logic for Mercedes GLC. Normalizes sensors (Windows/Doors), wrapper switches, and Status Notifications. |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | +## Configuration |
| 16 | +```yaml |
| 17 | +# ------------------------------------------------------------------------------ |
| 18 | +# Package: Car GLC |
| 19 | +# Version: 2.0.3 |
| 20 | +# Description: Unified logic for Mercedes GLC. Normalizes sensors (Windows/Doors), wrapper switches, and Status Notifications. |
| 21 | +# Dependencies: |
| 22 | +# - Integration: ReneNulschDE/mbapi2020 (HACS) |
| 23 | +# - Script: script.notify_smart_master |
| 24 | +# ------------------------------------------------------------------------------ |
| 25 | + |
| 26 | +# ============================================================================== |
| 27 | +# 1. TEMPLATE SENSORS & BINARY SENSORS |
| 28 | +# ============================================================================== |
| 29 | +template: |
| 30 | + - binary_sensor: |
| 31 | + # --- Windows (Normalized from Attribute) --- |
| 32 | + - name: "Car GLC Window Front Left" |
| 33 | + unique_id: car_glc_window_front_left |
| 34 | + device_class: window |
| 35 | + state: > |
| 36 | + {{ state_attr('binary_sensor.xpb_358_windows_closed', 'Windowstatusfrontleft') != '2' }} |
| 37 | +
|
| 38 | + - name: "Car GLC Window Front Right" |
| 39 | + unique_id: car_glc_window_front_right |
| 40 | + device_class: window |
| 41 | + state: > |
| 42 | + {{ state_attr('binary_sensor.xpb_358_windows_closed', 'Windowstatusfrontright') != '2' }} |
| 43 | +
|
| 44 | + - name: "Car GLC Window Rear Left" |
| 45 | + unique_id: car_glc_window_rear_left |
| 46 | + device_class: window |
| 47 | + state: > |
| 48 | + {{ state_attr('binary_sensor.xpb_358_windows_closed', 'Windowstatusrearleft') != '2' }} |
| 49 | +
|
| 50 | + - name: "Car GLC Window Rear Right" |
| 51 | + unique_id: car_glc_window_rear_right |
| 52 | + device_class: window |
| 53 | + state: > |
| 54 | + {{ state_attr('binary_sensor.xpb_358_windows_closed', 'Windowstatusrearright') != '2' }} |
| 55 | +
|
| 56 | + # --- Doors (Normalized from Attribute) --- |
| 57 | + - name: "Car GLC Door Front Left" |
| 58 | + unique_id: car_glc_door_front_left |
| 59 | + device_class: door |
| 60 | + state: > |
| 61 | + {{ state_attr('sensor.xpb_358_lock', 'Door front left') != 'closed' }} |
| 62 | +
|
| 63 | + - name: "Car GLC Door Front Right" |
| 64 | + unique_id: car_glc_door_front_right |
| 65 | + device_class: door |
| 66 | + state: > |
| 67 | + {{ state_attr('sensor.xpb_358_lock', 'Door front right') != 'closed' }} |
| 68 | +
|
| 69 | + - name: "Car GLC Door Rear Left" |
| 70 | + unique_id: car_glc_door_rear_left |
| 71 | + device_class: door |
| 72 | + state: > |
| 73 | + {{ state_attr('sensor.xpb_358_lock', 'Door rear left') != 'closed' }} |
| 74 | +
|
| 75 | + - name: "Car GLC Door Rear Right" |
| 76 | + unique_id: car_glc_door_rear_right |
| 77 | + device_class: door |
| 78 | + state: > |
| 79 | + {{ state_attr('sensor.xpb_358_lock', 'Door rear right') != 'closed' }} |
| 80 | +
|
| 81 | + - name: "Car GLC Deck Lid" |
| 82 | + unique_id: car_glc_deck_lid |
| 83 | + device_class: opening |
| 84 | + state: > |
| 85 | + {{ state_attr('sensor.xpb_358_lock', 'Deck lid') != 'closed' }} |
| 86 | +
|
| 87 | + # --- Locks (Normalized from Attribute) --- |
| 88 | + - name: "Car GLC Lock Front Left" |
| 89 | + unique_id: car_glc_lock_front_left |
| 90 | + device_class: lock |
| 91 | + state: > |
| 92 | + {{ state_attr('sensor.xpb_358_lock', 'Door lock front left') != 'locked' }} |
| 93 | +
|
| 94 | + - name: "Car GLC Lock Front Right" |
| 95 | + unique_id: car_glc_lock_front_right |
| 96 | + device_class: lock |
| 97 | + state: > |
| 98 | + {{ state_attr('sensor.xpb_358_lock', 'Door lock front right') != 'locked' }} |
| 99 | +
|
| 100 | + - name: "Car GLC Lock Rear Left" |
| 101 | + unique_id: car_glc_lock_rear_left |
| 102 | + device_class: lock |
| 103 | + state: > |
| 104 | + {{ state_attr('sensor.xpb_358_lock', 'Door lock rear left') != 'locked' }} |
| 105 | +
|
| 106 | + - name: "Car GLC Lock Rear Right" |
| 107 | + unique_id: car_glc_lock_rear_right |
| 108 | + device_class: lock |
| 109 | + state: > |
| 110 | + {{ state_attr('sensor.xpb_358_lock', 'Door lock rear right') != 'locked' }} |
| 111 | +
|
| 112 | + - name: "Car GLC Gas Lock" |
| 113 | + unique_id: car_glc_gas_lock |
| 114 | + device_class: lock |
| 115 | + state: > |
| 116 | + {{ state_attr('sensor.xpb_358_lock', 'Gas lock') != 'locked' }} |
| 117 | +
|
| 118 | + # --- Logic Sensors (Consolidated Status) --- |
| 119 | + - name: "Car Charge Plug" |
| 120 | + unique_id: car_charge_plug |
| 121 | + device_class: plug |
| 122 | + state: > |
| 123 | + {% set value = state_attr('sensor.xpb_358_range_electric', 'chargingstatus') | float(0) %} |
| 124 | + {{ value != 3 }} |
| 125 | + icon: > |
| 126 | + {% set value = state_attr('sensor.xpb_358_range_electric', 'chargingstatus') | float(0) %} |
| 127 | + {% if value == 3 %} |
| 128 | + mdi:power-plug-off |
| 129 | + {% else %} |
| 130 | + mdi:power-plug |
| 131 | + {% endif %} |
| 132 | +
|
| 133 | + - name: "Car Charging" |
| 134 | + unique_id: car_charging_active |
| 135 | + device_class: power |
| 136 | + state: > |
| 137 | + {% set value = states('sensor.xpb_358_charging_power') | float(0) %} |
| 138 | + {{ value != 0 }} |
| 139 | + icon: > |
| 140 | + {% if states('sensor.xpb_358_charging_power') | float(0) == 0 %} |
| 141 | + mdi:power-off |
| 142 | + {% else %} |
| 143 | + mdi:power-on |
| 144 | + {% endif %} |
| 145 | +
|
| 146 | + - name: "Car Engine" |
| 147 | + unique_id: car_engine_status |
| 148 | + device_class: running |
| 149 | + state: > |
| 150 | + {% set value = states('sensor.xpb_358_ignition_state') | float(0) %} |
| 151 | + {{ value >= 2 }} |
| 152 | + icon: > |
| 153 | + {% if states('sensor.xpb_358_ignition_state') | float(0) < 2 %} |
| 154 | + mdi:engine-off |
| 155 | + {% else %} |
| 156 | + mdi:engine |
| 157 | + {% endif %} |
| 158 | +
|
| 159 | + - name: "Car Doors" |
| 160 | + unique_id: car_doors_status |
| 161 | + device_class: door |
| 162 | + state: > |
| 163 | + {% set value = state_attr('sensor.xpb_358_lock', 'doorStatusOverall') %} |
| 164 | + {{ value == 0 }} |
| 165 | + icon: > |
| 166 | + {% if state_attr('sensor.xpb_358_lock', 'doorStatusOverall') == 0 %} |
| 167 | + mdi:car-door |
| 168 | + {% else %} |
| 169 | + mdi:car-door-lock |
| 170 | + {% endif %} |
| 171 | +
|
| 172 | + - sensor: |
| 173 | + - name: "Car Charge Ready" |
| 174 | + unique_id: car_charge_ready_time |
| 175 | + state: > |
| 176 | + {% set end = state_attr('sensor.xpb_358_range_electric', 'endofchargetime') %} |
| 177 | + {% if end %} |
| 178 | + {{ as_datetime(end).strftime('%H:%M') }} |
| 179 | + {% else %} |
| 180 | + unknown |
| 181 | + {% endif %} |
| 182 | +
|
| 183 | +# ============================================================================== |
| 184 | +# 2. SWITCHES (Wrappers for API Calls) |
| 185 | +# ============================================================================== |
| 186 | +switch: |
| 187 | + - name: "Car Pre-entry A/C" |
| 188 | + unique_id: car_pre_entry_ac |
| 189 | + icon: mdi:air-conditioner |
| 190 | + state: "{{ is_state_attr('sensor.xpb_358_range_electric', 'precondNow', 1) }}" |
| 191 | + turn_on: |
| 192 | + service: mbapi2020.preheat_start |
| 193 | + data: |
| 194 | + type: "0" |
| 195 | + vin: !secret [REDACTED] |
| 196 | + turn_off: |
| 197 | + service: mbapi2020.preheat_stop |
| 198 | + data: |
| 199 | + vin: !secret [REDACTED] |
| 200 | + |
| 201 | + - name: "Car Windows" |
| 202 | + unique_id: car_windows |
| 203 | + icon: mdi:car-door |
| 204 | + state: "{{ is_state('binary_sensor.xpb_358_windows_closed', 'on') }}" |
| 205 | + turn_on: |
| 206 | + service: mbapi2020.windows_close |
| 207 | + data: |
| 208 | + vin: !secret [REDACTED] |
| 209 | + turn_off: |
| 210 | + service: mbapi2020.windows_open |
| 211 | + data: |
| 212 | + vin: !secret [REDACTED] |
| 213 | + |
| 214 | + - name: "Car Door Locks" |
| 215 | + unique_id: car_doors |
| 216 | + icon: mdi:car-door |
| 217 | + state: "{{ is_state('sensor.xpb_358_lock', '2') }}" |
| 218 | + turn_on: |
| 219 | + service: mbapi2020.doors_unlock |
| 220 | + data: |
| 221 | + vin: !secret [REDACTED] |
| 222 | + turn_off: |
| 223 | + service: mbapi2020.doors_lock |
| 224 | + data: |
| 225 | + vin: !secret [REDACTED] |
| 226 | + |
| 227 | +# ============================================================================== |
| 228 | +# 3. AUTOMATION (Notifications) |
| 229 | +# ============================================================================== |
| 230 | +automation: |
| 231 | + - alias: "Notify: Car Status" |
| 232 | + id: notify_car_status_glc |
| 233 | + description: "Manages mobile notifications for critical car events including charging status, pre-conditioning, tire pressure warnings, and fluid levels. Uses the 'notify_smart_master' script." |
| 234 | + trigger: |
| 235 | + - entity_id: binary_sensor.car_charge_plug |
| 236 | + from: "off" |
| 237 | + to: "on" |
| 238 | + id: plug_in |
| 239 | + platform: state |
| 240 | + - entity_id: binary_sensor.xpb_358_charging_active |
| 241 | + from: "off" |
| 242 | + to: "on" |
| 243 | + id: charging_start |
| 244 | + platform: state |
| 245 | + - entity_id: sensor.xpb_358_state_of_charge |
| 246 | + above: 99 |
| 247 | + id: charging_full |
| 248 | + platform: numeric_state |
| 249 | + - entity_id: binary_sensor.xpb_358_preclimate_status |
| 250 | + from: "off" |
| 251 | + to: "on" |
| 252 | + id: climate_started |
| 253 | + platform: state |
| 254 | + - entity_id: binary_sensor.xpb_358_preclimate_status |
| 255 | + from: "on" |
| 256 | + to: "off" |
| 257 | + id: climate_stopped |
| 258 | + platform: state |
| 259 | + - entity_id: binary_sensor.xpb_358_tire_warning |
| 260 | + to: "on" |
| 261 | + id: warn_tire |
| 262 | + platform: state |
| 263 | + - entity_id: binary_sensor.xpb_358_low_brake_fluid_warning |
| 264 | + to: "on" |
| 265 | + id: warn_brake |
| 266 | + platform: state |
| 267 | + - entity_id: binary_sensor.xpb_358_low_coolant_level_warning |
| 268 | + to: "on" |
| 269 | + id: warn_coolant |
| 270 | + platform: state |
| 271 | + - entity_id: binary_sensor.xpb_358_low_wash_water_warning |
| 272 | + to: "on" |
| 273 | + id: warn_wash_water |
| 274 | + platform: state |
| 275 | + action: |
| 276 | + - choose: |
| 277 | + - conditions: |
| 278 | + - condition: trigger |
| 279 | + id: charging_start |
| 280 | + sequence: |
| 281 | + - wait_for_trigger: |
| 282 | + - entity_id: sensor.xpb_358_charging_power |
| 283 | + above: 0 |
| 284 | + platform: numeric_state |
| 285 | + timeout: "00:02:00" |
| 286 | + continue_on_timeout: true |
| 287 | + - variables: |
| 288 | + notification_data: | |
| 289 | + {% if trigger.id == 'plug_in' %} |
| 290 | + { |
| 291 | + "title": "🔌 Car Connected", |
| 292 | + "message": "Charging cable connected.", |
| 293 | + "tag": "car_charging", |
| 294 | + "critical": false |
| 295 | + } |
| 296 | + {% elif trigger.id == 'charging_start' %} |
| 297 | + {% set power = states('sensor.xpb_358_charging_power') %} |
| 298 | + {% set raw_end = state_attr('sensor.xpb_358_end_of_charge', 'original_value') %} |
| 299 | + |
| 300 | + {# Convert raw timestamp to HH:MM format (Local Time) #} |
| 301 | + {% if raw_end not in ['unknown', 'unavailable', None] %} |
| 302 | + {% set end_time = as_timestamp(raw_end) | timestamp_custom('%H:%M') %} |
| 303 | + {% else %} |
| 304 | + {% set end_time = 'Calculating...' %} |
| 305 | + {% endif %} |
| 306 | +
|
| 307 | + { |
| 308 | + "title": "⚡ Charging Started", |
| 309 | + "message": "Charging at {{ power }} kW. Ready by: {{ end_time }}", |
| 310 | + "tag": "car_charging", |
| 311 | + "critical": false |
| 312 | + } |
| 313 | + {% elif trigger.id == 'charging_full' %} |
| 314 | + {% set range = states('sensor.xpb_358_range_electric') %} |
| 315 | + { |
| 316 | + "title": "🔋 Fully Charged", |
| 317 | + "message": "Battery is 100%. Range: {{ range }} km.", |
| 318 | + "tag": "car_charging", |
| 319 | + "critical": false |
| 320 | + } |
| 321 | + {% elif trigger.id == 'climate_started' %} |
| 322 | + { |
| 323 | + "title": "🚗 Car Climate", |
| 324 | + "message": "Pre-conditioning has started.", |
| 325 | + "tag": "car_climate", |
| 326 | + "critical": false |
| 327 | + } |
| 328 | + {% elif trigger.id == 'climate_stopped' %} |
| 329 | + { |
| 330 | + "title": "🚗 Car Climate", |
| 331 | + "message": "Pre-conditioning finished.", |
| 332 | + "tag": "car_climate", |
| 333 | + "critical": false |
| 334 | + } |
| 335 | + {% elif trigger.id == 'warn_tire' %} |
| 336 | + { |
| 337 | + "title": "⚠️ Car Warning", |
| 338 | + "message": "Check Tire Pressure!", |
| 339 | + "tag": "car_warning", |
| 340 | + "critical": false |
| 341 | + } |
| 342 | + {% elif trigger.id == 'warn_brake' %} |
| 343 | + { |
| 344 | + "title": "🚨 Car Critical", |
| 345 | + "message": "Low Brake Fluid Warning! Check immediately.", |
| 346 | + "tag": "car_warning", |
| 347 | + "critical": true |
| 348 | + } |
| 349 | + {% elif trigger.id == 'warn_coolant' %} |
| 350 | + { |
| 351 | + "title": "⚠️ Car Warning", |
| 352 | + "message": "Low Coolant Level.", |
| 353 | + "tag": "car_warning", |
| 354 | + "critical": false |
| 355 | + } |
| 356 | + {% elif trigger.id == 'warn_wash_water' %} |
| 357 | + { |
| 358 | + "title": "💧 Car Warning", |
| 359 | + "message": "Low Washer Fluid Level.", |
| 360 | + "tag": "car_warning", |
| 361 | + "critical": false |
| 362 | + } |
| 363 | + {% endif %} |
| 364 | + - service: script.notify_smart_master |
| 365 | + data: |
| 366 | + category: car |
| 367 | + title: "{{ (notification_data | from_json).title }}" |
| 368 | + message: "{{ (notification_data | from_json).message }}" |
| 369 | + tag: "{{ (notification_data | from_json).tag }}" |
| 370 | + critical: "{{ (notification_data | from_json).critical }}" |
| 371 | + mode: queued |
| 372 | +# ------------------------------------------------------------------------------ |
| 373 | +# Changelog |
| 374 | +# ------------------------------------------------------------------------------ |
| 375 | +# 2.0.3 (2025-12-07): Added Changelog footer. |
| 376 | +# 2.0.2 (2025-12-07): Added unique_id to automation for UI editing. |
| 377 | +# 2.0.1 (2025-12-07): Moved VIN to secrets. Updated automation description. |
| 378 | +# 2.0.0 (2025-12-07): Initial consolidation of Package A, B, and UI Automation. |
| 379 | +# ------------------------------------------------------------------------------ |
| 380 | + |
| 381 | +``` |
0 commit comments