Custom iFrame based on sensor

I would like to have an iframe that loads specific URLs depending on the state on a certain sensor.

Has this not been done? Although I’m no programming guru it doesn’t seem like it would be too much work. Could someone help me with this?

Best
Johan

I realized I was a bit vague about my project…

I have a moon-sensor with jpg-images for the 8 different phases and I would like them to show in HAdash.

My first thought was to use the icon-widget but that didn’t work as you probably know.
So as of now there doesn’t seem to be an easy way to bring those jpg’s in along with the sensor, closest way I can come up with is to have the 8 URLs from my server in a argumented IMG/URL-list but that’s where my programming skills falls short.

Is there another way?

The moon sensor badge in home assistant frontend will show icons. I’ll post my setup when i get back home later.

  - platform: template
    sensors:
        moonphases:
          entity_id: sensor.moon
          friendly_name: "Moon Phase"
          value_template: "{{ states.sensor.moon.state }}"
          entity_picture_template: >-
            {% if is_state('sensor.moon', 'New moon') %}
              /local/MoonPhases/NNewMoon.jpg
            {% elif is_state('sensor.moon', 'Waxing crescent') %}
              /local/MoonPhases/NWaxingCrescent.jpg
            {% elif is_state('sensor.moon', 'First quarter') %}
              /local/MoonPhases/NFirstQuarter.jpg
            {% elif is_state('sensor.moon', 'Waxing gibbous') %}
              /local/MoonPhases/NWaxingGibbous.jpg
            {% elif is_state('sensor.moon', 'Full moon') %}
              /local/MoonPhases/NFullMoon.jpg
            {% elif is_state('sensor.moon', 'Waning gibbous') %}
              /local/MoonPhases/NWaningGibbous.jpg
            {% elif is_state('sensor.moon', 'Last quarter') %}
              /local/MoonPhases/NLastQuarter.jpg
            {% elif is_state('sensor.moon', 'Waning crescent') %}
              /local/MoonPhases/NWaningCrescent.jpg
            {% endif %}

Not my work, I got it from somewhere else on the forum.

Thats the sensor I’ve got too, but the issue here is to get it to show those custom icons in the HADashboard-presentation.
Thank you anyway :slight_smile: