andrewleech / ha_magiqtouch

Home Assistant (HACS) integration to control Seeley MagiQtouch heating and cooling units.
MIT License
24 stars 6 forks source link

Control functions have stopped responding to input #19

Open Dazzzwaa opened 9 months ago

Dazzzwaa commented 9 months ago

Hi, last week i have noticed the integration has stopped responding to input the magiqtouch display wont update to the value i set in Home assistant, however if i set it on magiqtouch controll it will update on Home assistant image image

see below information from the log This error originated from a custom integration.

Logger: magiqtouch Source: custom_components/magiqtouch/magiqtouch.py:274 Integration: Seeley MagIQtouch (documentation, issues) First occurred: 8:40:15 PM (3 occurrences) Last logged: 8:51:34 PM

Failed to set value properly:

andrewleech commented 8 months ago

Hi @TheOriginalMrWolf yes zone support is very much still in progress, most of the last week or two's discussions have been around this. I don't have any zones myself so it's a bit of a guessing game informed by user's logs.

I haven't seen a system with add on cooler either, so logs with that turned on/off and any other related settings would be helpful.

In hacs make sure you select installing pre-release version, they select hacs instead of a version number.

Then in the integration settings, under magiqtouch there's a configure button that lets you turn on verbose logging.

The system logs will have extra entries for this then.

I'm not sure if there a better way to get diagnostic logs for just the integration.

TheOriginalMrWolf commented 8 months ago

Hi @andrewleech,

Cool. Latest hacs pre-release installed (https://github.com/andrewleech/ha_magiqtouch/commit/d1e6870e0ad7ebd2efe9fcf7e2f20877d522159b).

Two log files attached.

The first contains log extracts with annotations showing what was done & the resulting output; the second is just the raw log.

Hope that helps! Commented log extracts.txt Full log.log

epetousis commented 8 months ago

@andrewleech I haven't reviewed any code yet but the support seems solid so far, working fine with my setup. There seems to be a massive delay in starting though, it looks like something (maybe the web socket server?) is blocking during HA startup.

andrewleech commented 8 months ago

@epetousis oh interesting, i thought you'd be needing this zone stuff to work for your setup :-)

At the moment I'm blocking until the initial state response comes down the websocket to use this data in setting up the correct number and names for the entities. Occasionally on my ha I get log warnings saying "something in blocking startup" though I thought I had that fixed / streamlined in the more recent commits and hadn't seen the error in a little while.

AschwinGehlen commented 8 months ago

@andrewleech do you need some more logs from my setup?

If so, is the laters hacs version d1e6870? I can do some more testing today if you need the logs.

I did run a quick test on that version and still have the same issue where the controllers won’t turn off. Can turn the heater on and change the heat settings and change it to fan mode but can’t change the fan settings.

One thing I did notice is that the controller does flash the controller zone name when it receives a command from HA. Eg, trying to turn the heater off in HA and the zone name flashes but then the controller does nothing.

andrewleech commented 8 months ago

@AschwinGehlen thanks but I don't think I need more logs just yet, need to fix the device selection logic first.

For your zones, I see they're all "individual" type? Does this mean they can ask have different fan speeds/ temperature settings?

@TheOriginalMrWolf thanks those logs help a lot, though I'm missing the "system state" details. This is logged once at ha startup, or by toggling the integration verbose setting on and off.

Similarly with your zones being individual, do you have a different setting for heater_fan vs cooler_fan? I would assume not?

Oh and question for both, can you have one zone heating and another zone cooling? If so can I get a log of this?

andrewleech commented 8 months ago

Actually I've just fixed a bunch of these little things in 982249a just pushed, a couple of logs / tests of this would help.

Hopefully turning off might work now? Still not sure about all the zone logic though.

epetousis commented 8 months ago

@epetousis oh interesting, i thought you'd be needing this zone stuff to work for your setup :-)

At the moment I'm blocking until the initial state response comes down the websocket to use this data in setting up the correct number and names for the entities. Occasionally on my ha I get log warnings saying "something in blocking startup" though I thought I had that fixed / streamlined in the more recent commits and hadn't seen the error in a little while.

Oh I assumed the zone stuff was implemented!? I am using the latest hacs branch HEAD, and it seems to be working a treat.

Understood about the initial state response related block, seems like an insanely slow response from Seeley’s API though…the only reason why my setup works (eventually) is because eventually Home Assistant ignores the thread block and continues on.

TheOriginalMrWolf commented 8 months ago

Hi @andrewleech

This integration is blocking HAss startup for a loooong time - preventing things like HomeKit etc from starting. Is there a way to fix this as it's causing issues with a few of my other integrations?

On startup:

2024-03-24 12:17:25.764 WARNING (SyncWorker_2) [homeassistant.loader] We found a custom integration magiqtouch which has not been tested by Home Assistant.
...
2024-03-24 12:17:56.464 WARNING (MainThread) [magiqtouch] Logged in
...
2024-03-24 12:23:22.194 WARNING (MainThread) [homeassistant.bootstrap] Setup timed out for bootstrap - moving forward
2024-03-24 12:23:37.197 WARNING (MainThread) [homeassistant.core] Something is blocking Home Assistant from wrapping up the start up phase. We're going to continue anyway. Please report the following info

though I'm missing the "system state" details

Here is the current system state after updating to your latest hacs version just now:

{
  "ACZones": {
    "Manual": false,
    "SlaveWallControls": true,
    "Zones": [
      {
        "Name": "Family Room",
        "Type": "MASTER",
        "CoolerCompatible": false,
        "HeaterCompatible": true
      }
    ]
  },
  "AOCFixed": {
    "InSystem": false,
    "MaximumTemperature": 28,
    "MinimumTemperature": 19
  },
  "AOCInverter": {
    "MaximumTemperature": 28,
    "MinimumTemperature": 19,
    "InSystem": true
  },
  "Cabinets": [],
  "EVAPCooler": {
    "Brands": 0,
    "HumidityControl": false,
    "MaximumTemperature": 28,
    "MinimumTemperature": 19,
    "TemperatureUnits": 0
  },
  "WallController": {
    "Firmware": "44R0920",
    "Type": 0
  },
  "Heater": {
    "InSystem": true,
    "FixedFan": false,
    "Brands": 0,
    "DataTableVersion": "D0.0",
    "ICSSoftwareRev": "D0.0",
    "MaxSetFanSpeed": 10,
    "MaximumTemperature": 23,
    "MinimumTemperature": 0,
    "ModelNo": "TQS6X32N",
    "SerialNo": 1043234
  },
  "MasterAirSensorPresent": false,
  "SlaveWallControls": 0,
  "NoOfZoneControls": 2,
  "System": {
    "configuration": 3,
    "cooler": {
      "available": true,
      "fanFixed": false
    },
    "heater": {
      "available": true,
      "fanFixed": false
    },
    "fan": {
      "available": true,
      "fanFixed": false
    },
    "Address": "<redacted>",
    "Name": "<redacted>"
  },
  "Wifi_Module": {
    "MacAddressId": "<redacted>",
    "version": "1.7",
    "type": "WI-FI IoT Device"
  },
  "ExternalAirSensorPresent": false,
  "DamperDelayModulePresent": false,
  "BMSS1": false,
  "BMSMS1": false,
  "ZoneAirSensors": 4
}

I believe that the Zones array only has one object (Family Room) because the system only has one zone controller, located in the family room, and the other zones only have air temp sensors & are controlled via the family room controller or via the app.

do you have a different setting for heater_fan vs cooler_fan?

User can't change fan speeds in heating or cooling mode. Each zone is given a fan speed to run at for each of heat & cool functions in system configuration. Controller then simply adds up the speeds for all the currently running zones and ramps the fan up/down to that total.

can you have one zone heating and another zone cooling?

Not on my system. Whole system is in either heat, cool, or fan mode.

Looking at current state you can see the "runningMode" key at head of object.

{
  "device": "90e202cadd0c",
  "timestamp": 1711243427789,
  "online": true,
  "systemOn": false,
  "runningMode": "COOL",
  "heaterFault": false,
  "coolerFault": false,
  "cooler": [
    {
      "brand": 3,
      "name": "Family Room",
      "runningState": "NOT_REQUIRED",
      "zoneRunningState": "NOT_REQUIRED",
      "zoneOn": false,
      "zoneType": "INDIVIDUAL",
      "set_temp": 22,
      "temperature_units": "c",
      "actual_temp": 23,
      "max_temp": 28,
      "min_temp": 19,
      "fan_speed": 1,
      "max_fan_speed": 10,
      "min_fan_speed": 1,
      "control_mode": null,
      "control_mode_type": "NONE",
      "internal_temp": 23,
      "external_temp": null,
      "programMode": "off",
      "ProgramModeOverridden": false,
      "ProgramPeriodActive": false,
      "programOverrideDisabled": false
    },
    {
      "brand": 3,
      "name": "Lounge / Dining",
      "runningState": "NOT_REQUIRED",
      "zoneRunningState": "NOT_REQUIRED",
      "zoneOn": false,
      "zoneType": "INDIVIDUAL",
      "set_temp": 22,
      "temperature_units": "c",
      "actual_temp": 25,
      "max_temp": 28,
      "min_temp": 19,
      "fan_speed": 1,
      "max_fan_speed": 10,
      "min_fan_speed": 1,
      "control_mode": null,
      "control_mode_type": "NONE",
      "internal_temp": 25,
      "external_temp": null,
      "programMode": "off",
      "ProgramModeOverridden": false,
      "ProgramPeriodActive": false,
      "programOverrideDisabled": false
    },
    {
      "brand": 3,
      "name": "Master Bedroom",
      "runningState": "NOT_REQUIRED",
      "zoneRunningState": "NOT_REQUIRED",
      "zoneOn": false,
      "zoneType": "INDIVIDUAL",
      "set_temp": 23,
      "temperature_units": "c",
      "actual_temp": 24,
      "max_temp": 28,
      "min_temp": 19,
      "fan_speed": 1,
      "max_fan_speed": 10,
      "min_fan_speed": 1,
      "control_mode": null,
      "control_mode_type": "NONE",
      "internal_temp": 24,
      "external_temp": null,
      "programMode": "off",
      "ProgramModeOverridden": false,
      "ProgramPeriodActive": false,
      "programOverrideDisabled": false
    },
    {
      "brand": 3,
      "name": "Spare Room",
      "runningState": "NOT_REQUIRED",
      "zoneRunningState": "NOT_REQUIRED",
      "zoneOn": false,
      "zoneType": "INDIVIDUAL",
      "set_temp": 21,
      "temperature_units": "c",
      "actual_temp": 24,
      "max_temp": 28,
      "min_temp": 19,
      "fan_speed": 1,
      "max_fan_speed": 10,
      "min_fan_speed": 1,
      "control_mode": null,
      "control_mode_type": "NONE",
      "internal_temp": 24,
      "external_temp": null,
      "programMode": "off",
      "ProgramModeOverridden": false,
      "ProgramPeriodActive": false,
      "programOverrideDisabled": false
    },
    {
      "brand": 3,
      "name": "Mishy Bedroom",
      "runningState": "NOT_REQUIRED",
      "zoneRunningState": "NOT_REQUIRED",
      "zoneOn": false,
      "zoneType": "INDIVIDUAL",
      "set_temp": 23,
      "temperature_units": "c",
      "actual_temp": 24,
      "max_temp": 28,
      "min_temp": 19,
      "fan_speed": 1,
      "max_fan_speed": 10,
      "min_fan_speed": 1,
      "control_mode": null,
      "control_mode_type": "NONE",
      "internal_temp": 24,
      "external_temp": null,
      "programMode": "off",
      "ProgramModeOverridden": false,
      "ProgramPeriodActive": false,
      "programOverrideDisabled": false
    }
  ],
  "heater": [
    {
      "brand": 3,
      "name": "Family Room",
      "runningState": "NOT_REQUIRED",
      "zoneRunningState": "NOT_REQUIRED",
      "zoneOn": false,
      "zoneType": "INDIVIDUAL",
      "set_temp": 22,
      "temperature_units": "c",
      "actual_temp": 23,
      "max_temp": 23,
      "min_temp": 0,
      "fan_speed": 1,
      "max_fan_speed": 10,
      "min_fan_speed": 1,
      "control_mode": "TEMP",
      "control_mode_type": "NONE",
      "internal_temp": 23,
      "external_temp": null,
      "programMode": "off",
      "ProgramModeOverridden": false,
      "ProgramPeriodActive": false,
      "programOverrideDisabled": true
    },
    {
      "brand": 3,
      "name": "Lounge / Dining",
      "runningState": "NOT_REQUIRED",
      "zoneRunningState": "NOT_REQUIRED",
      "zoneOn": false,
      "zoneType": "INDIVIDUAL",
      "set_temp": 22,
      "temperature_units": "c",
      "actual_temp": 25,
      "max_temp": 23,
      "min_temp": 0,
      "fan_speed": 1,
      "max_fan_speed": 10,
      "min_fan_speed": 1,
      "control_mode": "TEMP",
      "control_mode_type": "NONE",
      "internal_temp": 25,
      "external_temp": null,
      "programMode": "off",
      "ProgramModeOverridden": false,
      "ProgramPeriodActive": false,
      "programOverrideDisabled": true
    },
    {
      "brand": 3,
      "name": "Master Bedroom",
      "runningState": "NOT_REQUIRED",
      "zoneRunningState": "NOT_REQUIRED",
      "zoneOn": false,
      "zoneType": "INDIVIDUAL",
      "set_temp": 23,
      "temperature_units": "c",
      "actual_temp": 24,
      "max_temp": 23,
      "min_temp": 0,
      "fan_speed": 1,
      "max_fan_speed": 10,
      "min_fan_speed": 1,
      "control_mode": "TEMP",
      "control_mode_type": "NONE",
      "internal_temp": 24,
      "external_temp": null,
      "programMode": "off",
      "ProgramModeOverridden": false,
      "ProgramPeriodActive": false,
      "programOverrideDisabled": true
    },
    {
      "brand": 3,
      "name": "Spare Room",
      "runningState": "NOT_REQUIRED",
      "zoneRunningState": "NOT_REQUIRED",
      "zoneOn": false,
      "zoneType": "INDIVIDUAL",
      "set_temp": 21,
      "temperature_units": "c",
      "actual_temp": 24,
      "max_temp": 23,
      "min_temp": 0,
      "fan_speed": 1,
      "max_fan_speed": 10,
      "min_fan_speed": 1,
      "control_mode": "TEMP",
      "control_mode_type": "NONE",
      "internal_temp": 24,
      "external_temp": null,
      "programMode": "off",
      "ProgramModeOverridden": false,
      "ProgramPeriodActive": false,
      "programOverrideDisabled": true
    },
    {
      "brand": 3,
      "name": "Mishy Bedroom",
      "runningState": "NOT_REQUIRED",
      "zoneRunningState": "NOT_REQUIRED",
      "zoneOn": false,
      "zoneType": "INDIVIDUAL",
      "set_temp": 23,
      "temperature_units": "c",
      "actual_temp": 24,
      "max_temp": 23,
      "min_temp": 0,
      "fan_speed": 1,
      "max_fan_speed": 10,
      "min_fan_speed": 1,
      "control_mode": "TEMP",
      "control_mode_type": "NONE",
      "internal_temp": 24,
      "external_temp": null,
      "programMode": "off",
      "ProgramModeOverridden": false,
      "ProgramPeriodActive": false,
      "programOverrideDisabled": true
    }
  ],
  "fan": {
    "cooler_available": false,
    "cooler_brand": 3,
    "heater_available": true,
    "heater_brand": 3,
    "heater_Fan_Speed": 1,
    "cooler_Fan_Speed": 1
  },
  "touchCount": 528,
  "installed": {
    "evap": false,
    "faoc": false,
    "heater": true,
    "iaoc": true,
    "coolerType": 2
  }
}
andrewleech commented 8 months ago

I did think I had the startup blocking fixed already, clearly not. The websocket response for me is normally immediate, there must be done cases where it's not or needs retrying or something.

The whole system being in heat or cool mode, not mixed, is what I expected based on the json format, thanks for confirming.

That's interesting that you can't / don't set fan speed... with my evap I never have it in "set temperature" mode, I always just choose a fan speed.

When you have fan only mode (not heat) I presume it's a recirculating air fan, not pulling from outside? Do you set the fan speed in this case?

Oh, and in terms of turning the system off, do you normally "turn all the zones off" or is it a case of "master' zone turns system on/off regardless of individual zone settings?

TheOriginalMrWolf commented 8 months ago

Thanks @andrewleech.

In fan-only mode it’s recirculating only (though the controller icon implies that for some configurations you could maybe choose external air input).

It turns on all the zones and allows you to set the fan speed.

There is no individual zone control available in this state.

in terms of turning the system off

The system has a master on/off.

Each of the 5 zones has individual zone on/off.

If master is off, turning it on then enables the individual zones which retain their previous states (ie what they were set at when the master got turned off).

Any zone that’s turned on gets heat/cold as per setting and demand.

If you turn all zones off then the system stops, but the master remains on, and the system will service any zone that is subsequently turned on again.

Turning the master off saves current zone state and then shuts everything down.

andrewleech commented 8 months ago

Thanks, that description helps. Currently in iterating through an the cooler and heaters in their lists to gather zone names and making ha entities for each one.

So in the situation like yours where they're all individual zones it sounds like I should have their on/off linked only to the zone enabled setting in the device entry for that zone. These zone entities should not have control over the HVAC mode / presets at all. However they did report of they're active or off/idle for the current system mode, ie a heating only zones when running in cool mode could be set "on" but would be in idle state perhaps.

I should then also create an additional common / master entity that directly controls the system mode and on/off setting.

How does that sound?

Other people have (ducted) systems that are not individual zone types but listed as common and slave, they'll likely need a slightly different behaviour.

Fyi my evap only system has a fan that just pulls air from outside.

TheOriginalMrWolf commented 8 months ago

Hi @andrewleech,

Fixing the start-up blocking would be fantastic.

My system is a recirculating ducted gas heater with the add-on cooler inverter split system (evaporator attached immediately downstream from the heater) which then feeds the various zone motors.

Also, the family uses HomeKit to control all the various smart things around the house, most of which are provided by the HAss HomeKit functionality.

For me the ideal configuration would be:

However not sure how to handle the fan only mode within HAss? With my system the fan only mode turns on all zones and does not allow any individual zone control (no on/off, temp, or fan speed settings). How would you disable the zones' on/off and target temp settings?

For behaviour/interaction between the master & zone controls, not sure what's possible within the constraints of HAss however could suggest a couple of options:

Dunno if any of this helps?

andrewleech commented 8 months ago

The master on/off implicitly is basically what the integration if currently trying to do. That would mean though for someone to shut their system off they'd need to manually turn off all entities. So having one explicit master entity probably makes sense.

Regardless, yes your description and suggestions do certainly help me make sense of how these systems can / do work.

Could you share a log with all the magiqtouch entries during a ha restart? Hopefully the timing of them might help with me fixing the blocking behaviour.

Edit: oh, my startup is blocking again now too so it's probably a new bug from the last round of changes :-)

TheOriginalMrWolf commented 8 months ago

Hi @andrewleech,

If I just restart HAss by going to developer tools/yaml & hit restart things go quite pear-shaped.

First, the shutdown seems to have quite a few problems. A couple of different integrations seem to get quite upset and then I finally see a message in the log:

homeassistant  | 2024-03-24 16:06:46.462 WARNING (MainThread) [homeassistant.core] Task <Task pending name='Task-2222' coro=<MagiQtouch_Driver.ws_handler() running at /config/custom_components/magiqtouch/magiqtouch.py:235> wait_for=<Future pending cb=[Task.task_wakeup()]> cb=[set.remove()]> was still running after final writes shutdown stage; Integrations should cancel non-critical tasks when receiving the stop event to prevent delaying shutdown

Then, shortly after - not too sure if it's still trying to shut down or actually restarting (though I suspect it's stuck in the shutdown process) the integration absolutely hoses the log with continuous repeats of the following & HAss doesn't seem to ever restart:

homeassistant  | 2024-03-24 16:06:46.468 ERROR (MainThread) [magiqtouch] websocket
homeassistant  | Traceback (most recent call last):
homeassistant  |   File "/config/custom_components/magiqtouch/magiqtouch.py", line 235, in ws_handler
homeassistant  |     while msg := await asyncio.wait_for(ws.receive(), timeout):
homeassistant  |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant  |   File "/usr/local/lib/python3.12/asyncio/tasks.py", line 520, in wait_for
homeassistant  |     return await fut
homeassistant  |            ^^^^^^^^^
homeassistant  |   File "/usr/local/lib/python3.12/site-packages/aiohttp/client_ws.py", line 244, in receive
homeassistant  |     msg = await self._reader.read()
homeassistant  |           ^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant  |   File "/usr/local/lib/python3.12/site-packages/aiohttp/streams.py", line 663, in read
homeassistant  |     return await super().read()
homeassistant  |            ^^^^^^^^^^^^^^^^^^^^
homeassistant  |   File "/usr/local/lib/python3.12/site-packages/aiohttp/streams.py", line 622, in read
homeassistant  |     await self._waiter
homeassistant  | asyncio.exceptions.CancelledError: Home Assistant final writes shutdown stage
homeassistant  | 2024-03-24 16:06:46.483 INFO (MainThread) [magiqtouch] websocket has closed
homeassistant  | 2024-03-24 16:06:46.484 ERROR (MainThread) [magiqtouch] websocket
homeassistant  | Traceback (most recent call last):
homeassistant  |   File "/config/custom_components/magiqtouch/magiqtouch.py", line 219, in ws_handler
homeassistant  |     async with self.httpsession.ws_connect(
homeassistant  |   File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 1194, in __aenter__
homeassistant  |     self._resp = await self._coro
homeassistant  |                  ^^^^^^^^^^^^^^^^
homeassistant  |   File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 832, in _ws_connect
homeassistant  |     resp = await self.request(
homeassistant  |            ^^^^^^^^^^^^^^^^^^^
homeassistant  |   File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 425, in _request
homeassistant  |     raise RuntimeError("Session is closed")
homeassistant  | RuntimeError: Session is closed
homeassistant  | 2024-03-24 16:06:46.489 INFO (MainThread) [magiqtouch] websocket has closed
homeassistant  | 2024-03-24 16:06:46.490 ERROR (MainThread) [magiqtouch] websocket
homeassistant  | Traceback (most recent call last):
homeassistant  |   File "/config/custom_components/magiqtouch/magiqtouch.py", line 219, in ws_handler
homeassistant  |     async with self.httpsession.ws_connect(
homeassistant  |   File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 1194, in __aenter__
homeassistant  |     self._resp = await self._coro
homeassistant  |                  ^^^^^^^^^^^^^^^^
homeassistant  |   File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 832, in _ws_connect
homeassistant  |     resp = await self.request(
homeassistant  |            ^^^^^^^^^^^^^^^^^^^
homeassistant  |   File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 425, in _request
homeassistant  |     raise RuntimeError("Session is closed")
homeassistant  | RuntimeError: Session is closed
homeassistant  | 2024-03-24 16:06:46.492 INFO (MainThread) [magiqtouch] websocket has closed
homeassistant  | 2024-03-24 16:06:46.494 ERROR (MainThread) [magiqtouch] websocket
homeassistant  | Traceback (most recent call last):
homeassistant  |   File "/config/custom_components/magiqtouch/magiqtouch.py", line 219, in ws_handler
homeassistant  |     async with self.httpsession.ws_connect(
homeassistant  |   File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 1194, in __aenter__
homeassistant  |     self._resp = await self._coro
homeassistant  |                  ^^^^^^^^^^^^^^^^
homeassistant  |   File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 832, in _ws_connect
homeassistant  |     resp = await self.request(
homeassistant  |            ^^^^^^^^^^^^^^^^^^^
homeassistant  |   File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 425, in _request
homeassistant  |     raise RuntimeError("Session is closed")
homeassistant  | RuntimeError: Session is closed
homeassistant  | 2024-03-24 16:06:46.496 INFO (MainThread) [magiqtouch] websocket has closed

In order to recover I need to restart the HAss container. This at least proceeds 'normally' - though with the abovementioned blocking issue.

Attached is the MagiqTouch integration debug log with the full (eventually successful) restart.

magiqtouch_reboot_debug.log

I could also provide the full HAss log if you wanted though this has a lot more noise and is probably not that much more helpful.

andrewleech commented 8 months ago

Those errors at shutdown are something I hadn't noticed, I hadn't seen my logs from then either so thanks for sharing. I think that's easy to clean up.

New update posted 3f0ddbc, hopefully has that shutdown issue and startup blocking fixed.

TheOriginalMrWolf commented 8 months ago

Still a problem on restart @andrewleech -

homeassistant  | 2024-03-25 11:40:25.399 ERROR (MainThread) [homeassistant.setup] Setup failed for custom integration 'magiqtouch': Unable to import component: No module named 'mandate                                                                                                            '
homeassistant  | Traceback (most recent call last):
homeassistant  |   File "/usr/src/homeassistant/homeassistant/setup.py", line 296, in _async_setup_component
homeassistant  |     component = await integration.async_get_component()
homeassistant  |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant  |   File "/usr/src/homeassistant/homeassistant/loader.py", line 894, in async_get_component
homeassistant  |     comp = self.get_component()
homeassistant  |            ^^^^^^^^^^^^^^^^^^^^
homeassistant  |   File "/usr/src/homeassistant/homeassistant/loader.py", line 921, in get_component
homeassistant  |     ComponentProtocol, importlib.import_module(self.pkg_path)
homeassistant  |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant  |   File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, in import_module
homeassistant  |     return _bootstrap._gcd_import(name[level:], package, level)
homeassistant  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant  |   File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
homeassistant  |   File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
homeassistant  |   File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
homeassistant  |   File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
homeassistant  |   File "<frozen importlib._bootstrap_external>", line 995, in exec_module
homeassistant  |   File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
homeassistant  |   File "/config/custom_components/magiqtouch/__init__.py", line 21, in <module>
homeassistant  |     from .magiqtouch import MagiQtouch_Driver
homeassistant  |   File "/config/custom_components/magiqtouch/magiqtouch.py", line 15, in <module>
homeassistant  |     from mandate import Cognito
homeassistant  | ModuleNotFoundError: No module named 'mandate'

...and still blocking on start unfortunately.

andrewleech commented 8 months ago

Ok I think I know what HA was seeing as blocking behaviour and worked around it, hopefully fixed in c8af4f3

That mandate issue is weird, maybe check in hacs that you're still on the branch for this integration and that it hasn't jumped back to a version number.

TheOriginalMrWolf commented 8 months ago

Hi @andrewleech,

maybe check in hacs that you're still on the branch for this integration

Yep, definitely still on 3f0ddbc.

hopefully fixed in https://github.com/andrewleech/ha_magiqtouch/commit/c8af4f386376474412826c43abea269dfe72e937

Have updated to c8af4f3 and now shutdown & restarts are working well. No error messages including the 'mandate' one gone as well, so... great, thanks! 😁

Do you need any more logs or testing etc from me to progress the zoning issue?

andrewleech commented 8 months ago

I should have enough info to work on the zones setup, might just have to think about how to structure it a bit though internally.

andrewleech commented 8 months ago

@TheOriginalMrWolf looking at what's needed for a system like yours, it's all individual zones, no common / master zone. However it'll need a common / master climate entity created to set the overall system enabled and operating mode.

However, this common entity, what temperature should be presented? Similarly, if a set temperature is configured, should that be set somewhere?

andrewleech commented 8 months ago

Hi! I've restructured the zone support fairly extensively, let me know if it crashes or works for you!

Should be an entity per zone, plus extra master zone for individual zone systems.

Changing modes heat/cool/fan should only work from master / common zone. Presets are similarly just on master. Turning off on the master/common control turns entire system off.

The controls for off/auto on each zone entity should work to turn it on/off. The entity should show whether it's in heat or cool mode based on the master/system setting.

AschwinGehlen commented 8 months ago

@andrewleech that broke it. 🤣

It can no longer find any entities. Even after logging in again it fails to pickup any entities.

Running version cf93396

andrewleech commented 8 months ago

Ok, that's not so surprising as there's lots of code here that doesn't get run for me, must be a simple code bug. Can you please share any error logs?

AschwinGehlen commented 8 months ago

@andrewleech hopefully this helps.

This is just a 'reload' of the integration, followed by a 'add entry' where I entered in my user name and password.

In the image, the top one with 4 entities is the original setup before it lost the entities. The bottom one is the result when adding a new entry.

image

home-assistant_magiqtouch_2024-04-02T21-00-32.852Z.log

andrewleech commented 8 months ago

I've fixed the first issue I saw on that log and pushed it if you get a chance to try again :-)

Fyi losing entities is completely normal in a new code / bug testing / integration crashing situation - I had that about 6 times last night while coding and testing this change. When it happens the logs are the only thing needed really to show where the issue is coming from.

AschwinGehlen commented 8 months ago

Downloading now and will test.

AschwinGehlen commented 8 months ago

@andrewleech, interties are there with an added 2. Now also have 'climate.magiqtouch' that is not available and 'sensor.magiqtouch_internal_temperature'.

image

There is no 'on' option now so cannot turn on the heater or fan. The interties also do not recognise and manual changes made on the physical controller.

image

Here is a quick log grab. home-assistant_magiqtouch_2024-04-02T23-51-57.969Z.log

andrewleech commented 7 months ago

There were issues with which unit to read from for things like current temperature, fan speed etc for a particular zone.

New update pushed that hopefully addresses this.

TheOriginalMrWolf commented 7 months ago

Updated to latest version & restarted via dev/yaml/restart.

Restart is blocking with logs being spammed:

2024-04-04 11:51:26.233 ERROR (MainThread) [magiqtouch] websocket
Traceback (most recent call last):
  File "/config/custom_components/magiqtouch/magiqtouch.py", line 271, in ws_handler
    self.process_new_state(status)
  File "/config/custom_components/magiqtouch/magiqtouch.py", line 361, in process_new_state
    self._update_listener()
  File "/config/custom_components/magiqtouch/__init__.py", line 111, in data_updated
    self.async_set_updated_data(None)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 444, in async_set_updated_data
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 183, in async_update_listeners
    update_callback()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 497, in _handle_coordinator_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 992, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1113, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1052, in __async_calculate_state
    attr.update(self.state_attributes or {})
                ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 322, in __getattribute__
    return super().__getattribute__(__name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 496, in state_attributes
    data[ATTR_FAN_MODE] = self.fan_mode
                          ^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 322, in __getattribute__
    return super().__getattribute__(__name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/magiqtouch/climate.py", line 379, in fan_mode
    if self.controller.active_device(self.zone).control_mode == CONTROL_MODE_TEMP:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/magiqtouch/magiqtouch.py", line 494, in active_device
    if state.runningMode in (MODE_COOLER, MODE_COOLER_FAN):
       ^^^^^^^^^^^^^^^^^
AttributeError: 'ZoneType' object has no attribute 'runningMode'

Full restart also spamming the logs every second:

 2024-04-04 12:00:30.913 ERROR (MainThread) [magiqtouch] websocket
homeassistant  | Traceback (most recent call last):
homeassistant  |   File "/config/custom_components/magiqtouch/magiqtouch.py", line 271, in ws_handler
homeassistant  |     self.process_new_state(status)
homeassistant  |   File "/config/custom_components/magiqtouch/magiqtouch.py", line 361, in process_new_state
homeassistant  |     self._update_listener()
homeassistant  |   File "/config/custom_components/magiqtouch/__init__.py", line 111, in data_updated
homeassistant  |     self.async_set_updated_data(None)
homeassistant  |   File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 444, in async_set_updated_data
homeassistant  |     self.async_update_listeners()
homeassistant  |   File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 183, in async_update_listeners
homeassistant  |     update_callback()
homeassistant  |   File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 497, in _handle_coordinator_update
homeassistant  |     self.async_write_ha_state()
homeassistant  |   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 992, in async_write_ha_state
homeassistant  |     self._async_write_ha_state()
homeassistant  |   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1113, in _async_write_ha_state
homeassistant  |     state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
homeassistant  |                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant  |   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1052, in __async_calculate_state
homeassistant  |     attr.update(self.state_attributes or {})
homeassistant  |                 ^^^^^^^^^^^^^^^^^^^^^
homeassistant  |   File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 322, in __getattribute__
homeassistant  |     return super().__getattribute__(__name)
homeassistant  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant  |   File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 496, in state_attributes
homeassistant  |     data[ATTR_FAN_MODE] = self.fan_mode
homeassistant  |                           ^^^^^^^^^^^^^
homeassistant  |   File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 322, in __getattribute__
homeassistant  |     return super().__getattribute__(__name)
homeassistant  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant  |   File "/config/custom_components/magiqtouch/climate.py", line 379, in fan_mode
homeassistant  |     if self.controller.active_device(self.zone).control_mode == CONTROL_MODE_TEMP:
homeassistant  |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant  |   File "/config/custom_components/magiqtouch/magiqtouch.py", line 494, in active_device
homeassistant  |     if state.runningMode in (MODE_COOLER, MODE_COOLER_FAN):
homeassistant  |        ^^^^^^^^^^^^^^^^^
homeassistant  | AttributeError: 'ZoneType' object has no attribute 'runningMode'

Have disabled the integration for now.

AschwinGehlen commented 7 months ago

@andrewleech I am back to no entities running 32ca854

image

andrewleech commented 7 months ago

Thanks @TheOriginalMrWolf that was a silly one on my part, local testing should have found that.

@AschwinGehlen I appreciate the testing, I'm sure it's getting frustrating. To put it in context though I'm doing all this coding from my phone, mostly at eg. 3am so I'm making more mistakes than I normally would at work!

That bug is fixed without any extra major changes, see how it goes now.

AschwinGehlen commented 7 months ago

Hey @andrewleech, it’s not frustrating, I just appreciate all your hard work on this. I only wish I had the brains to help you out more.

This is something you don’t need to do and are not getting paid for so we are all thankful for helping us out.

I’ll download the newest version this morning and test again for you.

AschwinGehlen commented 7 months ago

@andrewleech, just a quick look and it now comes up with a Failed to Connect message.

image

andrewleech commented 7 months ago

On that screen there, it would help to hit the "enable debug logging" button. Then it turns into a button that downloads a log file that's just got things relevant to the integration.

AschwinGehlen commented 7 months ago

Hey @andrewleech, I turn that on when I run the logs otherwise I turn it off.

Do you want some new logs? If so I’ll see if I can run them later on for you.

andrewleech commented 7 months ago

Yeah unfortunately screenshot / error message doesn't help fix it, it's always the logs that are needed to see what's next.

DuL90 commented 7 months ago

@andrewleech just installed the latest version, logs attached. The logs were taken after the install and restart. Not seeing the error message like the one above but there are several Warnings in the logs. I am seeing this error when you try turning on a zone. Log_5.log

Logger: homeassistant.components.websocket_api.http.connection Source: components/websocket_api/commands.py:239 integration: Home Assistant WebSocket API (documentation, issues) First occurred: 10:52:32 AM (1 occurrences) Last logged: 10:52:32 AM

[140033427156416] type object 'HVACMode' has no attribute 'ON' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 239, in handle_call_service response = await hass.services.async_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2542, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2579, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 971, in entity_service_call single_response = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1043, in _handle_entity_call result = await task ^^^^^^^^^^ File "/config/custom_components/magiqtouch/climate.py", line 346, in async_set_hvac_mode elif hvac_mode == HVACMode.ON: ^^^^^^^^^^^ AttributeError: type object 'HVACMode' has no attribute 'ON'

andrewleech commented 7 months ago

Oh I thought I got rid of all the HVACMode.ON bits; there was one left. That's fixed now.

AschwinGehlen commented 7 months ago

@andrewleech just installed 628541f and here are the logs. Still have the message 'failed to setup' home-assistant_magiqtouch_2024-04-05T04-12-05.214Z.log

DuL90 commented 7 months ago

@andrewleech Yep, that fixed the error I was seeing.

I grabbed some more logs but this time I included the logs while I did some basic testing. Log_6.log

I can turn on either the heater or the evap from the common zone but none of the climate enitities update to show the correct status of either. I dont seem to be able to turn anything off. I can change the fan speed on the evap but again its not reflected in what the climate entity shows. None of the other controls on any of the climate entities seem to do anything eg turn off, zone switching, temp, etc.

Hope this helps a little...

AschwinGehlen commented 7 months ago

@andrewleech you wouldn’t believe it.

So it turns out that for some bizarre reason, when I started up the Seeley MagIQtouch app on my phone, it suddenly came up with a message for me to go to my controller to complete the setup. I had to log out of my account from the controller and re sign in.

Now my entities are back.

So strange because it was working fine from the app all this time. Stupid heating system. Why do they make it so difficult for everyone. 🤣

Anyway, all do some testing today and upload the new logs.

andrewleech commented 7 months ago

I had to log out of my account from the controller and re sign in.

Ah, that's kind of good - the error from your last logs was new to me and in an area I haven't changed for ages so I was quite surprised. I've made a change to the logging in that section to get more details if this happens in future because as it was I didn't really know what was going on!

epetousis commented 7 months ago

@andrewleech I reckon there should be a check to see if the "redacted" var outputs to "N" like Aschwin's logs seem to indicate, and tell the user to finish setup/log out and in on their controller if it appears.

andrewleech commented 7 months ago

@andrewleech I reckon there should be a check to see if the "redacted" var outputs to "N" like Aschwin's logs seem to indicate, and tell the user to finish setup/log out and in on their controller if it appears.

Yeah I think that's what I've added, in that N is just the first character of a string returned from the server when the code was expecting a list of dictionary - I'm now detecting if I don't have the expected dict and logging the whole returned content as text to find out what is actually said.

AschwinGehlen commented 7 months ago

@andrewleech here are some logs. I have had to cut the log file in half because because it has blown up to over 45megs in the 5 minutes testing I did. home-assistant_magiqtouch_2024-04-06T03-23-39.044Z.log

Just did a quick test of trying to turn the zones on and off and set different temperatures on both zones. In most cases changing the temperature didn't work and if it did happen to work it took a very long time to respond.

Trying to turn the zones off kind of worked once, sort of. I turned the bedroom zone of in HA but no response on the controller so then tried to turn the lounge zone off and that turned everything off. Trying to turn the lounge off only does nothing.

When controller the zones manually from the controller there is no response back to HA.

andrewleech commented 7 months ago

Sorry for going quiet, hectic at home. Those last changes have resulted in a build that doesn't have a crash associated with the bad behaviour which makes it trickier to figure what's wrong.

Turns out basic functionality is broken for me too such means some of the problems should be easier to fix, however only really when I can turn my unit on and off to see what's happening each time - I'm not going to do that at 3am though :-D

TheOriginalMrWolf commented 7 months ago

All good @andrewleech - thanks for the update & no need to apologise! Family & personal life much more important than hobby - we all truly appreciate your efforts & what you've done so far!

andrewleech commented 7 months ago

I've fixed the basic functionality again, which included an issue in the zone parsing so maybe it'll help for people with zones controls. Let me know if/when you have a chance to test!

AschwinGehlen commented 7 months ago

I’ll test it tonight. Just about to head out to work. Yippee. 🤣