Skip to content

360 Degree Vehicle Images

Wayne Drescher edited this page Oct 9, 2024 · 9 revisions

This guide will help you set up dynamic 3D vehicle images in your Ultra Vehicle Card for Home Assistant, refreshing the images every 5 seconds.

Step 1: Create a Template Sensor

First, you'll need to create a template sensor in your configuration.yaml that generates the image URLs based on the current time.

  1. Open your configuration.yaml file.
  2. Add the following code to create the template sensor:
template:
  - sensor:
      - name: "Current Time"
        state: "{{ now().strftime('%H:%M:%S') }}"
      - name: "Current Date"
        state: "{{ now().strftime('%Y-%m-%d') }}"
      - name: "Dynamic 3D Image"
        state: "{{ now() }}"
        attributes:
          entity_picture: >
            {% set image_number = '%03d' % ((now().second * 36 / 60) | round(0, 'floor')) %}
            {{ '/local/3d_images/yourimageprefix' + image_number + '.png' }}

yourimageprefix should be the prefix before the number like NLG_G1U_360e_

This sensor generates the URL for the 3D images based on the current seconds and milliseconds.

Step 2: Set Up Automation to Update the Sensor

Next, set up an automation that will force the sensor to update every 5 seconds.

  1. Add the following code to your automations.yaml file to create the automation:
automation:
     - alias: Update Dynamic Image Every 5 Seconds
       trigger:
         - platform: time_pattern
           seconds: "/5"
       action:
         - service: homeassistant.update_entity
           target:
             entity_id: sensor.dynamic_3d_image

This automation will trigger an update of the dynamic_3d_image sensor every 5 seconds.

You can also add the automation in YAML form using the Home Assistant GUI and choosing the 3 dots and clicking "Edit in Yaml" and pasting the code above.

Step 3: Use the Entity in Ultra Vehicle Card

Select "Entity" for your vehicle image and select the entity you just made, in this case sensor.dynamic_3d_image

Conclusion

By following these steps, you will have a dynamic 3D vehicle image that updates every 0.5 seconds in your Ultra Vehicle Card. If you have any issues or questions, feel free to reach out for assistance!