mentalilll/ha-vpd-chart

Chart Zones are displayed wrong

garv3 opened this issue · 4 comments

Checklist

  • I updated the card to the latest version available
  • I cleared the cache of my browser

Describe the bug
The Zones are configured as follows:

vpd_phases:
  - upper: 0.4
    className: under-transpiration
  - lower: 0.4
    upper: 0.8
    className: early-veg
  - lower: 0.8
    upper: 1.2
    className: late-veg
  - lower: 1.2
    upper: 1.6
    className: mid-late-flower
  - lower: 1.6
    className: danger-zone

The chart is abviously wrong with the upper end of early veg at about 0.72 instead of 0.8:
image

Version of the card
Version: 1.2.4

To Reproduce
This is the configuration I used:

type: custom:ha-vpd-chart
air_text: Temp.
rh_text: RF
min_temperature: 5
max_temperature: 35
min_humidity: 10
max_humidity: 100
min_height: 200
is_bar_view: false
enable_tooltip: true
enable_axes: false
enable_ghostmap: false
enable_triangle: true
sensors:
  - temperature: sensor.luftsensor_arbeitszimmer_temperature
    humidity: sensor.luftsensor_arbeitszimmer_humidity
    name: Growbox
leaf_temperature_offset: 2
kpa_text: VPD
vpd_phases:
  - upper: 0.4
    className: under-transpiration
  - lower: 0.4
    upper: 0.8
    className: early-veg
  - lower: 0.8
    upper: 1.2
    className: late-veg
  - lower: 1.2
    upper: 1.6
    className: mid-late-flower
  - lower: 1.6
    className: danger-zone

Screenshots
see above

Expected behavior
The chart should show the zones as configured.

Desktop (please complete the following information):

  • Browser [Edge]
  • Version [125.0.2535.51]

Smartphone (please complete the following information):

  • Device: [Xiaomi Mi Mix 3]
  • OS: [Android]
  • Browser [HA Companion App]
  • Version [2024.4.1-full]

Additional context
In /dist/chart.js line 47 I can see that the leaf temperature is a constant and always uses 2 °C delta instead of the configured value:
const Tleaf = Tair - 2;
I don't know if this makes a difference since I use 2 as the offset value in config (which by the way is used in an unconventional way; should be -2 and added in the code instead of being subtracted).

I just found that the chart should change depending on the leaf temp offset. You can test this on this page: https://www.dimluxlighting.com/knowledge/blog/vapor-pressure-deficit-the-ultimate-guide-to-vpd/
There is a chart where you can select several leaf temp offsets. As you can see, the chart chages. Maybe this has not been taken into account?

Hi, i fixed line 47 on chart.js, missed it :P.

also i rechecked the shown vpd chart. and you are right! there was a offset, i hope its fixed now, still testing.
sorry for that problem

No need to apologize, thanks for your work! Finally a VPD chart that does not block all lovelace navigation.

Works now!

Fixed!