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

2 Likes

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.

Hi,

Total newbie here and would really appreciate some help. I’ve tried the code in the thread but can’t get it to work for me. I want the graph to show the my weather compensation of my heat pump. I have the x1-4 (ambient temp) and y1-4 (flow temp) values, as ‘editable’ climate’s (e.g. climate.ecomode_flow_temp_y1). Can anyone assist please. Ideally i would like the 8 sliders values at the top and the corrsponding graph below. Unless anyone has any better ideas. Many thanks

Hi @robomilo!

Which of the codes did you try out? And can you maybe try draw a curve you are trying to achieve with excel/ drawing program?

Thanks for your reply, this is what i currently have and can directly change the values of the heat pump, they are climate entites. I ideally wanted a ‘curved’ graph underneath.

@robomilo, you seem to have same kind of curve needs as I did.

If you do not need the most beautiful shape of curve, you can try to use my simple plotly code in the couple of answers back:

Yes this is what i wanted! I’m no progammer, i tried the code but could get it to work.

@robomilo, let me try to help and break down what might be the reason for code not working. Firstly, in all these sample codes we are using “Plotly” which is HACS card. Have you installed it?

More info about Plotly in HA: