How to setup an Input Number (for night) as shown in this custom graph?

In this example an input number is used to display night (1) and day (0) time: https://github.com/kalkih/mini-graph-card

As I can see, input number seems a box where I can put a number in. But I only need some sort of variable that changes through automation. But I don’t know how to set it up and manage it…

You can set the input number to any value using an automation. Just make a time-trigger that updates the input_number value.
You do not need to make the input_number visible in lovelace.

I know it’s an old thread, but I had the same question, and figured out how to do it using the sun.sun entity, without the need to create an input number and automation.
Here my card code:

type: custom:mini-graph-card
Name: Temperature
entities:
  - entity: sensor.pool_water_temperature
    name: Pool Water
  - entity: sensor.nest_thermostat_temperature
    name: Indoor
  - entity: sensor.weatherbit_air_temperature
    name: Outside
  - color: gray
    entity: sun.sun
    name: Sun
    show_line: false
    show_points: false
    show_legend: false
    y_axis: secondary
show:
  labels: true
  labels_secondary: true
state_map:
  - value: below_horizon
    label: Night
  - value: above_horizon
    label: Day
19 Likes

Awesome, thank you so much!
Was trying out the same with the sun.sun entity but couldn’t figure out how to map the states properly. Now it works. :smiley:

hey mate

i have literally copied this code and its does not work for me.

type: custom:mini-graph-card
entities:
  - entity: sensor.average_whole_house_humidity
  - color: gray
    entity: sun.sun
    name: Sun
    show_line: false
    show_points: false
    show_legend: false
    y_axis: secondary
hours_to_show: 96
points_per_hour: 1
line_color: '#3cb371'
font_size: 100
font_size_header: 14
show:
  labels: true
  labels_secondary: true
state_map:
  - value: below_horizon
    label: Night
  - value: above_horizon
    label: Day

Perfect, Thank You!

Thanks for the contribution!

One question though:
How do I invert the graph so that the nighttime is gray?
Right now the daytime is equivalent to binary one.

PS: please ignore the title 24h. it’s actually 48h.

Swapping the order in state_map worked for me.

state_map:
  - value: above_horizon
    label: Day
  - value: below_horizon
    label: Night
3 Likes