Awesome thank you! Where are you getting your moon png’s from I like them better than mine lol
I just did a google search for phases of the moon pictures
can this be used in the customize section to modify an existing binary sensor or do I have to create a template sensor for it to work?
No idea I just used a template sensor
Alrighty then. Thanks!
I just gave it a try by creating a template binary sensor.
It didn’t work but I’m not sure why.
Here is the code in my binary_sensors.yaml:
- platform: template
sensors:
n_gd_pos_template:
friendly_name: "North Garage Door Position"
device_class: opening
value_template: "{{ is_state('binary_sensor.garage_door_north_position_sensor', 'on') }}"
entity_picture_template: >
{% if is_state('binary_sensor.garage_door_north_position_sensor', 'off') %}
/local/my-garage-closed.png
{% elif is_state('binary_sensor.garage_door_north_position_sensor', 'on') %}
/local/my-garage-open.png
{% endif %}
extra_data_template: Battery Level ${(entities['sensor.batt_garagedoor1'].state)}%
I ran the template through the checker and it came up with the correct response so I know that part is good.
I get this error in the log:
2018-02-11 17:26:20 ERROR (MainThread) [homeassistant.config] Invalid config for [binary_sensor.template]: [entity_picture_template] is an invalid option for [binary_sensor.template]. Check: binary_sensor.template->sensors->n_gd_pos_template->entity_picture_template. (See ?, line ?). Please check the docs at https://home-assistant.io/components/binary_sensor.template/
I’ve checked the docs and according to that “entity_picture_template” is indeed a valid option:
Am I missing something here?
Try getting rid of the above line? Other than that I don’t see where yours is different from mine.
Yeah I already tried that. Neither way works.
Looks like I need to keep digging…
The only other thing that’s different is the device_class line.
The docs say that is OK too but I removed that line just to be sure.
Same result.
It needs to be in sensors not binary_sensors maybe?
Both should support entity_picture_template. At least according to the docs…
I tried it anyway…
same result only now the error is in sensor not binary_sensor
2018-02-11 18:46:54 ERROR (MainThread) [homeassistant.config] Invalid config for [sensor.template]: [device_class] is an invalid option for [sensor.template]. Check: sensor.template->sensors->n_gd_pos_template->device_class. (See ?, line ?). Please check the docs at https://home-assistant.io/components/sensor.template/
EDIT: never mind different error…
Last thing I can think of is the - in the png name, try it with an underscore, after that I’m out of ideas
moving it to sensor instead of binary_sensor worked.
I guess the docs are wrong! Or I’m not seeing something I did wrong…
Now I just have to figure out the template to have it say open/closed as opposed to true/false. That shouldn’t be too hard (famous last words…I didn’t think the rest would have been that hard either)
Glad you got it working :), the moon template above does exactly that
@keithh666 I cant get this to work but i dont get any errors either.
sensor:
- platform: moon
- platform: template
sensors:
moonphases:
entity_id: sensor.moon
friendly_name: "Moon"
value_template: "{{ states.sensor.moon.state }}"
entity_picture_template: >
{% if is_state('sensor.moon', 'New moon') %}
/local/moonphases/nm.png
{% elif is_state('sensor.moon', 'Waxing crescent') %}
/local/moonphases/wxc.png
{% elif is_state('sensor.moon', 'First quarter') %}
/local/moonphases/fq.png
{% elif is_state('sensor.moon', 'Waxing gibbous') %}
/local/moonphases/wxg.png
{% elif is_state('sensor.moon', 'Full moon') %}
/local/moonphases/fm.png
{% elif is_state('sensor.moon', 'Waning gibbous') %}
/local/moonphases/wng.png
{% elif is_state('sensor.moon', 'Last quarter') %}
/local/moonphases/lq.png
{% elif is_state('sensor.moon', 'Waning crescent') %}
/local/moonphases/wnc.png
{% endif %}
It could be your value template…This is what worked for me.
value_template: >
{% if is_state('sensor.moon', 'New moon') %}
'New Moon'
{% elif is_state('sensor.moon', 'Waning crescent') %}
'Waning Moon'
{%elif is_state('sensor.moon', 'Waxing crescent') %}
'Waxing Moon'
{% endif %}
entity_picture_template: >
{% if is_state('sensor.moon', 'New moon') %}
/local/moon_new.png
{% elif is_state('sensor.moon', 'Waning crescent') %}
/local/moonwane.png
{%elif is_state('sensor.moon', 'Waxing crescent') %}
/local/moonwax.png
{% endif %}
I realized that i need to use sensor.moonphases
Can you tell me where can I download the moonphase of all 8 png?