Sensor.nightstate not working on mini-graphics-card

Hi there,

Rather new to HA and just signed up to this forum for I can’t seem to find the answer I am looking for.
I am building a dashboard for my NAS. Therefor I added the first custom:mini-graphics-card and added this code to the card (found all these options on the internet):

type: custom:mini-graph-card
name: NAS °C (volume 01)
icon: mdi:thermometer
hours_to_show: 168
points_per_hour: 0.1
animate: true
unit: °C
show:
  extrema: true
  graph: line
  average: true
  icon_adaptive_color: true
  name_adaptive_color: false
  state: true
  fill: true
  labels: false
entities:
  - entity: sensor.NAS_volume_1_average_disk_temp
    color: '#406E37'
    name: gemiddelde temperatuur (volume 01)
  - color: '#AEBECF'
    entity: sensor.nightstate
    name: na zonsondergang
    show_legend: false
    show_line: false
    show_points: false
    y_axis: secondary
  - entity: sensor.NAS_volume_1_maximum_disk_temp
    color: '#B81F1F'
    name: maximale temperatuur (volume 01)
  - color: '#AEBECF'
    entity: sensor.nightstate
    name: na zonsondergang
    show_legend: false
    show_line: false
    show_points: false
    y_axis: secondary

This gives me a graphics with two lines, 1 in red and 1 in green. All other option are present (the ones that I want to see) but, no night state. So the gray secondar axis is not shown. T have checked that the sun.sun entity is active (it is) and I have checked that there are no errors in configuration.yaml where night.state is defined.

# Night State
sensor:
  - platform: template
    sensors:
      nightstate:
        friendly_name: “Na zonsondergang”
        value_template: “{% if is_state('sun.sun', 'below_horizon') %}1{% else %}0{% endif %}”

no_nightstate

What am I missing?
It does not change anything if I use the sensor.nightstate once at the end of the two NAS.sensors of if I do it twice.

Thanks in advance.

Kind regards,

ArtMel1998

As extra information:

HA is version 2022.12.8
Supervisor 2022.12.1
Operating System 9.4
Frontend 20221213.1

There are no issues found in the log about sensor.nightstate

Talking to myself: Still did not figure-out why this is not working for me. Checked the nightstate sensor by adding a sensor card to the dashboard. The state changes from 0 to 1 after sunset and from 1 to 0 after sunrise. So this is working. Must be something in the mini graphics card configuration or I guess. Only what?

Hello ArtMel1998 I have found another solution which is working. Instead adding the nightstate option in configuration.yaml you can do this:

type: custom:mini-graph-card
name: NAS °C (volume 01)
icon: mdi:thermometer
animate: true
hours_to_show: 168
points_per_hour: 0.1
unit: °C
graph: line
line_width: 2
hour24: true
entities:
  - entity: sensor.NAS_volume_1_average_disk_temp
    color: '#406E37'
    name: gemiddelde temperatuur (volume 01)
  - entity: sensor.NAS_volume_1_maximum_disk_temp
    color: '#B81F1F'
    name: maximale temperatuur (volume 01)
  - color: black
    entity: sun.sun
    name: na zonsondergang
    show_line: false
    show_points: false
    show_legend: false
    y_axis: secondary
show:
  extrema: true
  icon_adaptive_color: true
  name_adaptive_color: false
  labels: false
  labels_secondary: false
  fill: true
  average: true
  state: true
state_map:
  - value: below_horizon
    label: nacht
  - value: above_horizon
    label: dag

Thanks ArtMel1998, not exactly what I had in mind but this also works. Case closed.