How to draw curve/ graph card with own values, not sensor values?

It took me hours to find code examples, I was able to adapt for my needs. Console Log and Chrome Debugger was also helpful.

1 Like

This is great. What if I want the values on the y axis to come from climate entity attributes?

For example:
{{ state_attr('climate.heat_set_1_curvel', 'current_temperature') }}

It returns the correct value in the template devtool but returns an error in plotly.

type: custom:plotly-graph
hours_to_show: current_day
layout:
  xaxis:
    type: number
    showlegend: false
    autorange: reversed
  yaxis:
    fixedrange: true
    range:
      - 10
      - 85
entities:
  - entity: ''
    x:
      - 20
      - -35
    'y':
      - {{ state_attr('climate.heat_set_1_curvel', 'current_temperature')
      - 25
    line:
      shape: spline
Configuration errors detected:
missed comma between flow collection entries (19:73)

 16 |  ... 
 17 |  ... 
 18 |  ... 
 19 |  ... curvel', 'current_temperature') }}
-----------------------------------------^

In your plotly code, there are missing two closing curly brackets at the end of the first y: value.

Here is a visualization for mine:

(documented on 🎨 Add instructions for compensation curve visualization by kamaradclimber · Pull Request #117 · kamaradclimber/heishamon-homeassistant · GitHub)

EDIT: someone nicely remarked my curves are reversed: water is supposed to be hotter when outside is colder :sweat_smile: so the correct curves should go down instead of going up. But the code remains very similar.

1 Like

That’s probably just a typo. It makes no difference to the error.

When I quote within the curly brackets, the error stops but the value still does not show up. When saved and come back, it shows [object object] : null.

Finally, woohoo! Thank you @kamaradclimber for the real result to draw nice simple heat curves!

Now my code comes to nice only Plotly code:

      - type: custom:plotly-graph
        refresh_interval: 10
        defaults:
          entity:
            show_value: false
            line:
              shape: line
              width: 2
            mode: lines+markers+text
            texttemplate: '%{y}'
            textposition: top left
        layout:
          xaxis:
            type: number
            autorange: true
        entities:
          - entity: ''
            x:
              - ala
              - kylmä
              - keski
              - lämmin
              - ylä
            'y':
              - >-
                $ex
                hass.states['input_number.hvac_asetusarvo_ulkolampotila_01_alaraja'].state
              - >-
                $ex
                hass.states['input_number.hvac_asetusarvo_ulkolampotila_02_kylmaraja'].state
              - >-
                $ex
                hass.states['input_number.hvac_asetusarvo_ulkolampotila_03_keskiraja'].state
              - >-
                $ex
                hass.states['input_number.hvac_asetusarvo_ulkolampotila_04_lamminraja'].state
              - >-
                $ex
                hass.states['input_number.hvac_asetusarvo_ulkolampotila_05_ylaraja'].state

1 Like

Thank you @sofa74surfer for your code and image :slight_smile:
It helped a lot in making my own setup by adopting your code to my needs.

Actually my heat pump maker has a tool on their homepage where you can enter the slope and translation (offset) and see what the curve (in their case a straight line) will be.
As you can set the heat pump to follow the “curve” depending on the slope and translation you enter manually into the het pump you can get it to ajdust the outgoing temp based on the slope and translation you have chosen.
By taking into account the outside temp the heat pump follwos the “curve” chosen.

Havig connected the heat pump to HA and having the possibility to set the outgoing temp thru HA I do not need the heat pump itself to adjust the out going temp, but could use my own calcuation and automations (for exampel compensation for heavy wind cooling etc).

Thanks to your code, which I adopted to my own needs I can visualize it in HA and do not need to go the their home page anymore.

Did youever get the auto update to work? I have not looked into it yet, but I get the feeling it has to be edited in the code for the add on instead of the graph code.

Next steps will be do make my own curve which will not be a straight line as when it gets colder normally there is less wind and less moisture in the air which means that you actually might overrun when using a straight line.