I’m currently working on a project to get my car’s data into HA based on mqtt.
The problem is that the VIN of the car is in the mqtt message: eg
weconnect/0/vehicles/VIN/domains/readiness/readinessStatus/connectionState/batteryPowerLevel
I would like to define the VIN as a variable in the mqtt message. My first try:
platform: template
# substitutions:
{% set vin = "VIN"%}
{% set car = "id4"%}
sensor:
- platform: mqtt
name: {% car %}_display_name
state_topic: "weconnect/0/vehicles/" + {% vin %} + "/nickname"
icon: mdi:car
I would like to define 2 variables: vin and car. The car variable will be used if people have 2 cars, so they can give each sensor a unique name. Otherwise we’ll have duplicate sensor names.
But my code gives errors and I have no clue.
Any idea how this can be accomplished?