Custom Images not shown on moon sensor

the image doesn’t come out, I think the problem is this,

image

It’s possible. But it’s a subject I don’t know enough about.

not to barge in here, but you need an image for ‘fase lunar desconocida’ sorry about that, that is the friendly_name. probably need ‘unknown.jpg’ …

what does the template editor show when you enter:

 - platform: template
    sensors:
      moon_phases:
        entity_id: sensor.moon
        friendly_name: Luna
        value_template: >
          {% set phases = { 'new_moon':'Luna nueva', 'waxing_crescent':'Luna creciente', 'first_quarter':'Cuarto creciente', 'waxing_gibbous':'Gibosa creciente', 'full_moon':'Luna llena', 'waning_gibbous':'Gibosa menguante', 'last_quarter':'Cuarto menguante', 'waning_crescent':'Luna menguante'} %}
          {% set phase = states('sensor.moon') %}
          {{ phases[phase] if phase in phases.keys() else 'fase lunar desconocida' }}
        entity_picture_template: >
          {{ '/local/luna/{}.jpg'.format(states('sensor.moon')) }}

Ah ok thanks,

And what about networks do I have to accept?

Im not sure what you are saying here…?

sorry,

I mean that if I have to accept the public network to read the images

whether or not you need public network has nothing to do with you image template, but with your network settings on the computer and you HA settings… I suppose you see that with all network traffic going on?

Is that the screenshot in spanish you showed above?

but first enter the template in the template editor to see what we are looking for (what picture is needed when state is ‘unknown’)

I have already introduced an image when the moon phase is unknown. I attached the capture,
image

But it still doesn’t work and it doesn’t show me the image

image

This is the code I have in configuration.yaml

well, there is a typo (error) in the filename, so you should change that.

I asked you to enter the template in the dev-template page, and show us what that results in.

if you are on a current version of HA it is the developer-tools/template page

we need to be sure it is looking for ‘unknown_moon_phase.jpg’

I have already corrected the name and in the development template I get this

image

so it needs an ‘unknown.jpg’ as shown in the template you post.

which is to be expected using the template

{{'/local/luna/{}.jpg'.format(states('sensor.moon')) }}

sorry if I overlooked that before, Ill change it in the earlier reply…

Yes now!!

Thank you!!=)

2 Likes

I’m glad to thank Marius for your success. I’m a beginner, but I’ve tried.

cool, and very welcome!
there’s but 1 way to learn: try. And, with a little help from your friends, most things can be done :+1:

1 Like

Thank you @El_Viejo !!

Without your help it would not have been possible !!!

A question,

Why do I get unknown moon phase all the time?

image

as always, the answer lies in your code…

have a look here:

        value_template: >
          {% set phases = { 'new_moon':'Luna nueva', 'waxing_crescent':'Luna creciente', 'first_quarter':'Cuarto creciente', 'waxing_gibbous':'Gibosa creciente', 'full_moon':'Luna llena', 'waning_gibbous':'Gibosa menguante', 'last_quarter':'Cuarto menguante', 'waning_crescent':'Luna menguante'} %}
          {% set phase = states('sensor.moon') %}
          {{ phases[phase] if phase in phases.keys() else 'fase lunar desconocida' }}

this would imply your phase is not in phases.keys…

if you enter the above in the template editor you probably get your answer

below it, enter

{{states('sensor.moon'}}
{{phase}}
{{phases[phase]}}

and tell us what that results in

Pongo esto y me da error,

Este es el código que tengo:

this indicates your sensor.moon isnt working correctly.
Have you installed that at all in the setup?

see: https://www.home-assistant.io/components/moon/

this is the base sensor for all of the other template sensors to work, so essential to install first

Marius refers to something similar to this in your configuration file

##################################################################
# Empieza la sección SENSORES
##################################################################
sensor:
########## Weather prediction ####################################
  - platform: yr
########### Fases de la Luna #####################################
  - platform: moon
### Se añade el sensor de Fecha y Hora
  - platform: time_date
    display_options:
      - 'date'
      - 'time'