Lovelace: mini graph card

This is my config:

resources:
  - url: /community_plugin/mini-graph-card/mini-graph-card-bundle.js
    type: module
...
      - type: custom:mini-graph-card
        entities:
          - sensor.meter_zonnepanelen_uur
        aggregate_func: max
        group_by: hour
        points_per_hour: 1
        lower_bound: 0
        show:
          graph: bar

Could you please send me the config for that night_time entity + automations, I’ll set it up and see if I can reproduce the issue, thanks!

Config looks good, I’m not able to reproduce the issue either.
I’m 99% confident you’re still loading the old version fo the card, we could easily figure this out if you create a very basic graph and try with and without the new smoothing option, do you see any difference?

- type: custom:mini-graph-card
  name: TESTING
  entities:
    - sensor.example
  smoothing: false # enable/disable

I guess the next step would be to try reinstalling the card in HACS.

They look the same :frowning:

Uninstalled, reinstalled and restarted HA 


EDIT: and now it is working OK all of a sudden :slight_smile:

I am not sure why (probably bad memory :smiley: ) but I thought with card-mod I had to go and wrap everything inside another card, that’s why it was scaring me :slight_smile:

Your code worked perfectly!

Regarding the night mode:
input_number:

night_time:
  name: Night Time
  icon: mdi:theme-light-dark
  min: 0
  max: 1
  step: 1

sensor:

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 %}

automations:
To 1:

alias: System - Night Time On
initial_state: on
trigger:
  - platform: state
    entity_id: sensor.day_night
    to: 'Night'
  - platform: homeassistant
    event: start
condition:
  condition: and
  conditions:
    - condition: state
      entity_id: sensor.day_night
      state: 'Night'
action:
  - service: input_number.set_value
    data_template:
      entity_id: input_number.night_time
      value: 1

To 0:

alias: System - Night Time Off
initial_state: on
trigger:
  - platform: state
    entity_id: sensor.day_night
    to: 'Day'
  - platform: homeassistant
    event: start
condition:
  condition: and
  conditions:
    - condition: state
      entity_id: sensor.day_night
      state: 'Day'
action:
  - service: input_number.set_value
    data_template:
      entity_id: input_number.night_time
      value: 0

Card config:

      - type: custom:mini-graph-card
        name: Temperature 48h
        icon: "${vars[0] > 30 ? 'fas:thermometer-full' : vars[0] > 25 ? 'fas:thermometer-three-quarters' : vars[0] > 20 ? 'fas:thermometer-half' : vars[0] > 10 ? 'fas:thermometer-quarter' : 'fas:thermometer-empty' }"
        more_info: false
        group: false
        height: 150
        line_width: 4
        hours_to_show: 168
        points_per_hour: 0.25
        aggregate_func: max
        group_by: hour
        hour24: true
        animate: true
        decimals: 1
        font_size: 100
        font_size_header: 14
        align_header: default
        align_icon: right
        align_state: center
        lower_bound: -5
        upper_bound: 40
        show:
          name: false
          icon: false
          state: false
          graph: line
          fill: false
          points: false
          legend: false
          extrema: false
          labels: false
          name_adaptive_color: false
          icon_adaptive_color: false
        entities:
          - entity: sensor.dark_sky_temperature
            name: Outside
            color: '#FF8000'
          - entity: sensor.master_bedroom_temperature
            name: Master Bedroom
            color: '#0080FF'
          - entity: sensor.living_room_temperature
            name: Living Room
            color: '#FF3333'
          - entity: sensor.studio_andrea_temperature
            name: Studio Andrea
            color: '#7F00FF'
          - entity: sensor.studio_sonia_temperature
            name: Studio Sonia
            color: '#00FF00'
          - entity: sensor.master_bathroom_temperature
            name: Master Bathroom
            color: '#33FF99'
          - entity: sensor.bathroom_temperature
            name: Bathroom
            color: '#FF33FF'
          - entity: sensor.kitchen_temperature
            name: Bathroom
            color: '#FF6666'
          - entity: input_number.night_time
            color: gray
            name: Night Time
            show_fill: true
            show_line: false
            show_points: false
            show_legend: false
            y_axis: secondary

Thanks, as usual, for your immense help every single time :slight_smile:

Andrea

Awesome! Caching can be a real pain in the *** sometimes :wink:

Yeah, that was the old card-modder, I think thomas rewrote it from scratch and it’s now much more convenient!

Great looking setup and great colors btw!

Thank you :smile:
I’ll set up the sensor and try it out tomorrow or later this week.

1 Like

One thing I have noticed, is that when the card it’s using “bar” mode, the night_time is showed as a bar rather than a “background” as I would like, but on the lines (temperatures), it doesn’t show at all

Wow
 so how long ago did the card name change? I was using the old version all along
 as soon as I changed to the new version, my colours started working in the graphs


Okay, that it shows as a bar in “bar mode” is expected, there’s currently no way of mixing bar and line graphs in the same card. In the example it’s just rendered as another line graph entity on a separate y-axis so that it span over the full graph height.

In HACS you mean?
I don’t know to be honest, a few months ago I think, don’t know exactly what version of HACS it changed in and couldn’t find any mention of it in the HACS release notes.
The change has caused quite some headache for users of my cards


Yeah
 I guess I downloaded the updated card but never noticed the name had changed so I still had the old one AND the new one but because I didn’t see to change the resources I was still using the old card.

you have not been the only one :smile:

1 Like

Yeah I was going CRAZY with wondering why my colours were’t reacting to the different values of the line

Turns out I still had the old mini-media card as well

@DavidFW1960 it was August when I found out the first time just by luck :slight_smile:

This reply is directly linked to my original repy, since I didn’t find the “quote” button XD

1 Like

So I thought some more about this and it’s actually possible to achieve.
If you set the option line_width to 0, bars/values at the lower bound should be completely hidden.

I love the mini graph card, kalkih.

I’m trying to follow your advice earlier for creating a template sensor of a binary sensor but I don’t know what I’m doing wrong.

The goal is to show temperature in the mini graph card with a y_axis showing when lights are on and off using the switch.lights entity.

sensor:
  - platform: mqtt
    name: "Temperature"
    state_topic: "tent/sensor1"
    unit_of_measurement: '°C'
  - platform: mqtt
    name: "Humidity"
    state_topic: "tent/sensor1"
    unit_of_measurement: '°C'
    scan_interval: 20
    force_update: true
  - platform: template
    sensors:
      lights_on_status:
        value_template: '{% if states.binary_sensor.lighttest %}
          {% if states.binary_sensor.lighttest.state == "on" %}
            1
          {% else %}
            0
          {% endif %}
          {% else %}
          n/a
          {% endif %}'
        friendly_name: 'Lights on test' 
        entity_id:
          - sensor.lightson
binary_sensor:
  platform: template
  sensors:
    lighttest:
      value_template: "{{ is_state('switch.lights', 'on') }}"
      entity_id:
      - swtich.test    

I like the new group by date feature. Very handy.

Screenshot_2019-10-23%20Home%20Assistant

3 Likes

Would you mind sharing/explaining how did you achieve the cost-per-day?
I’ve been looking for something like this but never found the right way.

Thanks :slight_smile:

Here’s one I prepared earlier: Daily energy monitoring

And the card config:

type: 'custom:mini-graph-card'
entities:
  - entity: sensor.total_cost_today
name: Energy Cost Per Day
aggregate_func: max
group_by: date
hours_to_show: 168
show:
  graph: bar
  labels: true
color_thresholds:
  - color: '#039BE5'
    value: 0
  - color: '#0da035'
    value: 5
  - color: '#e0b400'
    value: 7.5
  - color: '#e45e65'
    value: 10
3 Likes

Yep, that works. Thx !

1 Like

Hey, with last version of the card you should be able to use binary sensors directly in the card.
So if you’r light sensor reports it’s state as “on” and “off”, consider a config like this:

- type: custom:mini-graph-card
  name: Temperature
  entities:
    - entity: sensor.temp_sensor
    - entity: binary_sensor.light_sensor
      y_axis: secondary
      aggregate_func: min
      smoothing: false
      color: black
      show_line: false
      show_points: false
  points_per_hour: 6
  line_width: 2
  state_map:
    - value: "off"
      label: Lights off
    - value: "on"
      label: Lights on

You’ll want to set points_per_hour pretty high to be able to spot small durations of “Lights on”, you can also paly around with the aggregate_func option, max/min.

Nice!
Indeed, this feature allows for a whole bunch of new use cases!

1 Like

OK. So I updated my binary sensor a little bit and input that as an entity to read in the mini graph card.
As a y_axis secondary, the values are 0 and 0. In a graph by itself it reads as NaN with no graph values.
Looking at my History panel, I see no line graph data for either the binary_sensor or the sensor template I created of the binary_sensory.

Could this be why there isn’t data loading to the mini graph?

I appreciate the help in this matter. If you have a Ko-fi, paypal, or patreon, I’d love to donate.