fix: convert pressure sensors from kgf/cm² to bar
This commit is contained in:
parent
03308e5c53
commit
410f81d8d2
|
|
@ -31,7 +31,6 @@ from .. import (
|
|||
|
||||
UNIT_LITRE_PER_MINUTE = "L/min"
|
||||
UNIT_ROTATIONS_PER_MINUTE = "r/min"
|
||||
UNIT_PRESSURE_KGFCM2 = "kgf/cm²"
|
||||
UNIT_BAR = "bar"
|
||||
ICON_PUMP = "mdi:pump"
|
||||
ICON_VALVE = "mdi:pipe-valve"
|
||||
|
|
@ -604,7 +603,7 @@ CONFIG_SCHEMA = cv.Schema(
|
|||
accuracy_decimals=2,
|
||||
device_class=DEVICE_CLASS_PRESSURE,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
unit_of_measurement=UNIT_PRESSURE_KGFCM2,
|
||||
unit_of_measurement=UNIT_BAR,
|
||||
),
|
||||
cv.Optional(CONF_TOP65): sensor.sensor_schema(
|
||||
PanasonicHeatpumpSensor,
|
||||
|
|
@ -618,7 +617,7 @@ CONFIG_SCHEMA = cv.Schema(
|
|||
accuracy_decimals=2,
|
||||
device_class=DEVICE_CLASS_PRESSURE,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
unit_of_measurement=UNIT_PRESSURE_KGFCM2,
|
||||
unit_of_measurement=UNIT_BAR,
|
||||
),
|
||||
cv.Optional(CONF_TOP67): sensor.sensor_schema(
|
||||
PanasonicHeatpumpSensor,
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace esphome {
|
||||
namespace panasonic_heatpump {
|
||||
static const char* const TAG = "panasonic_heatpump.sensor";
|
||||
static constexpr float KGF_CM2_TO_BAR = 0.980665f; // 1 kgf/cm² = 0.980665 bar
|
||||
|
||||
void PanasonicHeatpumpSensor::dump_config() {
|
||||
LOG_SENSOR("", "Panasonic Heatpump Sensor", this);
|
||||
|
|
@ -261,7 +262,7 @@ void PanasonicHeatpumpSensor::publish_new_state(const std::vector<uint8_t>& data
|
|||
return;
|
||||
break;
|
||||
case SensorIds::CONF_TOP64:
|
||||
new_state = PanasonicDecode::getByteMinus1Div5(data[163]);
|
||||
new_state = PanasonicDecode::getByteMinus1Div5(data[163]) * KGF_CM2_TO_BAR;
|
||||
if (this->has_state() && this->get_state() == new_state)
|
||||
return;
|
||||
break;
|
||||
|
|
@ -271,7 +272,7 @@ void PanasonicHeatpumpSensor::publish_new_state(const std::vector<uint8_t>& data
|
|||
return;
|
||||
break;
|
||||
case SensorIds::CONF_TOP66:
|
||||
new_state = PanasonicDecode::getByteMinus1Times50(data[164]);
|
||||
new_state = PanasonicDecode::getByteMinus1Times50(data[164]) * KGF_CM2_TO_BAR;
|
||||
if (this->has_state() && this->get_state() == new_state)
|
||||
return;
|
||||
break;
|
||||
|
|
|
|||
Loading…
Reference in New Issue