joleys / niko-home-control-II

Home Assistant Custom Integration for Niko Home Control II
MIT License
74 stars 21 forks source link

Unable to turn on/off daikin AC (generic AC) via Niko integration #107

Closed ostracon closed 9 months ago

ostracon commented 9 months ago

Hi,

This integration is working pretty well for my use case, appreciate all the work that's gone into it!

I have some Daikin AC units integrated into my Niko installation, and was hoping to control them via HA (especially as I cannot do this with the newer Daikin control methods now). They appear in the Home Control programming software as generic units, which I guess most closely correspond to "NHC HVAC Thermostat" mentioned in the README, which I realise is untested!

I can correctly read state information from the devices, and set the temperate, but the other functionality - particuarly turning the units on and off, does not work.

I realise this is untested, I'm happy to try to test things out in the Python code, but am a newcomer to HA in general so unsure of where to start.

I'm not sure if this related but I get a lot of errors along the lines of:

Source: custom_components/nhc2/nhccoco/coco.py:158
Integration: Niko Home Control II ([documentation](https://github.com/joleys/niko-home-control-II/blob/master/README.md), [issues](https://github.com/joleys/niko-home-control-II/issues))
First occurred: 8 January 2024 at 21:44:06 (8560 occurrences)
Last logged: 21:30:36

'NoneType' object has no attribute 'loop'

in my logs; when I enabled debug logging and do a service call along the lines of:

service: climate.turn_on
data: {}
target:
  entity_id: climate.daikinap61769

I see a log item like:

2024-01-09 21:33:18.390 DEBUG (Thread-2 (_publish_device_control_commands)) [custom_components.nhc2.nhccoco.coco] → Publishing device control command: {"Method": "devices.control", "Params": [{"Devices": [{"Uuid": "7b03c01f-2947-42cd-a063-12677ff630c5", "Properties": [{"OperationMode": "Auto"}]}]}]}
2024-01-09 21:33:19.299 DEBUG (Thread-3 (_thread_main)) [custom_components.nhc2.nhccoco.devices.controller] Controller changed (hobby/control/devices/evt == /control/devices/rsp).
2024-01-09 21:33:19.305 DEBUG (Thread-3 (_thread_main)) [custom_components.nhc2.nhccoco.devices.generic_hvac] DaikinAP61769 changed. Topic: hobby/control/devices/evt | Data: {'Uuid': '7b03c01f-2947-42cd-a063-12677ff630c5', 'Properties': [{'OperationMode': 'Auto'}]}

If I change the mode to something else in the Niko app (e.g. 'Heat'), running this call does change the mode back to 'Auto' as you might expect from the log, but doesn't turn it on. Simiarly, calling climate.set_hvac_mode appears to work, but wont' power the unit on.

In the Niko app, the controls are: Setpoint temperature Program (e.g. Manual/Schedule/Holiday) Fan speed Operation mode Power

It seems only the last one is missing from the integration here. Happy to test/provide more info as needed!

tijsverkoyen commented 9 months ago

I have some Daikin AC units integrated into my Niko installation, and was hoping to control them via HA (especially as I cannot do this with the newer Daikin control methods now). They appear in the Home Control programming software as generic units, which I guess most closely correspond to "NHC HVAC Thermostat" mentioned in the README, which I realise is untested!

I don't think they will be seen as a NHC HVAC Thermostat. But probably as Generic Heating/Cooling Implementation. To be sure you can check Settings → Devices & Services → Niko Home Control II → XX devices. Search for the device, and check the model.

I can correctly read state information from the devices, and set the temperate, but the other functionality - particuarly turning the units on and off, does not work.

Probably Daikin exposes some properties that are not documented. If you can provide me with a device list I can try to add better support. See https://github.com/joleys/niko-home-control-II#i-need-to-see-the-device-list

I'm not sure if this related but I get a lot of errors along the lines of:

Source: custom_components/nhc2/nhccoco/coco.py:158 Integration: Niko Home Control II (documentation, issues) First occurred: 8 January 2024 at 21:44:06 (8560 occurrences) Last logged: 21:30:36

'NoneType' object has no attribute 'loop' in my logs; when I enabled debug logging and do a service call along the lines of:

To my knowledge this is related to the Niko Controller restarting.

In the Niko app, the controls are:

  • Setpoint temperature
  • Program (e.g. Manual/Schedule/Holiday)
  • Fan speed
  • Operation mode
  • Power

It seems only the last one is missing from the integration here. Happy to test/provide more info as needed!

With the device list I will be able to see this.

ostracon commented 9 months ago

I don't think they will be seen as a NHC HVAC Thermostat. But probably as Generic Heating/Cooling Implementation. To be sure you can check Settings → Devices & Services → Niko Home Control II → XX devices. Search for the device, and check the model.

They are indeed Generics in the home control app itself, I should have clarified that, apologies. In HA, following those steps, I can see:

Device info
Airco (Hvac)
by Niko (daikin)

Probably Daikin exposes some properties that are not documented. If you can provide me with a device list I can try to add better support. See https://github.com/joleys/niko-home-control-II#i-need-to-see-the-device-list

Attached the full device list: home-assistant_2024-01-10T09-34-36.465Z.log

I guess the relevant snippet (prettified) is:

{
  "Uuid": "7b03c01f-2947-42cd-a063-12677ff630c5",
  "Identifier": "2e96ce41-c5ff-4997-9661-dae231fad155_climateControl",
  "Model": "airco",
  "Online": "True",
  "Name": "DaikinAP61769",
  "Technology": "daikin",
  "Type": "hvac",
  "Traits": [
    {
      "PlayerName": "N Office AC Niko"
    }
  ],
  "Parameters": [
    {
      "LocationName": "Nathaniel's Office"
    },
    {
      "LocationId": "dad31713-cba1-4b57-b048-bd6c873fe9fa"
    },
    {
      "LocationIcon": "bureau"
    }
  ],
  "Properties": [
    {
      "Program": "Setpoint"
    },
    {
      "SetpointTemperature": "30.00"
    },
    {
      "Status": "Off"
    },
    {
      "AmbientTemperature": "20.00"
    },
    {
      "CouplingStatus": "Ok"
    },
    {
      "FanSpeed": "Auto"
    },
    {
      "OperationMode": "Auto"
    }
  ],
  "PropertyDefinitions": [
    {
      "Program": {
        "HasStatus": "true",
        "CanControl": "true",
        "Description": "Choice(Setpoint,Schedule,Holiday)"
      }
    },
    {
      "SetpointTemperature": {
        "HasStatus": "true",
        "CanControl": "true",
        "Description": "Range(10.00,33.00,0.50)"
      }
    },
    {
      "Status": {
        "HasStatus": "true",
        "CanControl": "true",
        "Description": "Choice(On,Off)"
      }
    },
    {
      "AmbientTemperature": {
        "HasStatus": "true",
        "CanControl": "false",
        "Description": "Range(-128.00,128.00,0.10)"
      }
    },
    {
      "CouplingStatus": {
        "HasStatus": "true",
        "CanControl": "false",
        "Description": "Choice(Ok,NoInternet,NoCredentials,InvalidCredentials,ConnectionError,ConnectionTimeout,ApiError,UnknownError)"
      }
    },
    {
      "FanSpeed": {
        "HasStatus": "true",
        "CanControl": "true",
        "Description": "Choice(Auto,Quiet,Speed1,Speed2,Speed3,Speed4,Speed5)"
      }
    },
    {
      "OperationMode": {
        "HasStatus": "true",
        "CanControl": "true",
        "Description": "Choice(Fan,Heat,Cool,Auto,Dry)"
      }
    }
  ]
}

Possibly this Status parameter?

I'm not sure if this related but I get a lot of errors along the lines of: Source: custom_components/nhc2/nhccoco/coco.py:158 Integration: Niko Home Control II (documentation, issues) First occurred: 8 January 2024 at 21:44:06 (8560 occurrences) Last logged: 21:30:36 'NoneType' object has no attribute 'loop' in my logs; when I enabled debug logging and do a service call along the lines of:

To my knowledge this is related to the Niko Controller restarting.

Given there are around 8.5k occurrences of this entry in 24 hours or so, is the controller likely to restart that often? Anyway, it doesn't seem relevant to the AC issue, nor does it stop anything else from working currently, so happy to park that or open a separate issue.

Thank you so much for such a quick and comprehensive response :)

tijsverkoyen commented 9 months ago

Thx. I will try to look into it. But I have a busy week and busy next week.

tijsverkoyen commented 9 months ago

@ostracon I just took a quick look:

I think https://github.com/joleys/niko-home-control-II/pull/108 should resolve the issue. Can you try to apply the changes on your local installation. After applying the changes you will need to restart Home Assistant.

Can you also test this. As I don't have a Daikin AC ;-)

ostracon commented 9 months ago

Thanks - I'll try this now.

I had already hacked the same file a little to add the following:

    async def async_turn_on(self) -> None:
        self._device.set_status(self._gateway, PROPERTY_STATUS_VALUE_ON)
        self.on_change()

    async def async_turn_off(self) -> None:
        self._device.set_status(self._gateway, PROPERTY_STATUS_VALUE_OFF)
        self.on_change()

With that, I could turn on the device by calling the service climate.turn_on from developer tools, but turn_off was not working.

With this, and your fix, I can see similar behaviour - the AC will turn on when it is off and I set the mode to 'Auto', etc., but will not sure off either if I call turn_off or through the UI.

FWIW, if I try to change the fan speed from the UI, I also see "Fan mode is not valid. Valid fan modes are: off, low, medium, high, auto."

ostracon commented 9 months ago

Thanks for the hints on this - the linked PR fixes this, and I get the full functionality available now. :)

Screenshot 2024-01-10 at 21 45 44

tijsverkoyen commented 9 months ago

@ostracon big thank for your effort! I have released https://github.com/joleys/niko-home-control-II/releases/tag/v3.3.3 which includes your changes