Custom Images not shown on moon sensor

Right, but that’s not the same template. That’s using Java Script, where what you posted up top in the picture_template is Jinja. 2 totally different interpreters.

Sure, confusing it is now and then.
Still, I’ve been forced to use this intermediary template_sensor for the Tiles because I couldn’t get the javascript to do that for me…No way I could get that in the correct syntax.

A mixed bag of Jinja and Javascript, and both can use Pythonesque techniques…

Well, you are doing stuff that isn’t standard, of course it’s going to get confusing. The standard coding for HA is yaml and jinja.

ok, I appreciate that, and indeed confess to take things in the frontend a bit further than the default HA configuration. But thats what makes HA sing for me, and adds to the WAF…
Luckily with the aid of this great community, many challenges are met with great solutions. I thank you for that most sincerely! :+1:

1 Like

I am not sure I fully understand this change to 0.81

  • Template sensors will no longer auto update if we can’t find relevant entities in the template. You’ll want to review your template sensors and consider adding relevant entity_id entries or use the new homeassistant.update_entity service.

Does this still hold true?

I’m guessing yes because the entity_id appears somewhere in the template?
I just want to be sure before I ugrade!

maybe this helps:

Ive updated to 0.81.0b2 and as far as I can see the moon sensor still works fine:

23

42

and the regular sensor.moon

07

Thanks. A little :slight_smile:
As far as I can tell the safest thing is to always include the entity_id!

Also, it seems like this could be a big breaking change for some people?

Yes I updated all my template sensors to include the entity_id used in the template. I have no idea why not just referencing the sensor in the template isn’t enough. It’s a 0.81.0 change. Guess there’s some purpose regarding timer out of sync but I only started getting errors after 0.81 because of the entity id.

All my template sensors are working without using entity_id. I think there are some fringe cases in which the parser cannot resolve a sensor. Those are going to fail now.

yes, same here, most (all aamof) of them still work fine, fringe cases are explained by @pnbruckner above

Trying to get my moon sensor going on my new build and after trying several of these examples still can’t get things running. Any help would be appreciated.

I am running Home Assistant 0.93.1 using the #hass-io image on Raspberry Pi 3 B+ on a 64GB card. I am connected via wireless on the same network as my devices I am trying to control. I am also subscribed and logged into Home Assistant Cloud.

Directory Structure:
/local/moonphases/

core-ssh:/config/www/moonphases# ls
NFirstQuarter.jpg NNewMoon.jpg NWaxingCrescent.jpg
NFullMoon.jpg NWaningCrescent.jpg NWaxingGibbous.jpg
NLastQuarter.jpg NWaningGibbous.jpg

Here is my config snippet:

# Sensors
sensor:

# Moon Phase 
  - platform: template
    sensors:
      moonphases:
       friendly_name: 'Moon'
       value_template: >
        {{ states('sensor.moon').title().replace('_',' ') }}
       entity_picture_template: >
        {% set state = states('sensor.moon').title().replace('_','') %}
        {{ '/local/moonphases/N{}.jpg'.format(state) }}

Thanks in advance for the help!

what do you see? Or have any errors? the template is fine.

you do have a folder /config/www/moonphases ? because /local = /config/www …

also, be sure to need the replace function in the images template, I don’t use that and my files look like:
57
I use

      moon_phases:
        friendly_name: 'Moon phases'
        value_template: >
          {{states('sensor.moon').title().replace('_',' ')}}
        entity_picture_template: >
          {% set state = states('sensor.moon') %}
          {{ '/local/weather/moonphases/{}.jpg'.format(state) }}

because I didn’t like the capitals in the file names…

but, since your template results in:


and your files are named like that, it seems you don’t have a folder named /www

I do have a folder /config/www/moonphases

No errors in Config when I do config check.
The display shows sensor with label Moon that is a blank white circle circle

I thought perhaps my template was wrong because of how I had my files named so I renamed to be like yours:

and I updated my config matching yours (adjusting the directory to local/moonphases

# Moon Phase 
  - platform: template
    sensors:
      moon_phases:
        friendly_name: 'Moon Phase'
        value_template: >
          {{states('sensor.moon').title().replace('_',' ')}}
        entity_picture_template: >
          {% set state = states('sensor.moon') %}
          {{ '/local/moonphases/{}.jpg'.format(state) }}

I don’t get why I can’t get the status or images to display?

I don’t see why it shouldn’t be working. From what I see, you have the www folder, you’re using local. and your code will get you the correct information. Just to rule out the template, copy the entity_picture_template into the value template so we can see the output.

EDIT: Actually, it appears as if your sensor.moon is causing the problems. You’re getting the word unknown as a state back, that’s coming directly from it outputting ‘none’. Fix sensor.moon and you fix your problem.

1 Like

yes that what I tried also, and on my system, the template shows fine, see above screenshot.

maybe the files are in an incorrect format/density?

of course…

sensor:
  - platform: moon

should be in your config :wink:

1 Like

Bingo the entity picture template shows this as well when I adjusted to test

re-added sensor.moon (and Yes @petro and @Mariusthvdb it was there just spaced over incorrectly it looked like but not throwing an error)

We HAVE MOON!!!

However, now I am still getting Unknown. Wil this sort out over time?

regular sensor.moon is showing status fine. but the single color moon icons (default moon icons that used to show up) is not showing. Is this expected behavior?

Once I get this all sorted I assume I should hide the regular sensor and then trigger the template to show after the sun sets?

sensor.moon is still not showing the default icons it used to. Would be good to understand why. Before I started with the value_template, it would show default icons. I plan on hiding this and just using the vaule_template but its one of those things I’d like to understand and fix.

The updated moon phase template is working and updating now. I forgot that its not a real-time update and takes time to pull in the data.

Special Thanks to @petro and @Mariusthvdb for digging in and helping me resolve this. I appreciate it.

1 Like

you mean this?:

17

should automatically do so, unless you’ve customized it someway. brightness-3 now.

While we’re on the subject of the moon sensor, has anyone else noticed that it appears to report a full moon a day late?

must admit I’ve never been troubled by that :wink: out of ignorance probably, and it gave me reason to check this:

which has some nice pictures too I will probably ‘borrow’.

Does the sensor moon have an attribute of next full moon, down think so? So we can only check if it says so?