Custom Images not shown on moon sensor

oh now if it’s correct

was missing

  • platform: moon

thank you!

In Spanish it is said “quien la sigue lo consigue”. (the one who follows it gets it)
In this forum there is a group of admirable experts, who are able to dedicate their time to inexperienced people like Nerea or me.

1 Like

Piggy backing off this old thread but for some reason the image isn’t showing up for me…

Suggestions? I put the info in the template editor and it shows the path correctly and the sensor seems to be working correctly. Here’s all that I have suggestions would be greatly appreciated!
Thank you!

- type: vertical-stack
        cards:
          - type: custom:mushroom-chips-card
            chips:
              - type: entity
                entity: sensor.moon_phases
              - type: template
                content: >-
                  Sunrise  {% if states.sun.sun %} {{
                  (as_timestamp(states.sun.sun.attributes.next_rising)) |
                  timestamp_custom(('%-I:%M %p') )}} {% endif %}
                icon: mdi:weather-sunset-up
              - type: template
                content: >-
                  Sunset  {% if states.sun.sun %} {{
                  (as_timestamp(states.sun.sun.attributes.next_setting)) |
                  timestamp_custom(('%-I:%M %p') )}} {% endif %}
              - type: template
                content: >-
                  {% set setting = state_attr('sun.sun', 'next_setting') | as_datetime | as_local %}
                  {% set rising = state_attr('sun.sun', 'next_rising') | as_datetime | as_local %}
                  Sun{{ iif(rising < setting, 'rise', 'set') }} in {{ (iif(rising < setting, rising, setting) - now()).total_seconds() | timestamp_custom('%-I:%M', 0) }}
                icon: mdi:weather-sunset-down

Here’s what it’s showing:

Capture

Here’s the sensor that I have put in the template editor and it returns correctly but won’t display in the front end…

- platform: template
  sensors:
    moon_img:
      friendly_name_template: >
        {{states('sensor.moon_phases')}}
      value_template: >
        {{states('sensor.moon').capitalize().replace('_',' ')}}
      entity_picture_template: >-
        {% set state = states('sensor.moon') %}
        {{ '/local/images/moon_phases/{}.png'.format(state) }}

Capture

I’m sure I’ve missed something but it’s not showing the image…

try:

      - unique_id: moon_phases
        name: >
          {% set phase = states('sensor.moon') %}
          {% set mapper = {'new_moon':'Nieuwe Maan',
                           'waxing_crescent':'Jonge Maansikkel',
                           'first_quarter':'Eerste Kwartier',
                           'waxing_gibbous':'Wassende Maan',
                           'full_moon':'Volle Maan',
                           'waning_gibbous':'Afnemende Maan',
                           'last_quarter':'Laatste Kwartier'} %}
          {{mapper[phase] if phase in mapper else 'Asgrouwe Maan'}}
          ({{phase|replace('_',' ')|capitalize}})
        state: >
          {{states('sensor.moon').capitalize().replace('_',' ')}}
        picture: >
          {% set state = states('sensor.moon') %}
          /local/weather/moonphases/{{state}}.jpg

which goes under

template:
  - trigger:
      - platform: time_pattern
        hours: 0
        minutes: 0
      - platform: homeassistant
        event: start
      - platform: event
        event_type: event_template_reloaded
    sensor:

because I only need it to update on day change, or startup. You can ofc also put it under the template: sensor listing directly.

1 Like

[quote=“Mariusthvdb, post:105, topic:66681”]

Thank you…
Just having an issue…

you have sensors: under template: that shouldn’t be there.

also, since I use this to translate the states of sensor.moon, you dont need that. in fact, you dont even use the mapper in your final template :wink:

so simply use the last line of that template.
(btw, please dont post screenshots… we can not copy those yaml blocks like that)

1 Like

When I tried using the above as the code [in the screen shot above]… it passes config but nothing shows up

Even when I take out

sensors:

I check states and nothing shows… so it’s not loading [this]

template:
 - trigger:
     - platform: time_pattern
       hours: 0
       minutes: 0
     - platform: homeassistant
       event: start
     - platform: event
       event_type: event_template_reloaded
   sensor:
     - unique_id: moon_phases
       name: >
         {% set phase = states('sensor.moon') %}
         ({{phase|replace('_',' ')|capitalize}})
       state: >
         {{states('sensor.moon').capitalize().replace('_',' ')}}
       picture: >
         {% set state = states('sensor.moon') %}
         /local/images/moonphases/{{state}}.png

Do you have the Moon integration installed?
I tried your template in the developer tools and it works fine
moon

1 Like

Yes I do :slight_smile: That was the 1st thing I made sure I did.

I also get the same thing in the template editor:

name: >

      (Waxing crescent)
    state: >
      Waxing crescent
    picture: >
      
      /local/images/moonphases/waxing_crescent.png

So where is your problem?
You should have another moon_phase entity in the entities.

I do and this is what that shows…

Capture

However it doesn’t show up on the frontend as an image…this is what it’s still showing:

Capture

This is the frontend WHICH I suspect is the problem…

- type: vertical-stack
        cards:
          - type: custom:mushroom-chips-card
            chips:
              - type: entity
                entity: sensor.moon_phases```

Yes, it will be a problem in the mushroom card.
Take a look at their thread, maybe you’ll find a solution there

1 Like

I think I’ll just pull it out of that card and make a new one for now. Thank you guys!!!

There are 3 back ticks in that code that seem
Off (shouldn’t be there)

Also, check the dev states for moon_phases only. You might have an entity with template_moon_phases

1 Like

Thank you! I have discovered it has something to do directly with the mushroom card…
When I put it in a regular vertical-stack card the image shows up!!

So I’m going to have to figure out how to do with the chips card that I already have but not finding much in the forum or on Github to actually show someone how to accomplish that.

Actually I don’t it can be done the way I’m doing it…