Merge pull request #37 from ElVit/heatpump/pressure-unit-bar
fix: convert pressure sensors from kgf/cm² to bar
This commit is contained in:
commit
824d7accd9
|
|
@ -31,7 +31,6 @@ from .. import (
|
||||||
|
|
||||||
UNIT_LITRE_PER_MINUTE = "L/min"
|
UNIT_LITRE_PER_MINUTE = "L/min"
|
||||||
UNIT_ROTATIONS_PER_MINUTE = "r/min"
|
UNIT_ROTATIONS_PER_MINUTE = "r/min"
|
||||||
UNIT_PRESSURE_KGFCM2 = "kgf/cm²"
|
|
||||||
UNIT_BAR = "bar"
|
UNIT_BAR = "bar"
|
||||||
ICON_PUMP = "mdi:pump"
|
ICON_PUMP = "mdi:pump"
|
||||||
ICON_VALVE = "mdi:pipe-valve"
|
ICON_VALVE = "mdi:pipe-valve"
|
||||||
|
|
@ -604,7 +603,7 @@ CONFIG_SCHEMA = cv.Schema(
|
||||||
accuracy_decimals=2,
|
accuracy_decimals=2,
|
||||||
device_class=DEVICE_CLASS_PRESSURE,
|
device_class=DEVICE_CLASS_PRESSURE,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=STATE_CLASS_MEASUREMENT,
|
||||||
unit_of_measurement=UNIT_PRESSURE_KGFCM2,
|
unit_of_measurement=UNIT_BAR,
|
||||||
),
|
),
|
||||||
cv.Optional(CONF_TOP65): sensor.sensor_schema(
|
cv.Optional(CONF_TOP65): sensor.sensor_schema(
|
||||||
PanasonicHeatpumpSensor,
|
PanasonicHeatpumpSensor,
|
||||||
|
|
@ -618,7 +617,7 @@ CONFIG_SCHEMA = cv.Schema(
|
||||||
accuracy_decimals=2,
|
accuracy_decimals=2,
|
||||||
device_class=DEVICE_CLASS_PRESSURE,
|
device_class=DEVICE_CLASS_PRESSURE,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=STATE_CLASS_MEASUREMENT,
|
||||||
unit_of_measurement=UNIT_PRESSURE_KGFCM2,
|
unit_of_measurement=UNIT_BAR,
|
||||||
),
|
),
|
||||||
cv.Optional(CONF_TOP67): sensor.sensor_schema(
|
cv.Optional(CONF_TOP67): sensor.sensor_schema(
|
||||||
PanasonicHeatpumpSensor,
|
PanasonicHeatpumpSensor,
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace panasonic_heatpump {
|
namespace panasonic_heatpump {
|
||||||
static const char* const TAG = "panasonic_heatpump.sensor";
|
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() {
|
void PanasonicHeatpumpSensor::dump_config() {
|
||||||
LOG_SENSOR("", "Panasonic Heatpump Sensor", this);
|
LOG_SENSOR("", "Panasonic Heatpump Sensor", this);
|
||||||
|
|
@ -261,7 +262,7 @@ void PanasonicHeatpumpSensor::publish_new_state(const std::vector<uint8_t>& data
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
case SensorIds::CONF_TOP64:
|
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)
|
if (this->has_state() && this->get_state() == new_state)
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
|
|
@ -271,7 +272,7 @@ void PanasonicHeatpumpSensor::publish_new_state(const std::vector<uint8_t>& data
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
case SensorIds::CONF_TOP66:
|
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)
|
if (this->has_state() && this->get_state() == new_state)
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue