sHedC / python-masterthermconnect

MasterTherm HeatPump API
MIT License
3 stars 2 forks source link

Add more Operating Modes #75

Closed sHedC closed 1 year ago

sHedC commented 1 year ago

Is your feature request related to a problem? Please describe. Operating Modes follow the one from the Web UI, however could add more such as Off (heat pump totally off), Idle (on but nothing happening)

Maybe some other modes

SeBsZ commented 1 year ago

This would be good as right now it will say 'heating' even though it should really be 'idle' if the compressor is off. Agree?

sHedC commented 1 year ago

Current Logic:

operating_mode = "heating"
if data["domestic_hot_water"]["heating"]:
    operating_mode = "dhw"
elif data["heating_circuits"]["pool"]["heating"]:
    operating_mode = "pool"
else:
    error_info = data["error_info"]
    if (
        error_info["some_error"]
        or error_info["three_errors"]
        or not data["aux_heater_1"]
        ):
        if data["cooling_mode"]:
            if data["dewp_control"]:
                operating_mode = "dpc"
            else:
                operating_mode = "cooling"

Additional should be

Just re-work the error, for some reason the current logic looks for errors before checking for cooling, weird. some_error is one of the many errors has occured and three_errors is three or more errors have occured and a reset is required.

sHedC commented 1 year ago

Noticed that I am ignoring errors for the v1 heatpump if the API returns that its online but the HP returns unavailable, it didn't show up because I had the raise exception in a try section.

{
  'timestamp': 1676310470,
  'error': {
    'errorMessage': 'Actual data for some variables are not available.',
    'errorId': 9
  },
  'messageId': 2,
  'data': {}
}
sHedC commented 1 year ago

It is a bit confusing the logic but in both the old and new Web UI's it seems that the priority is:

So I think the logic would be as follows that if the pump is offline then just override the operating mode to offline:

Otherwise follow operating mode as:

if domestic_hot_water.heating:
    "dhw"
elif heating_circuits.pool.heating:
    "pool"
elif not (error_info.some_errors or error_info.three_errors) and (aux_heater_1 or aux_heater_2):
    "aux_heater"
elif dewp_control:
    "dpc"
elif cooling_mode:
    "cooling"
elif (compressor_running or compressor2_running or circulation_pump_running or fan_running):
    "heating"
else
    "idle"

This seems to follow the same logic and add in aux_heater and idle as an option.

sHedC commented 1 year ago

Updated some error reporting as well to align with pump data issues.

sHedC commented 1 year ago

Ready for next release 2.1.0.