diff --git a/components/daikin_rotex_uart/__init__.py b/components/daikin_rotex_uart/__init__.py index 5a13412..fc4de0b 100644 --- a/components/daikin_rotex_uart/__init__.py +++ b/components/daikin_rotex_uart/__init__.py @@ -131,6 +131,195 @@ def get_fan_divider(): "accuracy_decimals": 1, "state_class": STATE_CLASS_MEASUREMENT }, + { + "type": "sensor", + "name": "liq_pressure", + "registryID": 0x20, + "offset": 14, + "signed": True, + "dataSize": 2, + "endian": Endian.LITTLE, + "divider": 10, + "device_class": DEVICE_CLASS_PRESSURE, + #"unit_of_measurement": UNIT_BAR, + "accuracy_decimals": 1, + "state_class": STATE_CLASS_MEASUREMENT + }, + { + "type": "sensor", + "name": "t_liq2", + "registryID": 0x20, + "offset": 14, + "signed": True, + "dataSize": 2, + "endian": Endian.LITTLE, + "divider": 10, + "device_class": DEVICE_CLASS_TEMPERATURE, + "unit_of_measurement": UNIT_CELSIUS, + "accuracy_decimals": 1, + "state_class": STATE_CLASS_MEASUREMENT, + "handle_lambda": """ + const double pressureBar = (data[0] + (data[1] << 8)) / 10.0; + const double divider = 10.0; + + const std::vector> table = { + {0.482,-65.0}, + {0.511,-64.0}, + {0.542,-63.0}, + {0.574,-62.0}, + {0.607,-61.0}, + {0.642,-60.0}, + {0.679,-59.0}, + {0.717,-58.0}, + {0.757,-57.0}, + {0.799,-56.0}, + {0.843,-55.0}, + {0.888,-54.0}, + {0.935,-53.0}, + {0.985,-52.0}, + {1.036,-51.0}, + {1.090,-50.0}, + {1.146,-49.0}, + {1.204,-48.0}, + {1.264,-47.0}, + {1.326,-46.0}, + {1.391,-45.0}, + {1.459,-44.0}, + {1.529,-43.0}, + {1.602,-42.0}, + {1.677,-41.0}, + {1.755,-40.0}, + {1.836,-39.0}, + {1.920,-38.0}, + {2.007,-37.0}, + {2.096,-36.0}, + {2.189,-35.0}, + {2.285,-34.0}, + {2.385,-33.0}, + {2.487,-32.0}, + {2.593,-31.0}, + {2.703,-30.0}, + {2.816,-29.0}, + {2.933,-28.0}, + {3.053,-27.0}, + {3.177,-26.0}, + {3.306,-25.0}, + {3.438,-24.0}, + {3.574,-23.0}, + {3.714,-22.0}, + {3.858,-21.0}, + {4.007,-20.0}, + {4.160,-19.0}, + {4.317,-18.0}, + {4.479,-17.0}, + {4.645,-16.0}, + {4.817,-15.0}, + {4.992,-14.0}, + {5.173,-13.0}, + {5.359,-12.0}, + {5.550,-11.0}, + {5.746,-10.0}, + {5.947,-9.0}, + {6.153,-8.0}, + {6.365,-7.0}, + {6.583,-6.0}, + {6.806,-5.0}, + {7.034,-4.0}, + {7.268,-3.0}, + {7.509,-2.0}, + {7.755,-1.0}, + {8.007,0.0}, + {8.265,1.0}, + {8.530,2.0}, + {8.801,3.0}, + {9.078,4.0}, + {9.362,5.0}, + {9.653,6.0}, + {9.950,7.0}, + {10.25,8.0}, + {10.57,9.0}, + {10.88,10.0}, + {11.21,11.0}, + {11.54,12.0}, + {11.88,13.0}, + {12.23,14.0}, + {12.58,15.0}, + {12.95,16.0}, + {13.32,17.0}, + {13.70,18.0}, + {14.08,19.0}, + {14.48,20.0}, + {14.88,21.0}, + {15.29,22.0}, + {15.71,23.0}, + {16.14,24.0}, + {16.57,25.0}, + {17.02,26.0}, + {17.48,27.0}, + {17.94,28.0}, + {18.41,29.0}, + {18.89,30.0}, + {19.39,31.0}, + {19.89,32.0}, + {20.40,33.0}, + {20.92,34.0}, + {21.45,35.0}, + {21.99,36.0}, + {22.54,37.0}, + {23.10,38.0}, + {23.67,39.0}, + {24.26,40.0}, + {24.85,41.0}, + {25.45,42.0}, + {26.07,43.0}, + {26.70,44.0}, + {27.34,45.0}, + {27.99,46.0}, + {28.65,47.0}, + {29.32,48.0}, + {30.01,49.0}, + {30.71,50.0}, + {31.42,51.0}, + {32.14,52.0}, + {32.88,53.0}, + {33.63,54.0}, + {34.39,55.0}, + {35.17,56.0}, + {35.96,57.0}, + {36.76,58.0}, + {37.58,59.0}, + {38.42,60.0}, + {39.27,61.0}, + {40.13,62.0}, + {41.01,63.0}, + {41.91,64.0}, + {42.82,65.0}, + {43.75,66.0}, + {44.70,67.0}, + {45.67,68.0}, + {46.65,69.0}, + {47.65,70.0}, + {48.67,71.0}, + }; + + if (pressureBar < table.front().first || pressureBar > table.back().first) { + return -1; // Druck außerhalb des gültigen Bereichs! + } + + for (size_t i = 1; i < table.size(); ++i) { + if (pressureBar <= table[i].first) { + double x1 = table[i - 1].first; + double y1 = table[i - 1].second; + double x2 = table[i].first; + double y2 = table[i].second; + + return (y1 + (pressureBar - x1) * (y2 - y1) / (x2 - x1)) * divider; + } + } + + return -1; + """ + }, { "type": "sensor", "name": "inv_prim_current", diff --git a/examples/full.yaml b/examples/full.yaml index 5262e83..cd829c3 100644 --- a/examples/full.yaml +++ b/examples/full.yaml @@ -103,6 +103,10 @@ daikin_rotex_uart: name: Betriebsart t_liq: name: Temperatur Flüssigkeitsleitung + liq_pressure: + name: Kältemitteldruck + t_liq2: + name: Kältemittetemperatur exv: name: Expansionsventil exch_temp: