readd climate entity 'tank'
This commit is contained in:
parent
77c9e3e947
commit
cd5e26d4ee
|
|
@ -13,10 +13,12 @@ from .. import (
|
||||||
)
|
)
|
||||||
|
|
||||||
CONF_COOL_MODE = "cool_mode"
|
CONF_COOL_MODE = "cool_mode"
|
||||||
|
CONF_CLIMATE_TANK = "tank"
|
||||||
CONF_CLIMATE_ZONE1 = "zone1"
|
CONF_CLIMATE_ZONE1 = "zone1"
|
||||||
CONF_CLIMATE_ZONE2 = "zone2"
|
CONF_CLIMATE_ZONE2 = "zone2"
|
||||||
|
|
||||||
TYPES = [
|
TYPES = [
|
||||||
|
CONF_CLIMATE_TANK,
|
||||||
CONF_CLIMATE_ZONE1,
|
CONF_CLIMATE_ZONE1,
|
||||||
CONF_CLIMATE_ZONE2,
|
CONF_CLIMATE_ZONE2,
|
||||||
]
|
]
|
||||||
|
|
@ -43,6 +45,9 @@ CONFIG_SCHEMA = cv.Schema(
|
||||||
PanasonicHeatpumpComponent
|
PanasonicHeatpumpComponent
|
||||||
),
|
),
|
||||||
cv.Optional(CONF_COOL_MODE, default=False): cv.boolean,
|
cv.Optional(CONF_COOL_MODE, default=False): cv.boolean,
|
||||||
|
cv.Optional(CONF_CLIMATE_TANK): climate.climate_schema(
|
||||||
|
PanasonicHeatpumpClimate
|
||||||
|
).extend(climate_options(20.0, 65.0, 0.5)),
|
||||||
cv.Optional(CONF_CLIMATE_ZONE1): climate.climate_schema(
|
cv.Optional(CONF_CLIMATE_ZONE1): climate.climate_schema(
|
||||||
PanasonicHeatpumpClimate
|
PanasonicHeatpumpClimate
|
||||||
).extend(climate_options(-5.0, 5.0, 0.5)),
|
).extend(climate_options(-5.0, 5.0, 0.5)),
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,9 @@ void PanasonicHeatpumpClimate::control(const climate::ClimateCall& call) {
|
||||||
if (call.get_target_temperature().has_value()) {
|
if (call.get_target_temperature().has_value()) {
|
||||||
float new_temp = *call.get_target_temperature();
|
float new_temp = *call.get_target_temperature();
|
||||||
switch (this->id_) {
|
switch (this->id_) {
|
||||||
|
case ClimateIds::CONF_CLIMATE_TANK:
|
||||||
|
this->parent_->set_command_byte(PanasonicCommand::setPlus128(new_temp), 42); // set11
|
||||||
|
break;
|
||||||
case ClimateIds::CONF_CLIMATE_ZONE1:
|
case ClimateIds::CONF_CLIMATE_ZONE1:
|
||||||
this->parent_->set_command_byte(PanasonicCommand::setPlus128(new_temp), 38); // set5
|
this->parent_->set_command_byte(PanasonicCommand::setPlus128(new_temp), 38); // set5
|
||||||
break;
|
break;
|
||||||
|
|
@ -94,6 +97,10 @@ void PanasonicHeatpumpClimate::publish_new_state(const std::vector<uint8_t>& dat
|
||||||
|
|
||||||
new_mode = this->getClimateMode(data[6]); // set9
|
new_mode = this->getClimateMode(data[6]); // set9
|
||||||
switch (this->id_) {
|
switch (this->id_) {
|
||||||
|
case ClimateIds::CONF_CLIMATE_TANK:
|
||||||
|
new_target_temp_heat = PanasonicDecode::getByteMinus128(data[42]); // set11
|
||||||
|
new_current_temp = PanasonicDecode::getByteMinus128(data[141]); // top10
|
||||||
|
break;
|
||||||
case ClimateIds::CONF_CLIMATE_ZONE1:
|
case ClimateIds::CONF_CLIMATE_ZONE1:
|
||||||
new_target_temp_heat = PanasonicDecode::getByteMinus128(data[38]); // set5
|
new_target_temp_heat = PanasonicDecode::getByteMinus128(data[38]); // set5
|
||||||
new_target_temp_cool = PanasonicDecode::getByteMinus128(data[39]); // set6
|
new_target_temp_cool = PanasonicDecode::getByteMinus128(data[39]); // set6
|
||||||
|
|
@ -131,6 +138,15 @@ void PanasonicHeatpumpClimate::publish_new_state(const std::vector<uint8_t>& dat
|
||||||
|
|
||||||
uint8_t PanasonicHeatpumpClimate::getClimateMode(const uint8_t input) {
|
uint8_t PanasonicHeatpumpClimate::getClimateMode(const uint8_t input) {
|
||||||
switch (this->id_) {
|
switch (this->id_) {
|
||||||
|
case ClimateIds::CONF_CLIMATE_TANK:
|
||||||
|
switch ((uint8_t)(input & 0b110000)) {
|
||||||
|
case 0b010000:
|
||||||
|
return climate::CLIMATE_MODE_OFF;
|
||||||
|
case 0b100000:
|
||||||
|
return climate::CLIMATE_MODE_HEAT;
|
||||||
|
default:
|
||||||
|
return 255;
|
||||||
|
};
|
||||||
case ClimateIds::CONF_CLIMATE_ZONE1:
|
case ClimateIds::CONF_CLIMATE_ZONE1:
|
||||||
case ClimateIds::CONF_CLIMATE_ZONE2:
|
case ClimateIds::CONF_CLIMATE_ZONE2:
|
||||||
switch ((uint8_t)(input & 0b1111)) {
|
switch ((uint8_t)(input & 0b1111)) {
|
||||||
|
|
@ -157,6 +173,16 @@ uint8_t PanasonicHeatpumpClimate::getClimateMode(const uint8_t input) {
|
||||||
uint8_t PanasonicHeatpumpClimate::setClimateMode(const climate::ClimateMode mode, uint8_t byte) {
|
uint8_t PanasonicHeatpumpClimate::setClimateMode(const climate::ClimateMode mode, uint8_t byte) {
|
||||||
uint8_t newByte = byte;
|
uint8_t newByte = byte;
|
||||||
switch (this->id_) {
|
switch (this->id_) {
|
||||||
|
case ClimateIds::CONF_CLIMATE_TANK:
|
||||||
|
newByte = newByte & 0b11001111;
|
||||||
|
switch (mode) {
|
||||||
|
case climate::CLIMATE_MODE_OFF:
|
||||||
|
return newByte + 0b010000;
|
||||||
|
case climate::CLIMATE_MODE_HEAT:
|
||||||
|
return newByte + 0b100000;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
case ClimateIds::CONF_CLIMATE_ZONE1:
|
case ClimateIds::CONF_CLIMATE_ZONE1:
|
||||||
case ClimateIds::CONF_CLIMATE_ZONE2:
|
case ClimateIds::CONF_CLIMATE_ZONE2:
|
||||||
newByte = newByte & 0b11110000;
|
newByte = newByte & 0b11110000;
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace panasonic_heatpump {
|
namespace panasonic_heatpump {
|
||||||
enum ClimateIds : uint8_t {
|
enum ClimateIds : uint8_t {
|
||||||
|
CONF_CLIMATE_TANK,
|
||||||
CONF_CLIMATE_ZONE1,
|
CONF_CLIMATE_ZONE1,
|
||||||
CONF_CLIMATE_ZONE2,
|
CONF_CLIMATE_ZONE2,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,10 @@ from .. import (
|
||||||
|
|
||||||
CONF_TARGET_TEMPERATURE_STEP = "target_temperature_step"
|
CONF_TARGET_TEMPERATURE_STEP = "target_temperature_step"
|
||||||
|
|
||||||
CONF_TANK = "tank"
|
CONF_HEATER_TANK = "tank"
|
||||||
|
|
||||||
TYPES = [
|
TYPES = [
|
||||||
CONF_TANK,
|
CONF_HEATER_TANK,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -40,7 +40,7 @@ CONFIG_SCHEMA = cv.Schema(
|
||||||
cv.GenerateID(CONF_PANASONIC_HEATPUMP_ID): cv.use_id(
|
cv.GenerateID(CONF_PANASONIC_HEATPUMP_ID): cv.use_id(
|
||||||
PanasonicHeatpumpComponent
|
PanasonicHeatpumpComponent
|
||||||
),
|
),
|
||||||
cv.Optional(CONF_TANK): water_heater.water_heater_schema(
|
cv.Optional(CONF_HEATER_TANK): water_heater.water_heater_schema(
|
||||||
PanasonicHeatpumpWaterHeater
|
PanasonicHeatpumpWaterHeater
|
||||||
).extend(water_heater_options(20.0, 65.0, 0.5)),
|
).extend(water_heater_options(20.0, 65.0, 0.5)),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ void PanasonicHeatpumpWaterHeater::control(const water_heater::WaterHeaterCall&
|
||||||
|
|
||||||
float new_temp = call.get_target_temperature();
|
float new_temp = call.get_target_temperature();
|
||||||
switch (this->id_) {
|
switch (this->id_) {
|
||||||
case WaterHeaterIds::CONF_TANK:
|
case WaterHeaterIds::CONF_HEATER_TANK:
|
||||||
this->parent_->set_command_byte(PanasonicCommand::setPlus128(new_temp), 42); // set11
|
this->parent_->set_command_byte(PanasonicCommand::setPlus128(new_temp), 42); // set11
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
|
@ -56,7 +56,7 @@ void PanasonicHeatpumpWaterHeater::publish_new_state(const std::vector<uint8_t>&
|
||||||
|
|
||||||
new_mode = this->getWaterHeaterMode(data[6]); // set9
|
new_mode = this->getWaterHeaterMode(data[6]); // set9
|
||||||
switch (this->id_) {
|
switch (this->id_) {
|
||||||
case WaterHeaterIds::CONF_TANK:
|
case WaterHeaterIds::CONF_HEATER_TANK:
|
||||||
new_target_temp_heat = PanasonicDecode::getByteMinus128(data[42]); // set11
|
new_target_temp_heat = PanasonicDecode::getByteMinus128(data[42]); // set11
|
||||||
new_current_temp = PanasonicDecode::getByteMinus128(data[141]); // top10
|
new_current_temp = PanasonicDecode::getByteMinus128(data[141]); // top10
|
||||||
break;
|
break;
|
||||||
|
|
@ -77,7 +77,7 @@ void PanasonicHeatpumpWaterHeater::publish_new_state(const std::vector<uint8_t>&
|
||||||
|
|
||||||
uint8_t PanasonicHeatpumpWaterHeater::getWaterHeaterMode(const uint8_t input) {
|
uint8_t PanasonicHeatpumpWaterHeater::getWaterHeaterMode(const uint8_t input) {
|
||||||
switch (this->id_) {
|
switch (this->id_) {
|
||||||
case WaterHeaterIds::CONF_TANK:
|
case WaterHeaterIds::CONF_HEATER_TANK:
|
||||||
switch ((uint8_t)(input & 0b110000)) {
|
switch ((uint8_t)(input & 0b110000)) {
|
||||||
case 0b010000:
|
case 0b010000:
|
||||||
return water_heater::WATER_HEATER_MODE_OFF;
|
return water_heater::WATER_HEATER_MODE_OFF;
|
||||||
|
|
@ -94,7 +94,7 @@ uint8_t PanasonicHeatpumpWaterHeater::getWaterHeaterMode(const uint8_t input) {
|
||||||
uint8_t PanasonicHeatpumpWaterHeater::setWaterHeaterMode(const water_heater::WaterHeaterMode mode, const uint8_t byte) {
|
uint8_t PanasonicHeatpumpWaterHeater::setWaterHeaterMode(const water_heater::WaterHeaterMode mode, const uint8_t byte) {
|
||||||
uint8_t newByte = byte;
|
uint8_t newByte = byte;
|
||||||
switch (this->id_) {
|
switch (this->id_) {
|
||||||
case WaterHeaterIds::CONF_TANK:
|
case WaterHeaterIds::CONF_HEATER_TANK:
|
||||||
newByte = newByte & 0b11001111;
|
newByte = newByte & 0b11001111;
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case water_heater::WATER_HEATER_MODE_OFF:
|
case water_heater::WATER_HEATER_MODE_OFF:
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace panasonic_heatpump {
|
namespace panasonic_heatpump {
|
||||||
enum WaterHeaterIds : uint8_t {
|
enum WaterHeaterIds : uint8_t {
|
||||||
CONF_TANK,
|
CONF_HEATER_TANK,
|
||||||
};
|
};
|
||||||
|
|
||||||
class PanasonicHeatpumpWaterHeater : public water_heater::WaterHeater,
|
class PanasonicHeatpumpWaterHeater : public water_heater::WaterHeater,
|
||||||
|
|
|
||||||
|
|
@ -355,13 +355,13 @@ class TestPanasonicHeatpumpPlatforms:
|
||||||
|
|
||||||
from panasonic_heatpump.water_heater import (
|
from panasonic_heatpump.water_heater import (
|
||||||
CONFIG_SCHEMA,
|
CONFIG_SCHEMA,
|
||||||
CONF_TANK,
|
CONF_HEATER_TANK,
|
||||||
TYPES,
|
TYPES,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert CONFIG_SCHEMA is not None
|
assert CONFIG_SCHEMA is not None
|
||||||
assert CONF_TANK == "tank"
|
assert CONF_HEATER_TANK == "tank"
|
||||||
assert CONF_TANK in TYPES
|
assert CONF_HEATER_TANK in TYPES
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pytest.skip("Water heater platform not accessible in test environment")
|
pytest.skip("Water heater platform not accessible in test environment")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue