kalkih / mini-graph-card

Minimalistic graph card for Home Assistant Lovelace UI
MIT License
3.05k stars 237 forks source link

Bug: binary input in v0.11.0 #701

Closed Saentist closed 2 years ago

Saentist commented 2 years ago

After update to latest version v0.11.0 card refuse to use day/night binari sensor.

message

mini-graph-card
Entity not available: input_number.nighttime

In version v0.10.0 there was no problem.

jlsjonas commented 2 years ago

Hi, thanks for your report. Could you please provide your full card configuration & can you please confirm that the entity does (still) exist?

Saentist commented 2 years ago

Entity exist im use it in other cards

  - type: custom:mini-graph-card
    name: Temperature
    icon: mdi:thermometer-lines
    hour24: true
    line_width: 2
    animate: true
    entities:
      - entity: sensor.outdoor_temperature
      - entity: input_number.nighttime
        name: Night
        show_line: false
        show_points: false
        show_legend: false
        y_axis: secondary
    hours_to_show: 168
    show:
      fill: true
      extrema: true
      labels: true
      labels_secondary: true
    color_thresholds:
      - value: -5
        color: '#1286f3'
      - value: 0
        color: '#e317c4'
      - value: 15
        color: '#f5f1a9'
jlsjonas commented 2 years ago

Could you provide the config of your number helper; and/or perhaps a history of it? I just did a quick extra test using 0 & 1 as values on an input_number, but this works fine.

Can you try a browser refresh clearing cache to ensure it's not a weird caching-related issue?

Saentist commented 2 years ago

image

# time date
  - platform: time_date
    display_options:
      - 'time'
      - 'date'
      - 'date_time'
      - 'date_time_utc'
      - 'date_time_iso'
      - 'time_date'
      - 'time_utc'
      - 'beat'
  - platform: template
    sensors:
      day_night:
        friendly_name: "Day/Night"
        value_template: >-
          {% if is_state('sun.sun', 'above_horizon') %}
            Day
          {% else %}
            Night
          {% endif %}
        icon_template: >-
          {% if is_state('sun.sun', 'above_horizon') %}
            mdi:weather-sunny
          {% else %}
            mdi:weather-night
          {% endif %}
jlsjonas commented 2 years ago

It looks like you're referring to input_number.nighttime in your template, but are actually using sensor.day_night?

Saentist commented 2 years ago

But how is changed from sensor.day_night to input_number.nighttime? I dont change this from year

p.s. even with corected name it not show night graph as before.

jlsjonas commented 2 years ago

I can't provide you an answer to that, the config you provided above indicates you created a sensor.day_night, and the error implies that the input_number.nighttime no longer exists.

There was a recent fix to more properly report configuration errors, so perhaps 0.10 was just silently failing on that missing entity for you?

even with corected name it not show night graph as before.

What are you getting now & what are you expecting?

Saentist commented 2 years ago

image

this is now 1 week but no night background Must be some as this

image

when i point Night i get NaN image

jlsjonas commented 2 years ago

You would need something like a state_map to do this within mini-graph-card https://github.com/kalkih/mini-graph-card#non-numeric-sensor-states

Could it be that you accidentally deleted your input_number.nighttime which was providing day/night as a simple 1/0 numeric value?

p.s.: Binary input doesn't have ideal support yet (#505) but your case just seems to be a string; not a binary

ildar170975 commented 2 years ago

But how is changed from sensor.day_night to input_number.nighttime?

Use the same entity in the card as you specified in configuration for this purpose. Otherwise the issue is meaningless and is not supposed to be even raised.

What you can do is:

  1. Define a template sensor:
    sensor:
    - platform: template
    sensors:
      night:
        icon_template: mdi:power-sleep
        value_template: >-
          {% if is_state('sun.sun','above_horizon') -%}
          {{ 0 | int }}
          {%- else -%}
          {{ 1 | int }}
          {%- endif %}
  2. Add the sensor on the graph as a background:
      - entity: sensor.night
        color: some semi transparent color (darkish for light theme)
        unit: ''
        show_state: false
        show_indicator: false
        show_graph: true
        show_line: false
        show_fill: true
        show_points: false
        show_legend: false
        state_adaptive_color: false
        fixed_value: false
        aggregate_func: last
        y_axis: secondary

    Surely you may use a binary_sensor alternatively + state_map but the state_map is currently not supported per-entity and you'll see warnings in the browser then.

ildar170975 commented 2 years ago

Answers were given.