Fix AUTO (HEAT_COOL) mode: many ACs can change target T in this mode.

This commit is contained in:
GrKoR
2022-06-08 23:46:02 +03:00
parent 0500eae87b
commit 62615cae34
2 changed files with 36 additions and 57 deletions

View File

@@ -2089,7 +2089,7 @@ class AirCon : public esphome::Component, public esphome::climate::Climate {
/*************************** MUTE FAN MODE ***************************/
// MUTE работает в режиме FAN. В режимах HEAT, COOL, HEAT_COOL не работает. DRY не проверял.
// TODO: проверку на это несовместимые режимы пока выпилили, т.к. нет уверенности, что это поведение одинаково для всех
// TODO: проверку на несовместимые режимы пока выпилили, т.к. нет уверенности, что это поведение одинаково для всех
switch (_current_ac_state.fanMute) {
case AC_FANMUTE_ON:
//if (_current_ac_state.mode == AC_MODE_FAN) {
@@ -2208,8 +2208,15 @@ class AirCon : public esphome::Component, public esphome::climate::Climate {
if(_current_ac_state.mode == AC_MODE_FAN || _current_ac_state.power == AC_POWER_OFF){
// в режиме вентилятора и в выключенном состоянии будем показывать текущую температуру
this->target_temperature = _current_ac_state.temp_ambient;
/*
* принудительная установка целевой температуры для режима AUTO (HEAT_COOL) осознанно выпилена.
* как выяснилось, многие сплиты умеют задавать целевую температуру в этом режиме
* но не все. Кто не умеет, возвращает правильную температуру после установки режима.
* Так что проверка в коде не требуется
*/ /*
} else if (_current_ac_state.mode == AC_MODE_AUTO ){
this->target_temperature = 25; // в AUTO зашита температура 25 градусов
*/
} else {
this->target_temperature = _current_ac_state.temp_target;
}
@@ -2501,9 +2508,11 @@ class AirCon : public esphome::Component, public esphome::climate::Climate {
load_preset(&cmd, POS_MODE_AUTO);
#endif
/* принудительная установка температуры в этом режиме осознанно выпилена
cmd.temp_target = 25; // зависимость от режима HEAT_COOL
cmd.temp_target_matter = true;
cmd.fanTurbo = AC_FANTURBO_OFF; // зависимость от режима HEAT_COOL
*/
this->mode = mode;
break;

View File

@@ -21,8 +21,6 @@ def createParser ():
parent_group.add_argument ('--help', '-h', action='help', help='show this help message and exit')
parent_group.add_argument ('-i', '--ip', nargs=1, required=True, help='IP address of the esphome device')
parent_group.add_argument ('-p', '--pwd', nargs=1, required=True, help='native API password for the esphome device')
parent_group.add_argument ('-n', '--name', nargs=1, default=['noname'], help='name of this devace in the log')
parent_group.add_argument ('-l', '--logfile', nargs=1, default=['%4d-%02d-%02d %02d-%02d-%02d log.csv' % time.localtime()[0:6]], help='log file name')
return parser
async def main():
@@ -36,51 +34,6 @@ async def main():
print(api.api_version)
def log_AC(isAirConLog):
parts = re.search("(\d{10}): (\[\S{2}\]) \[([0-9A-F ]{23})\]\s?((?:[0-9A-F]{2}\s*)*) \[([0-9A-F ]{5})\]", isAirConLog.group(1))
packString = '\n' + namespace.name[0]
packString += ";" + "%4d-%02d-%02d %02d:%02d:%02d" % time.localtime()[0:6]
"""millis of message"""
packString += ";" + parts.group(1)
"""direction"""
packString += ";" + parts.group(2)
"""header"""
packString += ";" + ';'.join(parts.group(3).split(" "))
"""body (may be void)"""
if len(parts.group(4)) > 0:
packString += ";" + ';'.join(parts.group(4).split(" "))
"""crc"""
packString += ";" + ';'.join(parts.group(5).split(" "))
print(packString)
with open(namespace.logfile[0], 'a+') as file:
file.write( packString )
def log_Dallas(isDallasLog):
parts = re.search("'([\w ]+)': Got Temperature=([-]?\d+\.\d+)°C", isDallasLog.group(1))
packString = '\n' + parts.group(1)
packString += ";" + "%4d-%02d-%02d %02d:%02d:%02d" % time.localtime()[0:6]
"""millis of message always empty"""
packString += ";"
"""direction"""
packString += ";[<=]"
"""additional data flag"""
packString += ";AA"
"""dallas temperature"""
packString += ";" + parts.group(2)
print(packString)
with open(namespace.logfile[0], 'a+') as file:
file.write( packString )
def log_callback(log):
"""Print the log for AirCon"""
isAirConLog = re.search("\[AirCon:\d+\]: (.+\])", log.message.decode('utf-8'))
if isAirConLog:
log_AC(isAirConLog)
if namespace.logdallas:
isDallasLog = re.search("\[dallas.sensor:\d+\]: (.+C)", log.message.decode('utf-8'))
if isDallasLog:
log_Dallas(isDallasLog)
async def display_off():
await api.execute_service(
service,
@@ -104,7 +57,7 @@ async def main():
service,
data={
# 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
"data_buf": [0xBB, 0x00, 0x06, 0x80, 0x00, 0x00, 0x0F, 0x00, 0x01, 0x01, 0x97, 0xE0, 0x19, 0x60, 0x00, 0xC0, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00],
"data_buf": [0xBB, 0x00, 0x06, 0x80, 0x00, 0x00, 0x0F, 0x00, 0x01, 0x00, 0x87, 0xE0, 0x2F, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00],
}
)
@@ -113,7 +66,25 @@ async def main():
service,
data={
# 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
"data_buf": [0xBB, 0x00, 0x06, 0x80, 0x00, 0x00, 0x0F, 0x00, 0x01, 0x01, 0x97, 0xE0, 0x19, 0x60, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
"data_buf": [0xBB, 0x00, 0x06, 0x80, 0x00, 0x00, 0x0F, 0x00, 0x01, 0x00, 0x87, 0xE0, 0x2F, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
}
)
async def ac_get11_01():
await api.execute_service(
service,
data={
# 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
"data_buf": [0xBB, 0x00, 0x06, 0x80, 0x00, 0x00, 0x02, 0x00, 0x11, 0x01],
}
)
async def ac_get11_00():
await api.execute_service(
service,
data={
# 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
"data_buf": [0xBB, 0x00, 0x06, 0x80, 0x00, 0x00, 0x02, 0x00, 0x11, 0x00],
}
)
@@ -135,12 +106,6 @@ async def main():
}
)
# Subscribe to the log
# await api.subscribe_logs(log_callback, LOG_LEVEL_DEBUG)
# print(await api.device_info())
# print(f"%s" % (await api.list_entities_services(),))
# key надо искать в выводе list_entities_services
service = aioesphomeapi.UserService(
name="send_data",
@@ -150,6 +115,11 @@ async def main():
],
)
time.sleep(7)
await ac_get11_00()
time.sleep(7)
await ac_get11_01()
#await ac_set_vlouver( 0b10010000 ) # swing on
#await ac_set_vlouver( 0b10010111 ) # swing off
#await ac_set_vlouver( 0b10010001 ) # 1
@@ -204,7 +174,7 @@ async def main():
parser = createParser()
namespace = parser.parse_args()
print(namespace.name[0], namespace.ip[0])
print("IP: ", namespace.ip[0])
loop = asyncio.get_event_loop()