New feature for MiElHVAC (#22290)

* Add prohibit function for MiElHVAC

Add Prohibit functions:
* Power
* Temperature
* Mode
 and all combinations of this functions
Updated VaneV names for better identify

* Fixed Compressor and Operation for MiElHVAC

Changed Widevane position name from ISEE to AUTO sam as in MELCLoud

* Revert "Fixed Compressor and Operation for MiElHVAC"

This reverts commit f0973c84d4.

* New feature for MiElHVAC

* Added Compressor map
* Added Operation Power in Watts
* Added Operation Energy in kWh
* Changed Widevane position name from ISEE to AUTO, displays sam as in
* Changed all map value to lover case MELCloud
This commit is contained in:
Grzegorz 2024-10-14 23:09:47 +02:00 committed by GitHub
parent 8a9bf94e58
commit 6a7f8b11ed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 60 additions and 14 deletions

View File

@ -91,8 +91,14 @@ struct miel_hvac_data_roomtemp {
struct miel_hvac_data_status { struct miel_hvac_data_status {
uint8_t _pad1[2]; uint8_t _pad1[2];
uint8_t _pad2[1];
uint8_t compressor; uint8_t compressor;
uint8_t operation; #define MIEL_HVAC_STATUS_COMPRESSOR_OFF 0x00
#define MIEL_HVAC_STATUS_COMPRESSOR_ON 0x01
uint8_t operationpower;
uint8_t operationpower1;
uint8_t operationenergy;
uint8_t operationenergy1;
}; };
struct miel_hvac_data { struct miel_hvac_data {
@ -130,6 +136,12 @@ CTASSERT(offsetof(struct miel_hvac_data, data.settings.airdirection) == 14);
CTASSERT(offsetof(struct miel_hvac_data, data.roomtemp.temp) == 3); CTASSERT(offsetof(struct miel_hvac_data, data.roomtemp.temp) == 3);
CTASSERT(offsetof(struct miel_hvac_data, data.roomtemp.temp05) == 6); CTASSERT(offsetof(struct miel_hvac_data, data.roomtemp.temp05) == 6);
CTASSERT(offsetof(struct miel_hvac_data, data.status.compressor) == 4);
CTASSERT(offsetof(struct miel_hvac_data, data.status.operationpower) == 5);
CTASSERT(offsetof(struct miel_hvac_data, data.status.operationpower1) == 6);
CTASSERT(offsetof(struct miel_hvac_data, data.status.operationenergy) == 7);
CTASSERT(offsetof(struct miel_hvac_data, data.status.operationenergy1) == 8);
/* to hvac */ /* to hvac */
#define MIEL_HVAC_H_TYPE_CONNECT 0x5a #define MIEL_HVAC_H_TYPE_CONNECT 0x5a
@ -206,7 +218,7 @@ struct miel_hvac_msg_update {
uint8_t _pad1[4]; uint8_t _pad1[4];
uint8_t widevane; uint8_t widevane;
#define MIEL_HVAC_UPDATE_WIDEVANE_MASK 0x0f #define MIEL_HVAC_UPDATE_WIDEVANE_MASK 0x0f
#define MIEL_HVAC_UPDATE_WIDEVANE_ISEE 0x00 #define MIEL_HVAC_UPDATE_WIDEVANE_AUTO 0x00
#define MIEL_HVAC_UPDATE_WIDEVANE_LL 0x01 #define MIEL_HVAC_UPDATE_WIDEVANE_LL 0x01
#define MIEL_HVAC_UPDATE_WIDEVANE_L 0x02 #define MIEL_HVAC_UPDATE_WIDEVANE_L 0x02
#define MIEL_HVAC_UPDATE_WIDEVANE_C 0x03 #define MIEL_HVAC_UPDATE_WIDEVANE_C 0x03
@ -304,6 +316,11 @@ struct miel_hvac_map {
const char *name; const char *name;
}; };
static const struct miel_hvac_map miel_hvac_power_map[] = {
{ MIEL_HVAC_UPDATE_POWER_OFF, "off" },
{ MIEL_HVAC_UPDATE_POWER_ON, "on" },
};
static const struct miel_hvac_map miel_hvac_mode_map[] = { static const struct miel_hvac_map miel_hvac_mode_map[] = {
{ MIEL_HVAC_UPDATE_MODE_HEAT, "heat" }, { MIEL_HVAC_UPDATE_MODE_HEAT, "heat" },
{ MIEL_HVAC_UPDATE_MODE_DRY, "dry" }, { MIEL_HVAC_UPDATE_MODE_DRY, "dry" },
@ -335,7 +352,7 @@ static const struct miel_hvac_map miel_hvac_vane_map[] = {
}; };
static const struct miel_hvac_map miel_hvac_widevane_map[] = { static const struct miel_hvac_map miel_hvac_widevane_map[] = {
{ MIEL_HVAC_UPDATE_WIDEVANE_ISEE, "isee" }, { MIEL_HVAC_UPDATE_WIDEVANE_AUTO, "auto" },
{ MIEL_HVAC_UPDATE_WIDEVANE_LL, "left" }, { MIEL_HVAC_UPDATE_WIDEVANE_LL, "left" },
{ MIEL_HVAC_UPDATE_WIDEVANE_L, "left_middle" }, { MIEL_HVAC_UPDATE_WIDEVANE_L, "left_middle" },
{ MIEL_HVAC_UPDATE_WIDEVANE_C, "center" }, { MIEL_HVAC_UPDATE_WIDEVANE_C, "center" },
@ -362,6 +379,11 @@ static const struct miel_hvac_map miel_hvac_airdirection_map[] = {
{ MIEL_HVAC_UPDATE_AIRDIRECTION_DIRECT, "direct" }, { MIEL_HVAC_UPDATE_AIRDIRECTION_DIRECT, "direct" },
}; };
static const struct miel_hvac_map miel_hvac_compressor_map[] = {
{ MIEL_HVAC_STATUS_COMPRESSOR_OFF, "off" },
{ MIEL_HVAC_STATUS_COMPRESSOR_ON, "on" },
};
enum miel_hvac_parser_state { enum miel_hvac_parser_state {
MIEL_HVAC_P_START, MIEL_HVAC_P_START,
MIEL_HVAC_P_TYPE, MIEL_HVAC_P_TYPE,
@ -997,8 +1019,12 @@ miel_hvac_publish_settings(struct miel_hvac_softc *sc)
const char *name; const char *name;
const char *name_swing_h; const char *name_swing_h;
Response_P(PSTR("{\"" D_JSON_IRHVAC_POWER "\":\"%s\""), name = miel_hvac_map_byval(set->power,
set->power ? "ON" : "OFF"); miel_hvac_power_map, nitems(miel_hvac_power_map));
if (name != NULL) {
Response_P(PSTR("{\"" D_JSON_IRHVAC_POWER "\":\"%s\""),
name);
}
name = miel_hvac_map_byval( set->mode & name = miel_hvac_map_byval( set->mode &
MIEL_HVAC_SETTINGS_MODE_MASK, MIEL_HVAC_SETTINGS_MODE_MASK,
@ -1046,7 +1072,7 @@ miel_hvac_publish_settings(struct miel_hvac_softc *sc)
miel_hvac_airdirection_map, nitems(miel_hvac_airdirection_map)); miel_hvac_airdirection_map, nitems(miel_hvac_airdirection_map));
if (name != NULL) { if (name != NULL) {
ResponseAppend_P(PSTR(",\"AirDirection\":\"%s\""), ResponseAppend_P(PSTR(",\"AirDirection\":\"%s\""),
name_swing_h == "isee" ? name : "OFF"); name_swing_h == "auto" ? name : "OFF");
} }
name = miel_hvac_map_byval(set->prohibit, name = miel_hvac_map_byval(set->prohibit,
@ -1236,8 +1262,13 @@ miel_hvac_sensor(struct miel_hvac_softc *sc)
const char *name_swing_h; const char *name_swing_h;
ResponseAppend_P(PSTR("," "\"MiElHVAC\":{")); ResponseAppend_P(PSTR("," "\"MiElHVAC\":{"));
ResponseAppend_P(PSTR("\"Power\":\"%s\""),
set->power ? "ON" : "OFF"); name = miel_hvac_map_byval(set->power,
miel_hvac_power_map, nitems(miel_hvac_power_map));
if (name != NULL) {
ResponseAppend_P(PSTR("\"Power\":\"%s\""),
name);
}
name = miel_hvac_map_byval( set->mode & name = miel_hvac_map_byval( set->mode &
MIEL_HVAC_SETTINGS_MODE_MASK, MIEL_HVAC_SETTINGS_MODE_MASK,
@ -1283,7 +1314,7 @@ miel_hvac_sensor(struct miel_hvac_softc *sc)
miel_hvac_airdirection_map, nitems(miel_hvac_airdirection_map)); miel_hvac_airdirection_map, nitems(miel_hvac_airdirection_map));
if (name != NULL) { if (name != NULL) {
ResponseAppend_P(PSTR(",\"AirDirection\":\"%s\""), ResponseAppend_P(PSTR(",\"AirDirection\":\"%s\""),
name_swing_h == "isee" ? name : "OFF"); name_swing_h == "auto" ? name : "off");
} }
name = miel_hvac_map_byval(set->prohibit, name = miel_hvac_map_byval(set->prohibit,
@ -1317,13 +1348,28 @@ miel_hvac_sensor(struct miel_hvac_softc *sc)
} }
if (sc->sc_status.type != 0) { if (sc->sc_status.type != 0) {
const struct miel_hvac_data_status *s = const struct miel_hvac_data_status *status =
&sc->sc_status.data.status; &sc->sc_status.data.status;
ResponseAppend_P(PSTR(",\"Operation\":\"%s\""), name = miel_hvac_map_byval(status->compressor,
s->operation ? "ON" : "OFF"); miel_hvac_compressor_map, nitems(miel_hvac_compressor_map));
ResponseAppend_P(PSTR(",\"Compressor\":\"%s\""), if (name != NULL) {
s->compressor ? "ON" : "OFF"); ResponseAppend_P(PSTR(",\"Compressor\":\"%s\""),
name);
}
uint16_t combined_power = ((uint16_t)status->operationpower << 8) | (uint16_t)status->operationpower1;
char operationpower[33];
dtostrfd((float)combined_power, 0, operationpower);
ResponseAppend_P(PSTR(",\"OperationPower\":\"%s\""),
operationpower);
uint16_t combined_energy = ((uint16_t)status->operationenergy << 8) | (uint16_t)status->operationenergy1;
float operationenergy_in_kWh = (float)combined_energy / 10.0;
char operationenergy[33];
dtostrfd((float)operationenergy_in_kWh, 1, operationenergy);
ResponseAppend_P(PSTR(",\"OperationEnergy\":\"%s\""),
operationenergy);
} }
if (sc->sc_temp.type != 0) { if (sc->sc_temp.type != 0) {