mirror of
https://github.com/ElVit/esphome_components.git
synced 2026-10-18 04:34:48 +02:00
Added UARTDevice, removed entity_category=ENTITY_CATEGORY_CONFIG, fixed some controls
This commit is contained in:
@@ -8,37 +8,41 @@ MULTICONF = True
|
||||
DEPENDENCIES = ['uart']
|
||||
|
||||
CONF_PANASONIC_HEATPUMP_ID = "panasonic_heatpump"
|
||||
CONF_UART_HP = "uart_hp" # uart_id
|
||||
CONF_UART_WM = "uart_wm" # uart_id_2
|
||||
#CONF_UART_HP = "uart_hp" # uart_id
|
||||
#CONF_UART_WM = "uart_wm" # uart_id_2
|
||||
CONF_UART_CLIENT = "uart_client_id"
|
||||
CONF_LOG_UART_MSG = "log_uart_msg"
|
||||
CONF_POLLING_TIME_SEC = "polling_time_in_sec"
|
||||
|
||||
panasonic_heatpump_ns = cg.esphome_ns.namespace('panasonic_heatpump')
|
||||
PanasonicHeatpumpComponent = panasonic_heatpump_ns.class_('PanasonicHeatpumpComponent', cg.Component) #, uart.UARTDevice)
|
||||
PanasonicHeatpumpComponent = panasonic_heatpump_ns.class_('PanasonicHeatpumpComponent', cg.Component, uart.UARTDevice)
|
||||
|
||||
CONFIG_SCHEMA = (
|
||||
cv.Schema(
|
||||
{
|
||||
cv.GenerateID(): cv.declare_id(PanasonicHeatpumpComponent),
|
||||
|
||||
cv.Required(CONF_UART_HP): cv.use_id(uart.UARTComponent),
|
||||
cv.Required(CONF_UART_WM): cv.use_id(uart.UARTComponent),
|
||||
#cv.Required(CONF_UART_HP): cv.use_id(uart.UARTComponent),
|
||||
#cv.Required(CONF_UART_WM): cv.use_id(uart.UARTComponent),
|
||||
cv.Optional(CONF_UART_CLIENT): cv.use_id(uart.UARTComponent),
|
||||
cv.Optional(CONF_LOG_UART_MSG, default=False): cv.boolean,
|
||||
cv.Optional(CONF_POLLING_TIME_SEC, default=2): cv.int_range(min=1),
|
||||
}
|
||||
)
|
||||
.extend(cv.COMPONENT_SCHEMA)
|
||||
# .extend(uart.UART_DEVICE_SCHEMA)
|
||||
.extend(uart.UART_DEVICE_SCHEMA)
|
||||
)
|
||||
|
||||
async def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
await cg.register_component(var, config)
|
||||
# await uart.register_uart_device(var, config)
|
||||
await uart.register_uart_device(var, config)
|
||||
|
||||
uart_hp = await cg.get_variable(config[CONF_UART_HP])
|
||||
cg.add(var.set_uart_hp(uart_hp))
|
||||
uart_wm = await cg.get_variable(config[CONF_UART_WM])
|
||||
cg.add(var.set_uart_wm(uart_wm))
|
||||
#uart_hp = await cg.get_variable(config[CONF_UART_HP])
|
||||
#cg.add(var.set_uart_hp(uart_hp))
|
||||
#uart_wm = await cg.get_variable(config[CONF_UART_WM])
|
||||
#cg.add(var.set_uart_wm(uart_wm))
|
||||
uart_client = await cg.get_variable(config[CONF_UART_CLIENT])
|
||||
cg.add(var.set_uart_client(uart_client))
|
||||
cg.add(var.set_log_uart_msg(config[CONF_LOG_UART_MSG]))
|
||||
cg.add(var.set_polling_time(config[CONF_POLLING_TIME_SEC]))
|
||||
|
||||
@@ -85,89 +85,97 @@ namespace esphome
|
||||
|
||||
int PanasonicDecode::getBit1(uint8_t input)
|
||||
{
|
||||
return (input >> 7);
|
||||
return input >> 7;
|
||||
}
|
||||
|
||||
int PanasonicDecode::getBit1and2(uint8_t input)
|
||||
{
|
||||
return ((input >> 6) - 1);
|
||||
return (input >> 6) - 1;
|
||||
}
|
||||
|
||||
int PanasonicDecode::getBit3and4(uint8_t input)
|
||||
{
|
||||
return (((input >> 4) & 0b11) - 1);
|
||||
return ((input >> 4) & 0b11) - 1;
|
||||
}
|
||||
|
||||
int PanasonicDecode::getBit5and6(uint8_t input)
|
||||
{
|
||||
return (((input >> 2) & 0b11) - 1);
|
||||
return ((input >> 2) & 0b11) - 1;
|
||||
}
|
||||
|
||||
int PanasonicDecode::getBit7and8(uint8_t input)
|
||||
{
|
||||
return ((input & 0b11) - 1);
|
||||
return (input & 0b11) - 1;
|
||||
}
|
||||
|
||||
int PanasonicDecode::getBit3and4and5(uint8_t input)
|
||||
{
|
||||
return (((input >> 3) & 0b111) - 1);
|
||||
return ((input >> 3) & 0b111) - 1;
|
||||
}
|
||||
|
||||
int PanasonicDecode::getLeft5bits(uint8_t input)
|
||||
{
|
||||
return ((input >> 3) - 1);
|
||||
return (input >> 3) - 1;
|
||||
}
|
||||
|
||||
int PanasonicDecode::getRight3bits(uint8_t input)
|
||||
{
|
||||
return ((input & 0b111) - 1);
|
||||
return (input & 0b111) - 1;
|
||||
}
|
||||
|
||||
int PanasonicDecode::getIntMinus1(uint8_t input)
|
||||
{
|
||||
int value = (int)input - 1;
|
||||
return value;
|
||||
return (int)input - 1;
|
||||
}
|
||||
|
||||
int PanasonicDecode::getIntMinus128(uint8_t input)
|
||||
{
|
||||
int value = (int)input - 128;
|
||||
return value;
|
||||
return (int)input - 128;
|
||||
}
|
||||
|
||||
// TOP127, TOP128 //
|
||||
float PanasonicDecode::getIntMinus1Div2(uint8_t input)
|
||||
{
|
||||
return ((float)input - 1) / 2;
|
||||
}
|
||||
|
||||
float PanasonicDecode::getIntMinus1Div5(uint8_t input)
|
||||
{
|
||||
return ((((float)input - 1) / 5), 1);
|
||||
return ((float)input - 1) / 5;
|
||||
}
|
||||
|
||||
float PanasonicDecode::getIntMinus1Div50(uint8_t input)
|
||||
{
|
||||
return ((((float)input - 1) / 50), 2);
|
||||
return ((float)input - 1) / 50;
|
||||
}
|
||||
|
||||
int PanasonicDecode::getIntMinus1Times10(uint8_t input)
|
||||
{
|
||||
int value = (int)input - 1;
|
||||
return (value * 10);
|
||||
return ((int)input - 1) * 10;
|
||||
}
|
||||
|
||||
int PanasonicDecode::getIntMinus1Times50(uint8_t input)
|
||||
{
|
||||
int value = (int)input - 1;
|
||||
return (value * 50);
|
||||
return ((int)input - 1) * 50;
|
||||
}
|
||||
|
||||
int PanasonicDecode::getFirstByte(uint8_t input)
|
||||
// TOP15, TOP16, TOP38, TOP39, TOP40, TOP41 //
|
||||
int PanasonicDecode::getIntMinus1Times200(uint8_t input)
|
||||
{
|
||||
return ((input >> 4) - 1);
|
||||
return ((int)input - 1) * 200;
|
||||
}
|
||||
|
||||
int PanasonicDecode::getSecondByte(uint8_t input)
|
||||
int PanasonicDecode::getHighNibbleMinus1(uint8_t input)
|
||||
{
|
||||
return ((input & 0b1111) - 1);
|
||||
return (input >> 4) - 1;
|
||||
}
|
||||
|
||||
int PanasonicDecode::getWord(uint8_t low, uint8_t hi)
|
||||
int PanasonicDecode::getLowNibbleMinus1(uint8_t input)
|
||||
{
|
||||
return (input & 0b1111) - 1;
|
||||
}
|
||||
|
||||
int PanasonicDecode::getWordMinus1(uint8_t low, uint8_t hi)
|
||||
{
|
||||
return ((hi << 8) + low) - 1;
|
||||
}
|
||||
@@ -178,65 +186,34 @@ namespace esphome
|
||||
return (value - 1);
|
||||
}
|
||||
|
||||
// TOP127, TOP128 //
|
||||
float PanasonicDecode::getValvePID(uint8_t input)
|
||||
{
|
||||
return (((float)input - 1) / 2);
|
||||
}
|
||||
|
||||
// TOP15, TOP16, TOP38, TOP39, TOP40, TOP41 //
|
||||
int PanasonicDecode::getPower(uint8_t input)
|
||||
{
|
||||
int value = ((int)input - 1) * 200;
|
||||
return value;
|
||||
}
|
||||
|
||||
// TOP4 //
|
||||
int PanasonicDecode::getOpMode(uint8_t input)
|
||||
{
|
||||
switch ((int)(input & 0b111111))
|
||||
{
|
||||
case 18:
|
||||
case 18: // heat-only
|
||||
return 0;
|
||||
case 19:
|
||||
case 19: // cool-only
|
||||
return 1;
|
||||
case 25:
|
||||
case 24: // auto
|
||||
return 2;
|
||||
case 33:
|
||||
case 25: // auto-heat
|
||||
return 3;
|
||||
case 34:
|
||||
case 26: // auto-cool
|
||||
return 4;
|
||||
case 35:
|
||||
case 33: // dhw-only
|
||||
return 5;
|
||||
case 41:
|
||||
case 34: // heat+dhw
|
||||
return 6;
|
||||
case 26:
|
||||
case 35: // cool+dhw
|
||||
return 7;
|
||||
case 42:
|
||||
case 40: // auto-dhw
|
||||
return 8;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// TOP124 //
|
||||
int PanasonicDecode::getBivalent(uint8_t input)
|
||||
{
|
||||
switch ((int)input)
|
||||
{
|
||||
case 0x55:
|
||||
return 0;
|
||||
case 0x56:
|
||||
return 1;
|
||||
case 0x57:
|
||||
return 2;
|
||||
case 0x58:
|
||||
return 3;
|
||||
case 0x59:
|
||||
return 4;
|
||||
case 0x5A:
|
||||
return 5;
|
||||
default:
|
||||
case 41: // auto-heat+dhw
|
||||
return 9;
|
||||
case 42: // auto-cool+dhw
|
||||
return 10;
|
||||
default: // unknown
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -268,19 +245,13 @@ namespace esphome
|
||||
// input2 = data[170]
|
||||
float PanasonicDecode::getPumpFlow(uint8_t input1, uint8_t input2)
|
||||
{
|
||||
int PumpFlow2 = (int)input2;
|
||||
float PumpFlow1 = (((float)input1 - 1) / 256);
|
||||
float PumpFlow = PumpFlow2 + PumpFlow1;
|
||||
return PumpFlow;
|
||||
return (((float)input1 - 1) / 256) + ((int)input2);
|
||||
}
|
||||
|
||||
// TOP5, TOP6 //
|
||||
float PanasonicDecode::getFractional(uint8_t input, uint8_t shift)
|
||||
{
|
||||
float result;
|
||||
int fractional = (int)((input >> shift) & 0b111) - 1;
|
||||
result = fractional * 0.25;
|
||||
return result;
|
||||
return ((int)((input >> shift) & 0b111) - 1) * 0.25;
|
||||
}
|
||||
|
||||
// TOP44 //
|
||||
|
||||
@@ -26,20 +26,19 @@ namespace esphome
|
||||
static int getRight3bits(uint8_t input);
|
||||
static int getIntMinus1(uint8_t input);
|
||||
static int getIntMinus128(uint8_t input);
|
||||
static float getIntMinus1Div2(uint8_t input);
|
||||
static float getIntMinus1Div5(uint8_t input);
|
||||
static float getIntMinus1Div50(uint8_t input);
|
||||
static int getIntMinus1Times10(uint8_t input);
|
||||
static int getIntMinus1Times50(uint8_t input);
|
||||
static int getFirstByte(uint8_t input);
|
||||
static int getSecondByte(uint8_t input);
|
||||
static int getWord(uint8_t hi, uint8_t low);
|
||||
static int getIntMinus1Times200(uint8_t input);
|
||||
static int getHighNibbleMinus1(uint8_t input);
|
||||
static int getLowNibbleMinus1(uint8_t input);
|
||||
static int getWordMinus1(uint8_t hi, uint8_t low);
|
||||
static int getUintt16(uint8_t input1, uint8_t input2);
|
||||
|
||||
static float getValvePID(uint8_t input);
|
||||
static int getPower(uint8_t input);
|
||||
static int getOpMode(uint8_t input);
|
||||
static int getModel(std::vector<uint8_t>& data, uint8_t index);
|
||||
static int getBivalent(uint8_t input);
|
||||
static float getPumpFlow(uint8_t input1, uint8_t input2);
|
||||
static float getFractional(uint8_t input, uint8_t shift);
|
||||
static std::string getErrorInfo(uint8_t errorType, uint8_t errorNumber);
|
||||
@@ -47,25 +46,25 @@ namespace esphome
|
||||
static bool getBinaryState(uint8_t input);
|
||||
static std::string getTextState(const char* const array[], int index);
|
||||
|
||||
static const constexpr char* const DisabledEnabled[] = {"2", "Disabled", "Enabled"};
|
||||
static const constexpr char* const BlockedFree[] = {"2", "Blocked", "Free"};
|
||||
static const constexpr char* const OffOn[] = {"2", "Off", "On"};
|
||||
static const constexpr char* const InactiveActive[] = {"2", "Inactive", "Active"};
|
||||
static const constexpr char* const PumpFlowRateMode[] = {"2", "DeltaT", "Max flow"};
|
||||
static const constexpr char* const HolidayState[] = {"3", "Off", "Scheduled", "Active"};
|
||||
static const constexpr char* const OpModeDesc[] = {"9", "Heat", "Cool", "Auto(heat)", "DHW", "Heat+DHW", "Cool+DHW", "Auto(heat)+DHW", "Auto(cool)", "Auto(cool)+DHW"};
|
||||
static const constexpr char* const Powerfulmode[] = {"4", "Off", "30min", "60min", "90min"};
|
||||
static const constexpr char* const Quietmode[] = {"4", "Off", "Level 1", "Level 2", "Level 3"};
|
||||
static const constexpr char* const Valve[] = {"2", "Room", "DHW"};
|
||||
static const constexpr char* const Valve2[] = {"2", "Cool", "Heat"};
|
||||
static const constexpr char* const MixingValve[] = {"4", "Off", "Decrease","Increase", "Invalid"};
|
||||
static const constexpr char* const ZonesState[] = {"3", "Zone1 active", "Zone2 active", "Zone1 and zone2 active"};
|
||||
static const constexpr char* const HeatCoolModeDesc[] = {"2", "Comp. Curve", "Direct"};
|
||||
static const constexpr char* const SolarModeDesc[] = {"3", "Disabled", "Buffer", "DHW"};
|
||||
static const constexpr char* const ZonesSensorType[] = {"4", "Water Temperature", "External Thermostat", "Internal Thermostat", "Thermistor"};
|
||||
static const constexpr char* const LiquidType[] = {"2", "Water", "Glycol"};
|
||||
static const constexpr char* const ExtPadHeaterType[] = {"3", "Disabled", "Type-A", "Type-B"};
|
||||
static const constexpr char* const Bivalent[] = {"3", "Alternative", "Parallel", "Advanced Parallel"};
|
||||
static const constexpr char* const DisabledEnabled[] = { "2", "Disabled", "Enabled" };
|
||||
static const constexpr char* const BlockedFree[] = { "2", "Blocked", "Free" };
|
||||
static const constexpr char* const OffOn[] = { "2", "Off", "On" };
|
||||
static const constexpr char* const InactiveActive[] = { "2", "Inactive", "Active" };
|
||||
static const constexpr char* const PumpFlowRateMode[] = { "2", "DeltaT", "Max flow" };
|
||||
static const constexpr char* const Valve[] = { "2", "Room", "DHW" };
|
||||
static const constexpr char* const Valve2[] = { "2", "Cool", "Heat" };
|
||||
static const constexpr char* const HeatCoolModeDesc[] = { "2", "Comp. Curve", "Direct" };
|
||||
static const constexpr char* const LiquidType[] = { "2", "Water", "Glycol" };
|
||||
static const constexpr char* const HolidayState[] = { "3", "Off", "Scheduled", "Active" };
|
||||
static const constexpr char* const SolarModeDesc[] = { "3", "Disabled", "Buffer", "DHW" };
|
||||
static const constexpr char* const MixingValve[] = { "4", "Off", "Decrease","Increase", "Invalid" };
|
||||
static const constexpr char* const ZonesSensorType[] = { "4", "Water Temperature", "External Thermostat", "Internal Thermostat", "Thermistor" };
|
||||
static const constexpr char* const Quietmode[] = { "4", "Off", "Level 1", "Level 2", "Level 3" };
|
||||
static const constexpr char* const Powerfulmode[] = { "4", "Off", "30min", "60min", "90min" };
|
||||
static const constexpr char* const OpModeDesc[] = { "9", "Heat only", "Cool only", "Auto", "Auto(heat)", "Auto(cool)", "DHW only", "Heat+DHW", "Cool+DHW", "Auto+DHW", "Auto(heat)+DHW", "Auto(cool)+DHW" };
|
||||
static const constexpr char* const ZonesState[] = { "3", "Zone 1", "Zone 2", "Zone 1 & 2" };
|
||||
static const constexpr char* const ExtPadHeaterType[] = { "3", "Disabled", "Type-A", "Type-B" };
|
||||
static const constexpr char* const Bivalent[] = { "3", "Alternative", "Parallel", "Advanced Parallel" };
|
||||
static const constexpr char* const ModelNames[] =
|
||||
{
|
||||
"53", //string representation of number of known models (last model number + 1)
|
||||
|
||||
@@ -126,31 +126,25 @@ CONFIG_SCHEMA = cv.Schema(
|
||||
cv.Optional(CONF_SET5): number.number_schema(
|
||||
PanasonicHeatpumpNumber,
|
||||
unit_of_measurement=UNIT_CELSIUS,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET6): number.number_schema(
|
||||
PanasonicHeatpumpNumber,
|
||||
unit_of_measurement=UNIT_CELSIUS,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET7): number.number_schema(
|
||||
PanasonicHeatpumpNumber,
|
||||
unit_of_measurement=UNIT_CELSIUS,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET8): number.number_schema(
|
||||
PanasonicHeatpumpNumber,
|
||||
unit_of_measurement=UNIT_CELSIUS,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET11): number.number_schema(
|
||||
PanasonicHeatpumpNumber,
|
||||
unit_of_measurement=UNIT_CELSIUS,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET15): number.number_schema(
|
||||
PanasonicHeatpumpNumber,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET16_1): number.number_schema(
|
||||
PanasonicHeatpumpNumber,
|
||||
@@ -235,57 +229,46 @@ CONFIG_SCHEMA = cv.Schema(
|
||||
cv.Optional(CONF_SET18): number.number_schema(
|
||||
PanasonicHeatpumpNumber,
|
||||
unit_of_measurement=UNIT_KELVIN,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET19): number.number_schema(
|
||||
PanasonicHeatpumpNumber,
|
||||
unit_of_measurement=UNIT_KELVIN,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET20): number.number_schema(
|
||||
PanasonicHeatpumpNumber,
|
||||
unit_of_measurement=UNIT_KELVIN,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET21): number.number_schema(
|
||||
PanasonicHeatpumpNumber,
|
||||
unit_of_measurement=UNIT_MINUTE,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET22): number.number_schema(
|
||||
PanasonicHeatpumpNumber,
|
||||
unit_of_measurement=UNIT_KELVIN,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET23): number.number_schema(
|
||||
PanasonicHeatpumpNumber,
|
||||
unit_of_measurement=UNIT_KELVIN,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET27): number.number_schema(
|
||||
PanasonicHeatpumpNumber,
|
||||
unit_of_measurement=UNIT_KELVIN,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET29): number.number_schema(
|
||||
PanasonicHeatpumpNumber,
|
||||
unit_of_measurement=UNIT_CELSIUS,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET36): number.number_schema(
|
||||
PanasonicHeatpumpNumber,
|
||||
unit_of_measurement=UNIT_CELSIUS,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET37): number.number_schema(
|
||||
PanasonicHeatpumpNumber,
|
||||
unit_of_measurement=UNIT_CELSIUS,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET38): number.number_schema(
|
||||
PanasonicHeatpumpNumber,
|
||||
unit_of_measurement=UNIT_CELSIUS,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
@@ -191,6 +191,7 @@ namespace esphome
|
||||
LOG_NUMBER("", "Panasonic Heatpump Number", this->set38_number_);
|
||||
#endif
|
||||
#ifdef USE_SELECT
|
||||
LOG_SELECT("", "Panasonic Heatpump Select", this->set2_select_);
|
||||
LOG_SELECT("", "Panasonic Heatpump Select", this->set3_select_);
|
||||
LOG_SELECT("", "Panasonic Heatpump Select", this->set4_select_);
|
||||
LOG_SELECT("", "Panasonic Heatpump Select", this->set9_select_);
|
||||
@@ -200,7 +201,6 @@ namespace esphome
|
||||
#endif
|
||||
#ifdef USE_SWITCH
|
||||
LOG_SWITCH("", "Panasonic Heatpump Switch", this->set1_switch_);
|
||||
LOG_SWITCH("", "Panasonic Heatpump Switch", this->set2_switch_);
|
||||
LOG_SWITCH("", "Panasonic Heatpump Switch", this->set10_switch_);
|
||||
LOG_SWITCH("", "Panasonic Heatpump Switch", this->set12_switch_);
|
||||
LOG_SWITCH("", "Panasonic Heatpump Switch", this->set13_switch_);
|
||||
@@ -216,15 +216,23 @@ namespace esphome
|
||||
#endif
|
||||
}
|
||||
|
||||
void PanasonicHeatpumpComponent::setup()
|
||||
{
|
||||
ESP_LOGCONFIG(TAG, "Setting up Panasonic Heatpump ...");
|
||||
delay(10);
|
||||
this->check_uart_settings(9600, 1, uart::UART_CONFIG_PARITY_EVEN, 8);
|
||||
}
|
||||
|
||||
void PanasonicHeatpumpComponent::loop()
|
||||
{
|
||||
uint8_t byte_hp;
|
||||
uint8_t byte_wm;
|
||||
uint8_t byte_cl;
|
||||
|
||||
while (this->uart_hp_->available())
|
||||
while (this->available())
|
||||
{
|
||||
this->uart_hp_->read_byte(&byte_hp);
|
||||
this->uart_wm_->write_byte(byte_hp);
|
||||
this->read_byte(&byte_hp);
|
||||
if (this->uart_client_)
|
||||
this->uart_client_->write_byte(byte_hp);
|
||||
|
||||
// Message shall start with 0x71, if not skip this byte
|
||||
if (!this->response_receiving_)
|
||||
@@ -261,34 +269,36 @@ namespace esphome
|
||||
}
|
||||
}
|
||||
|
||||
while (this->uart_wm_->available())
|
||||
if (this->uart_client_)
|
||||
{
|
||||
while (this->uart_client_->available())
|
||||
{
|
||||
// stop forwording messages if no message is currently processing
|
||||
if (!this->forward_requests_ && !this->request_receiving_)
|
||||
continue;
|
||||
|
||||
this->uart_wm_->read_byte(&byte_wm);
|
||||
this->uart_hp_->write_byte(byte_wm);
|
||||
this->uart_client_->read_byte(&byte_cl);
|
||||
this->write_byte(byte_cl);
|
||||
|
||||
// Message shall start with 0x71, if not skip this byte
|
||||
if (!this->request_receiving_)
|
||||
{
|
||||
if (byte_wm != 0x71)
|
||||
if (byte_cl != 0x71)
|
||||
continue;
|
||||
this->request_receiving_ = true;
|
||||
}
|
||||
// Add current byte to message buffer
|
||||
this->request_message_.push_back(byte_wm);
|
||||
this->request_message_.push_back(byte_cl);
|
||||
|
||||
// 2. bytes contains the payload size
|
||||
if (this->request_message_.size() == 2)
|
||||
this->request_payload_length_ = byte_wm;
|
||||
this->request_payload_length_ = byte_cl;
|
||||
// Discard message if 3. and 4. byte are not as expected
|
||||
if (this->request_message_.size() == 3 && byte_wm != 0x01 ||
|
||||
this->request_message_.size() == 4 && byte_wm != 0x10)
|
||||
if (this->request_message_.size() == 3 && byte_cl != 0x01 ||
|
||||
this->request_message_.size() == 4 && byte_cl != 0x10)
|
||||
{
|
||||
ESP_LOGW(TAG, "Invalid request message: %d. byte is 0x%02X but expexted is 0x%02X",
|
||||
request_message_.size(), byte_wm, request_message_.size() == 3 ? "01" : "10");
|
||||
request_message_.size(), byte_cl, request_message_.size() == 3 ? "01" : "10");
|
||||
delay(10);
|
||||
this->request_message_.clear();
|
||||
this->request_receiving_ = false;
|
||||
@@ -303,6 +313,7 @@ namespace esphome
|
||||
this->request_receiving_ = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PanasonicHeatpumpComponent::log_uart_hex(std::string prefix, std::vector<uint8_t> bytes, uint8_t separator)
|
||||
@@ -366,11 +377,11 @@ namespace esphome
|
||||
if (this->top8_sensor_) this->top8_sensor_->publish_state(PanasonicDecode::getIntMinus1(bytes[166]));
|
||||
if (this->top9_sensor_) this->top9_sensor_->publish_state(PanasonicDecode::getIntMinus128(bytes[42]));
|
||||
if (this->top10_sensor_) this->top10_sensor_->publish_state(PanasonicDecode::getIntMinus128(bytes[141]));
|
||||
if (this->top11_sensor_) this->top11_sensor_->publish_state(PanasonicDecode::getWord(bytes[182], bytes[183]));
|
||||
if (this->top12_sensor_) this->top12_sensor_->publish_state(PanasonicDecode::getWord(bytes[179], bytes[180]));
|
||||
if (this->top11_sensor_) this->top11_sensor_->publish_state(PanasonicDecode::getWordMinus1(bytes[182], bytes[183]));
|
||||
if (this->top12_sensor_) this->top12_sensor_->publish_state(PanasonicDecode::getWordMinus1(bytes[179], bytes[180]));
|
||||
if (this->top14_sensor_) this->top14_sensor_->publish_state(PanasonicDecode::getIntMinus128(bytes[142]));
|
||||
if (this->top15_sensor_) this->top15_sensor_->publish_state(PanasonicDecode::getPower(bytes[194]));
|
||||
if (this->top16_sensor_) this->top16_sensor_->publish_state(PanasonicDecode::getPower(bytes[193]));
|
||||
if (this->top15_sensor_) this->top15_sensor_->publish_state(PanasonicDecode::getIntMinus1Times200(bytes[194]));
|
||||
if (this->top16_sensor_) this->top16_sensor_->publish_state(PanasonicDecode::getIntMinus1Times200(bytes[193]));
|
||||
if (this->top21_sensor_) this->top21_sensor_->publish_state(PanasonicDecode::getIntMinus128(bytes[158]));
|
||||
if (this->top22_sensor_) this->top22_sensor_->publish_state(PanasonicDecode::getIntMinus128(bytes[99]));
|
||||
if (this->top23_sensor_) this->top23_sensor_->publish_state(PanasonicDecode::getIntMinus128(bytes[84]));
|
||||
@@ -387,10 +398,10 @@ namespace esphome
|
||||
if (this->top35_sensor_) this->top35_sensor_->publish_state(PanasonicDecode::getIntMinus128(bytes[41]));
|
||||
if (this->top36_sensor_) this->top36_sensor_->publish_state(PanasonicDecode::getIntMinus128(bytes[145]));
|
||||
if (this->top37_sensor_) this->top37_sensor_->publish_state(PanasonicDecode::getIntMinus128(bytes[146]));
|
||||
if (this->top38_sensor_) this->top38_sensor_->publish_state(PanasonicDecode::getPower(bytes[196]));
|
||||
if (this->top39_sensor_) this->top39_sensor_->publish_state(PanasonicDecode::getPower(bytes[195]));
|
||||
if (this->top40_sensor_) this->top40_sensor_->publish_state(PanasonicDecode::getPower(bytes[198]));
|
||||
if (this->top41_sensor_) this->top41_sensor_->publish_state(PanasonicDecode::getPower(bytes[197]));
|
||||
if (this->top38_sensor_) this->top38_sensor_->publish_state(PanasonicDecode::getIntMinus1Times200(bytes[196]));
|
||||
if (this->top39_sensor_) this->top39_sensor_->publish_state(PanasonicDecode::getIntMinus1Times200(bytes[195]));
|
||||
if (this->top40_sensor_) this->top40_sensor_->publish_state(PanasonicDecode::getIntMinus1Times200(bytes[198]));
|
||||
if (this->top41_sensor_) this->top41_sensor_->publish_state(PanasonicDecode::getIntMinus1Times200(bytes[197]));
|
||||
if (this->top42_sensor_) this->top42_sensor_->publish_state(PanasonicDecode::getIntMinus128(bytes[147]));
|
||||
if (this->top43_sensor_) this->top43_sensor_->publish_state(PanasonicDecode::getIntMinus128(bytes[148]));
|
||||
if (this->top45_sensor_) this->top45_sensor_->publish_state(PanasonicDecode::getIntMinus128(bytes[43]));
|
||||
@@ -430,8 +441,8 @@ namespace esphome
|
||||
if (this->top87_sensor_) this->top87_sensor_->publish_state(PanasonicDecode::getIntMinus128(bytes[91]));
|
||||
if (this->top88_sensor_) this->top88_sensor_->publish_state(PanasonicDecode::getIntMinus128(bytes[93]));
|
||||
if (this->top89_sensor_) this->top89_sensor_->publish_state(PanasonicDecode::getIntMinus128(bytes[92]));
|
||||
if (this->top90_sensor_) this->top90_sensor_->publish_state(PanasonicDecode::getWord(bytes[185], bytes[186]));
|
||||
if (this->top91_sensor_) this->top91_sensor_->publish_state(PanasonicDecode::getWord(bytes[188], bytes[189]));
|
||||
if (this->top90_sensor_) this->top90_sensor_->publish_state(PanasonicDecode::getWordMinus1(bytes[185], bytes[186]));
|
||||
if (this->top91_sensor_) this->top91_sensor_->publish_state(PanasonicDecode::getWordMinus1(bytes[188], bytes[189]));
|
||||
if (this->top93_sensor_) this->top93_sensor_->publish_state(PanasonicDecode::getIntMinus1(bytes[172]));
|
||||
if (this->top95_sensor_) this->top95_sensor_->publish_state(PanasonicDecode::getIntMinus1(bytes[45]));
|
||||
if (this->top96_sensor_) this->top96_sensor_->publish_state(PanasonicDecode::getIntMinus1(bytes[104]));
|
||||
@@ -446,8 +457,8 @@ namespace esphome
|
||||
if (this->top116_sensor_) this->top116_sensor_->publish_state(PanasonicDecode::getIntMinus128(bytes[126]));
|
||||
if (this->top117_sensor_) this->top117_sensor_->publish_state(PanasonicDecode::getIntMinus128(bytes[127]));
|
||||
if (this->top118_sensor_) this->top118_sensor_->publish_state(PanasonicDecode::getIntMinus128(bytes[128]));
|
||||
if (this->top127_sensor_) this->top127_sensor_->publish_state(PanasonicDecode::getValvePID(bytes[177]));
|
||||
if (this->top128_sensor_) this->top128_sensor_->publish_state(PanasonicDecode::getValvePID(bytes[178]));
|
||||
if (this->top127_sensor_) this->top127_sensor_->publish_state(PanasonicDecode::getIntMinus1Div2(bytes[177]));
|
||||
if (this->top128_sensor_) this->top128_sensor_->publish_state(PanasonicDecode::getIntMinus1Div2(bytes[178]));
|
||||
if (this->top131_sensor_) this->top131_sensor_->publish_state(PanasonicDecode::getIntMinus128(bytes[65]));
|
||||
if (this->top134_sensor_) this->top134_sensor_->publish_state(PanasonicDecode::getIntMinus128(bytes[66]));
|
||||
if (this->top135_sensor_) this->top135_sensor_->publish_state(PanasonicDecode::getIntMinus128(bytes[68]));
|
||||
@@ -496,19 +507,76 @@ namespace esphome
|
||||
if (this->top101_text_sensor_) this->top101_text_sensor_->publish_state(PanasonicDecode::getTextState(PanasonicDecode::SolarModeDesc, PanasonicDecode::getBit3and4(bytes[24])));
|
||||
if (this->top106_text_sensor_) this->top106_text_sensor_->publish_state(PanasonicDecode::getTextState(PanasonicDecode::PumpFlowRateMode, PanasonicDecode::getBit3and4(bytes[29])));
|
||||
if (this->top107_text_sensor_) this->top107_text_sensor_->publish_state(PanasonicDecode::getTextState(PanasonicDecode::LiquidType, PanasonicDecode::getBit1(bytes[20])));
|
||||
if (this->top111_text_sensor_) this->top111_text_sensor_->publish_state(PanasonicDecode::getTextState(PanasonicDecode::ZonesSensorType, PanasonicDecode::getSecondByte(bytes[22])));
|
||||
if (this->top112_text_sensor_) this->top112_text_sensor_->publish_state(PanasonicDecode::getTextState(PanasonicDecode::ZonesSensorType, PanasonicDecode::getFirstByte(bytes[22])));
|
||||
if (this->top111_text_sensor_) this->top111_text_sensor_->publish_state(PanasonicDecode::getTextState(PanasonicDecode::ZonesSensorType, PanasonicDecode::getLowNibbleMinus1(bytes[22])));
|
||||
if (this->top112_text_sensor_) this->top112_text_sensor_->publish_state(PanasonicDecode::getTextState(PanasonicDecode::ZonesSensorType, PanasonicDecode::getHighNibbleMinus1(bytes[22])));
|
||||
if (this->top114_text_sensor_) this->top114_text_sensor_->publish_state(PanasonicDecode::getTextState(PanasonicDecode::ExtPadHeaterType, PanasonicDecode::getBit3and4(bytes[25])));
|
||||
if (this->top125_text_sensor_) this->top125_text_sensor_->publish_state(PanasonicDecode::getTextState(PanasonicDecode::Valve2, PanasonicDecode::getBit5and6(bytes[116])));
|
||||
if (this->top126_text_sensor_) this->top126_text_sensor_->publish_state(PanasonicDecode::getTextState(PanasonicDecode::Valve, PanasonicDecode::getBit7and8(bytes[116])));
|
||||
if (this->top130_text_sensor_) this->top130_text_sensor_->publish_state(PanasonicDecode::getTextState(PanasonicDecode::Bivalent, PanasonicDecode::getBit5and6(bytes[26])));
|
||||
#endif
|
||||
#ifdef USE_NUMBER
|
||||
if (this->set11_number_) this->set11_number_->publish_state(PanasonicDecode::getIntMinus128(bytes[42]));
|
||||
if (this->set20_number_) this->set20_number_->publish_state(PanasonicDecode::getIntMinus128(bytes[99]));
|
||||
if (this->set18_number_) this->set18_number_->publish_state(PanasonicDecode::getIntMinus128(bytes[84]));
|
||||
if (this->set19_number_) this->set19_number_->publish_state(PanasonicDecode::getIntMinus128(bytes[94]));
|
||||
if (this->set5_number_) this->set5_number_->publish_state(PanasonicDecode::getIntMinus128(bytes[38]));
|
||||
if (this->set6_number_) this->set6_number_->publish_state(PanasonicDecode::getIntMinus128(bytes[39]));
|
||||
if (this->set16_1_number_) this->set16_1_number_->publish_state(PanasonicDecode::getIntMinus128(bytes[75]));
|
||||
if (this->set16_2_number_) this->set16_2_number_->publish_state(PanasonicDecode::getIntMinus128(bytes[76]));
|
||||
if (this->set16_4_number_) this->set16_4_number_->publish_state(PanasonicDecode::getIntMinus128(bytes[78]));
|
||||
if (this->set16_3_number_) this->set16_3_number_->publish_state(PanasonicDecode::getIntMinus128(bytes[77]));
|
||||
if (this->set7_number_) this->set7_number_->publish_state(PanasonicDecode::getIntMinus128(bytes[40]));
|
||||
if (this->set8_number_) this->set8_number_->publish_state(PanasonicDecode::getIntMinus128(bytes[41]));
|
||||
if (this->set16_9_number_) this->set16_9_number_->publish_state(PanasonicDecode::getIntMinus128(bytes[86]));
|
||||
if (this->set16_10_number_) this->set16_10_number_->publish_state(PanasonicDecode::getIntMinus128(bytes[87]));
|
||||
if (this->set16_12_number_) this->set16_12_number_->publish_state(PanasonicDecode::getIntMinus128(bytes[89]));
|
||||
if (this->set16_11_number_) this->set16_11_number_->publish_state(PanasonicDecode::getIntMinus128(bytes[88]));
|
||||
if (this->set29_number_) this->set29_number_->publish_state(PanasonicDecode::getIntMinus128(bytes[83]));
|
||||
if (this->set16_5_number_) this->set16_5_number_->publish_state(PanasonicDecode::getIntMinus128(bytes[79]));
|
||||
if (this->set16_6_number_) this->set16_6_number_->publish_state(PanasonicDecode::getIntMinus128(bytes[80]));
|
||||
if (this->set16_8_number_) this->set16_8_number_->publish_state(PanasonicDecode::getIntMinus128(bytes[82]));
|
||||
if (this->set16_7_number_) this->set16_7_number_->publish_state(PanasonicDecode::getIntMinus128(bytes[81]));
|
||||
if (this->set16_13_number_) this->set16_13_number_->publish_state(PanasonicDecode::getIntMinus128(bytes[90]));
|
||||
if (this->set16_14_number_) this->set16_14_number_->publish_state(PanasonicDecode::getIntMinus128(bytes[91]));
|
||||
if (this->set16_16_number_) this->set16_16_number_->publish_state(PanasonicDecode::getIntMinus128(bytes[93]));
|
||||
if (this->set16_15_number_) this->set16_15_number_->publish_state(PanasonicDecode::getIntMinus128(bytes[92]));
|
||||
if (this->set15_number_) this->set15_number_->publish_state(PanasonicDecode::getIntMinus1(bytes[45]));
|
||||
if (this->set21_number_) this->set21_number_->publish_state(PanasonicDecode::getIntMinus1(bytes[104]));
|
||||
if (this->set22_number_) this->set22_number_->publish_state(PanasonicDecode::getIntMinus128(bytes[105]));
|
||||
if (this->set23_number_) this->set23_number_->publish_state(PanasonicDecode::getIntMinus128(bytes[106]));
|
||||
if (this->set27_number_) this->set27_number_->publish_state(PanasonicDecode::getIntMinus128(bytes[59]));
|
||||
if (this->set36_number_) this->set36_number_->publish_state(PanasonicDecode::getIntMinus128(bytes[65]));
|
||||
if (this->set37_number_) this->set37_number_->publish_state(PanasonicDecode::getIntMinus128(bytes[66]));
|
||||
if (this->set38_number_) this->set38_number_->publish_state(PanasonicDecode::getIntMinus128(bytes[68]));
|
||||
#endif
|
||||
#ifdef USE_SELECT
|
||||
if (this->set9_select_) this->set9_select_->publish_state(PanasonicDecode::getTextState(PanasonicDecode::OpModeDesc, PanasonicDecode::getOpMode(bytes[6])));
|
||||
if (this->set4_select_) this->set4_select_->publish_state(PanasonicDecode::getTextState(PanasonicDecode::Powerfulmode, PanasonicDecode::getRight3bits(bytes[7])));
|
||||
if (this->set3_select_) this->set3_select_->publish_state(PanasonicDecode::getTextState(PanasonicDecode::Quietmode, PanasonicDecode::getBit3and4and5(bytes[7])));
|
||||
if (this->set2_select_) this->set2_select_->publish_state(PanasonicDecode::getTextState(PanasonicDecode::HolidayState, PanasonicDecode::getBit3and4(bytes[5])));
|
||||
if (this->set17_select_) this->set17_select_->publish_state(PanasonicDecode::getTextState(PanasonicDecode::ZonesState, PanasonicDecode::getBit1and2(bytes[6])));
|
||||
if (this->set26_select_) this->set26_select_->publish_state(PanasonicDecode::getTextState(PanasonicDecode::ExtPadHeaterType, PanasonicDecode::getBit3and4(bytes[25])));
|
||||
if (this->set35_select_) this->set35_select_->publish_state(PanasonicDecode::getTextState(PanasonicDecode::Bivalent, PanasonicDecode::getBit5and6(bytes[26])));
|
||||
#endif
|
||||
#ifdef USE_SWITCH
|
||||
if (this->set1_switch_) this->set1_switch_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit7and8(bytes[4])));
|
||||
if (this->set10_switch_) this->set10_switch_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit1and2(bytes[4])));
|
||||
if (this->set24_switch_) this->set24_switch_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit1and2(bytes[5])));
|
||||
if (this->set12_switch_) this->set12_switch_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit5and6(bytes[111])));
|
||||
if (this->set13_switch_) this->set13_switch_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit5and6(bytes[117])));
|
||||
if (this->set28_switch_) this->set28_switch_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit5and6(bytes[24])));
|
||||
if (this->set30_switch_) this->set30_switch_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit7and8(bytes[23])));
|
||||
if (this->set33_switch_) this->set33_switch_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit5and6(bytes[23])));
|
||||
if (this->set31_switch_) this->set31_switch_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit3and4(bytes[23])));
|
||||
if (this->set32_switch_) this->set32_switch_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit1and2(bytes[23])));
|
||||
if (this->set34_switch_) this->set34_switch_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit7and8(bytes[26])));
|
||||
#endif
|
||||
}
|
||||
|
||||
void PanasonicHeatpumpComponent::send_initial_message()
|
||||
{
|
||||
// send command
|
||||
this->uart_hp_->write_array(PanasonicCommand::InitialMessage, REQUEST_INIT_MSG_SIZE);
|
||||
this->write_array(PanasonicCommand::InitialMessage, REQUEST_INIT_MSG_SIZE);
|
||||
this->log_uart_hex(">>>", this->command_message_, ',');
|
||||
delay(100); // NOLINT
|
||||
}
|
||||
@@ -516,7 +584,7 @@ namespace esphome
|
||||
void PanasonicHeatpumpComponent::send_periodical_message()
|
||||
{
|
||||
// send command
|
||||
this->uart_hp_->write_array(PanasonicCommand::PeriodicalMessage, REQUEST_DATA_MSG_SIZE);
|
||||
this->write_array(PanasonicCommand::PeriodicalMessage, REQUEST_DATA_MSG_SIZE);
|
||||
this->log_uart_hex(">>>", this->command_message_, ',');
|
||||
delay(100); // NOLINT
|
||||
}
|
||||
@@ -536,7 +604,7 @@ namespace esphome
|
||||
// while (request_receiving_ == 1) { delay(1); }
|
||||
|
||||
// send command
|
||||
// this->uart_hp_->write_array(this->command_message_);
|
||||
// this->write_array(this->command_message_);
|
||||
this->log_uart_hex(">>>", this->command_message_, ',');
|
||||
delay(100); // NOLINT
|
||||
}
|
||||
@@ -582,7 +650,8 @@ namespace esphome
|
||||
#ifdef USE_SELECT
|
||||
void PanasonicHeatpumpComponent::select_control(select::Select* object, size_t value)
|
||||
{
|
||||
if (object == this->set3_select_) this->send_command_message(PanasonicCommand::setPlus1Multiply8(value), 7);
|
||||
if (object == this->set2_select_) this->send_command_message(PanasonicCommand::setPlus1Multiply16(value), 5);
|
||||
else if (object == this->set3_select_) this->send_command_message(PanasonicCommand::setPlus1Multiply8(value), 7);
|
||||
else if (object == this->set4_select_) this->send_command_message(PanasonicCommand::setPlus73(value), 7);
|
||||
else if (object == this->set9_select_) this->send_command_message(PanasonicCommand::setOperationMode(value), 6);
|
||||
else if (object == this->set17_select_) this->send_command_message(PanasonicCommand::setPlus1Multiply64(value), 6);
|
||||
@@ -594,7 +663,6 @@ namespace esphome
|
||||
void PanasonicHeatpumpComponent::switch_control(switch_::Switch* object, size_t value)
|
||||
{
|
||||
if (object == this->set1_switch_) this->send_command_message(PanasonicCommand::setPlus1(value), 4);
|
||||
else if (object == this->set2_switch_) this->send_command_message(PanasonicCommand::setPlus1Multiply16(value), 5);
|
||||
else if (object == this->set10_switch_) this->send_command_message(PanasonicCommand::setPlus1Multiply64(value), 4);
|
||||
else if (object == this->set12_switch_) this->send_command_message(PanasonicCommand::setMultiply2(value), 8);
|
||||
else if (object == this->set13_switch_) this->send_command_message(PanasonicCommand::setMultiply4(value), 8);
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace esphome
|
||||
{
|
||||
namespace panasonic_heatpump
|
||||
{
|
||||
class PanasonicHeatpumpComponent : public Component
|
||||
class PanasonicHeatpumpComponent : public Component, public uart::UARTDevice
|
||||
{
|
||||
public:
|
||||
// ToDo: Add template for custom sensor classes similar to SUB_SENSOR (see Pipsolar)
|
||||
@@ -219,6 +219,7 @@ namespace esphome
|
||||
void number_control(number::Number* object, float value);
|
||||
#endif
|
||||
#ifdef USE_SELECT
|
||||
SUB_SELECT(set2);
|
||||
SUB_SELECT(set3);
|
||||
SUB_SELECT(set4);
|
||||
SUB_SELECT(set9);
|
||||
@@ -230,7 +231,6 @@ namespace esphome
|
||||
#endif
|
||||
#ifdef USE_SWITCH
|
||||
SUB_SWITCH(set1);
|
||||
SUB_SWITCH(set2);
|
||||
SUB_SWITCH(set10);
|
||||
SUB_SWITCH(set12);
|
||||
SUB_SWITCH(set13);
|
||||
@@ -250,16 +250,19 @@ namespace esphome
|
||||
PanasonicHeatpumpComponent() = default;
|
||||
float get_setup_priority() const override { return setup_priority::LATE; }
|
||||
void dump_config() override;
|
||||
void setup() override;
|
||||
void loop() override;
|
||||
|
||||
void set_uart_hp(uart::UARTComponent *uart) { this->uart_hp_ = uart; }
|
||||
void set_uart_wm(uart::UARTComponent *uart) { this->uart_wm_ = uart; }
|
||||
//void set_uart_hp(uart::UARTComponent *uart) { this->uart_hp_ = uart; }
|
||||
//void set_uart_wm(uart::UARTComponent *uart) { this->uart_wm_ = uart; }
|
||||
void set_uart_client(uart::UARTComponent *uart) { this->uart_client_ = uart; }
|
||||
void set_log_uart_msg(bool enable) { this->log_uart_msg_ = enable; }
|
||||
void set_polling_time(uint32_t time_sec) { this->polling_time_ = time_sec; }
|
||||
|
||||
protected:
|
||||
uart::UARTComponent *uart_hp_;
|
||||
uart::UARTComponent *uart_wm_;
|
||||
//uart::UARTComponent* uart_hp_;
|
||||
//uart::UARTComponent* uart_wm_;
|
||||
uart::UARTComponent* uart_client_;
|
||||
bool log_uart_msg_{false};
|
||||
uint32_t polling_time_{1};
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ from esphome.const import (
|
||||
from .. import CONF_PANASONIC_HEATPUMP_ID, PanasonicHeatpumpComponent, panasonic_heatpump_ns
|
||||
|
||||
|
||||
CONF_SET2 = "set2" # Set Holiday Mode
|
||||
CONF_SET3 = "set3" # Set Quiet Mode
|
||||
CONF_SET4 = "set4" # Set Powerful Mode
|
||||
CONF_SET9 = "set9" # Set Operation Mode
|
||||
@@ -15,6 +16,7 @@ CONF_SET26 = "set26" # Set External PadHeater
|
||||
CONF_SET35 = "set35" # Set Bivalent Mode
|
||||
|
||||
TYPES = [
|
||||
CONF_SET2,
|
||||
CONF_SET3,
|
||||
CONF_SET4,
|
||||
CONF_SET9,
|
||||
@@ -24,12 +26,13 @@ TYPES = [
|
||||
]
|
||||
|
||||
CONF_SELECTS = [
|
||||
[ "Off mode", "Quiet mode 1", "Quiet mode 2", "Quiet mode 3", ],
|
||||
[ "Off", "Scheduled", "Active", ],
|
||||
[ "Off", "Level 1", "Level 2", "Level 3", ],
|
||||
[ "Off", "30min", "60min", "90min", ],
|
||||
[ "Heat only", "Cool only", "Auto", "DHW only", "Heat+DHW", "Cool+DHW", "Auto + DHW", ],
|
||||
[ "Zone 1", "Zone2", "Zone1 and Zone2", ],
|
||||
[ "Heat only", "Cool only", "Auto", "Auto(heat)", "Auto(cool)", "DHW only", "Heat+DHW", "Cool+DHW", "Auto+DHW", "Auto(heat)+DHW", "Auto(cool)+DHW", ],
|
||||
[ "Zone 1", "Zone 2", "Zone 1 & 2", ],
|
||||
[ "Disabled", "Type-A", "Type-B" ],
|
||||
[ "Alternativ", "Parallel", "Advanced Parallel" ],
|
||||
[ "Alternative", "Parallel", "Advanced Parallel" ],
|
||||
]
|
||||
|
||||
PanasonicHeatpumpSelect = panasonic_heatpump_ns.class_("PanasonicHeatpumpSelect", select.Select)
|
||||
@@ -38,29 +41,26 @@ CONFIG_SCHEMA = cv.Schema(
|
||||
{
|
||||
cv.GenerateID(CONF_PANASONIC_HEATPUMP_ID): cv.use_id(PanasonicHeatpumpComponent),
|
||||
|
||||
cv.Optional(CONF_SET2): select.select_schema(
|
||||
PanasonicHeatpumpSelect,
|
||||
),
|
||||
cv.Optional(CONF_SET3): select.select_schema(
|
||||
PanasonicHeatpumpSelect,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET4): select.select_schema(
|
||||
PanasonicHeatpumpSelect,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET9): select.select_schema(
|
||||
PanasonicHeatpumpSelect,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET17): select.select_schema(
|
||||
PanasonicHeatpumpSelect,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET26): select.select_schema(
|
||||
PanasonicHeatpumpSelect,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET35): select.select_schema(
|
||||
PanasonicHeatpumpSelect,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
@@ -8,7 +8,6 @@ from .. import CONF_PANASONIC_HEATPUMP_ID, PanasonicHeatpumpComponent, panasonic
|
||||
|
||||
|
||||
CONF_SET1 = "set1" # Set Heatpump
|
||||
CONF_SET2 = "set2" # Set Holiday Mode
|
||||
CONF_SET10 = "set10" # Set Force DHW
|
||||
CONF_SET12 = "set12" # Set Force Defrost
|
||||
CONF_SET13 = "set13" # Set Force Sterilization
|
||||
@@ -24,7 +23,6 @@ CONF_SET34 = "set34" # Set Bivalent Control
|
||||
|
||||
TYPES = [
|
||||
CONF_SET1,
|
||||
CONF_SET2,
|
||||
CONF_SET10,
|
||||
CONF_SET12,
|
||||
CONF_SET13,
|
||||
@@ -47,59 +45,42 @@ CONFIG_SCHEMA = cv.Schema(
|
||||
|
||||
cv.Optional(CONF_SET1): switch.switch_schema(
|
||||
PanasonicHeatpumpSwitch,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET2): switch.switch_schema(
|
||||
PanasonicHeatpumpSwitch,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET10): switch.switch_schema(
|
||||
PanasonicHeatpumpSwitch,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET12): switch.switch_schema(
|
||||
PanasonicHeatpumpSwitch,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET13): switch.switch_schema(
|
||||
PanasonicHeatpumpSwitch,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET14): switch.switch_schema(
|
||||
PanasonicHeatpumpSwitch,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET24): switch.switch_schema(
|
||||
PanasonicHeatpumpSwitch,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET25): switch.switch_schema(
|
||||
PanasonicHeatpumpSwitch,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET28): switch.switch_schema(
|
||||
PanasonicHeatpumpSwitch,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET30): switch.switch_schema(
|
||||
PanasonicHeatpumpSwitch,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET31): switch.switch_schema(
|
||||
PanasonicHeatpumpSwitch,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET32): switch.switch_schema(
|
||||
PanasonicHeatpumpSwitch,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET33): switch.switch_schema(
|
||||
PanasonicHeatpumpSwitch,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_SET34): switch.switch_schema(
|
||||
PanasonicHeatpumpSwitch,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user