Ghawken / HomeKitLink-Siri

8 stars 3 forks source link

HomeKit Automation of Thermostats #30

Closed 7RDR7 closed 1 year ago

7RDR7 commented 1 year ago

Describe the bug In creating HomeKit automation for Indigo thermostats (Unistat Plugin, Qubino Thermostat ZMNKID) the Home app can only perform one function, either turn on the heater, or set the temperature, not both. It will always favor turning on the heater versus setting the temperature. It works fine in Indigo Schedules, setting both. I can see that HKSL only triggers a single command, mode or temperature.

To Reproduce Create automation in the Home app.

Expected behavior Set mode and temperature.

Screenshots If applicable, add screenshots to help explain your problem.

Device Information May 2, 2023 at 2:25:27 PM Embedded script executor host2 started Script address : batteryLevel : None buttonGroupCount : 0 configured : True coolIsOn : False coolSetpoint : 0.0 dehumidifierIsOn : False description : deviceTypeId : DeviceUnistat displayStateId : temperatureInputsAll displayStateImageSel : HvacHeatMode displayStateValRaw : 64.8 displayStateValUi : 64.8 enabled : True energyAccumBaseTime : None energyAccumTimeDelta : None energyAccumTotal : None energyCurLevel : None errorState : fanIsOn : False fanMode : Auto folderId : 1825553979 globalProps : MetaProps : (dict) com.GlennNZ.indigoplugin.HomeKitLink-Siri : (dict) HomeKit_audioSelector : false (bool) HomeKit_bridgeUniqueID : 386666 (integer) HomeKit_deviceSensor : hvacHeaterIsOn (string) HomeKit_deviceSubtype : Thermostat (string) HomeKit_inverseSelector : false (bool) HomeKit_publishDevice : true (bool) HomeKit_tempSelector : true (bool) homekit-name : Pool Heater (string) com.morris.unistat : (dict) NumHumidityInputs : 0 (integer) NumTemperatureInputs : 1 (integer) ShowCoolHeatEquipmentStateUI : true (bool) SupportsCoolSetpoint : false (bool) SupportsHeatSetpoint : true (bool) SupportsHvacFanMode : false (bool) SupportsHvacOperationMode : true (bool) coolDevices : (list) Item : 230420272 (string) deadband : 0.5 (string) deviceControlMode : normal (string) dimmerControlLevel : 100 (string) heatDevices : (list) Item : 230420272 (string) inputDecimals : 1 (string) inputDevice : 623611090 (string) inputState : sensorValue (string) inputType : dev (string) inputUnits : ºF (string) inputVariable : (string) modeNameAuto : Auto (string) modeNameCool : Cool (string) modeNameHeat : Heat (string) modeNameOff : Off (string) speedControlIndex : 3 (string) heatIsOn : False heatSetpoint : 60.1 humidifierIsOn : False humidities : [] humiditySensorCount : 0 hvacMode : Heat id : 1095881650 lastChanged : 2023-05-02 14:24:09 lastSuccessfulComm : 2023-05-02 14:24:09 model : Device Unistat name : Pool Heater ownerProps : com.morris.unistat : (dict) NumHumidityInputs : 0 (integer) NumTemperatureInputs : 1 (integer) ShowCoolHeatEquipmentStateUI : true (bool) SupportsCoolSetpoint : false (bool) SupportsHeatSetpoint : true (bool) SupportsHvacFanMode : false (bool) SupportsHvacOperationMode : true (bool) coolDevices : (list) Item : 230420272 (string) deadband : 0.5 (string) deviceControlMode : normal (string) dimmerControlLevel : 100 (string) heatDevices : (list) Item : 230420272 (string) inputDecimals : 1 (string) inputDevice : 623611090 (string) inputState : sensorValue (string) inputType : dev (string) inputUnits : ºF (string) inputVariable : (string) modeNameAuto : Auto (string) modeNameCool : Cool (string) modeNameHeat : Heat (string) modeNameOff : Off (string) speedControlIndex : 3 (string) pluginId : com.morris.unistat pluginProps : emptyDict : (dict) protocol : Plugin remoteDisplay : True sharedProps : com.indigodomo.indigoserver : (dict) states : States : (dict) hvacCoolerIsOn : off (on/off bool) hvacDehumidifierIsOn : off (on/off bool) hvacFanIsOn : off (on/off bool) hvacHeaterIsOn : off (on/off bool) hvacHumidifierIsOn : off (on/off bool) hvacOperationMode : 1 (integer) hvacOperationMode.ui : Heat (string) hvacOperationModeIsAuto : false (bool) hvacOperationModeIsCool : false (bool) hvacOperationModeIsHeat : true (bool) hvacOperationModeIsOff : false (bool) hvacOperationModeIsProgramAuto : false (bool) hvacOperationModeIsProgramCool : false (bool) hvacOperationModeIsProgramHeat : false (bool) setpointHeat : 60.1 (real) setpointHeat.ui : 60.1ºF (string) temperatureInput1 : 64.8 (real) temperatureInput1.ui : 64.8ºF (string) temperatureInputsAll : 64.8 (string) subModel : subType : supportsAllLightsOnOff : False supportsAllOff : False supportsCoolSetpoint : False supportsHeatSetpoint : True supportsHvacFanMode : False supportsHvacOperationMode : True supportsOnState : False supportsStatusRequest : True temperatureSensorCount : 1 temperatures : [64.8] version : None

Additional context As automation cannot be set in Indigo Touch, it's helpful to be able to modify automation from a device (iPhone), and not just the Indigo MacOS app. I used HomeKit automation for my pool heater which has frequent modifications due to outdoor weather.

Ghawken commented 1 year ago

Thanks I’ll have a look.

Automations likely send a different combination of requests to the plugin. We certainly know that Siri requests and button requests can be different - but haven’t widely tested against Automation, across most the devices.

Hopefully ii is a pretty easy fix - I suspect if an on/off received by plugin we probably ignore any temperature requests - so hopefully can fix that without breaking something else….

Alternatively an immediate work around may be to send 2 commands to thermostat - one mode change, and another temperature change. (presume that is possible?)

But will update my devices and add some demo automations and see what is up shortly

7RDR7 commented 1 year ago

Thanks Glenn. The HomeKit app doesn’t allow a two command implementation on the same device unless I do two separate automations. What I’ve done as a work-around is to have Indigo Schedules set the mode to ON and set the temperature to very low, then have Apple Home App automation only set the temperature later in the morning. It seems to be working. Thanks again for looking into the problem.

On May 4, 2023, at 4:27 AM, Ghawken @.***> wrote:

Thanks I’ll have a look.

Automations likely send a different combination of requests to the plugin. We certainly know that Siri requests and button requests can be different - but haven’t widely tested against Automation, across most the devices.

Hopefully ii is a pretty easy fix - I suspect if an on/off received by plugin we probably ignore any temperature requests - so hopefully can fix that without breaking something else….

Alternatively an immediate work around may be to send 2 commands to thermostat - one mode change, and another temperature change. (presume that is possible?)

But will update my devices and add some demo automations and see what is up shortly

— Reply to this email directly, view it on GitHub https://github.com/Ghawken/HomeKitLink-Siri/issues/30#issuecomment-1534287171, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQTW6AMJPQ2ZIFLSHE5HJITXENR5VANCNFSM6AAAAAAXTNG554. You are receiving this because you authored the thread.

Ghawken commented 1 year ago

Try 0.6.1

Was an interesting issue. Wasn't what I thought it would be. Basically the state of the Indigo device wasn't being updated quickly enough.

eg. HomeKit sends command Off -> Cool and Setpoint change to 20 Degrees

Plugin would see Off and turn to Cool. But because state of Indigo device was still Off (according to it) - would ignore the temp setting.

I have updated 0.6.1 - to update the indigo device based on us sending Indigo the command. Risk here if command fails, may actually not be the state the device is in. But regardless even if off can change temperature - so shouldn't really matter in these cases

Have a go and report back

Thanks

7RDR7 commented 1 year ago

Success! Thanks Glenn!

7RDR7 commented 1 year ago

Spoke too soon.... Automation works great, but if you attempt to change the temperature manually via the Home App, the temperature reverts back to the prior temperature. I think that my be what you were eluding to above.

May 5, 2023 at 4:39:01 PM Unistat "Pool Heater" mode now Heat Trigger Thermostat Start-up Temperature Reading. Unistat "Pool Heater" Cool equipment now on Z-Wave sent "Pool Probe" status request Z-Wave received "Pool Probe" sensor update to 21.1 °C Z-Wave sent "Heater Switch" on Trigger Heater - Pump High ON Z-Wave sent "Pump High" on HomeKitLink Siri Error (plugin.py: Function: Plugin_setter_callback line: 2427): Exception : Message : Error in setter callback HomeKitLink Siri Error Traceback: File "plugin.py", line 2115, in Plugin_setter_callback currentMode = newMode

HomeKitLink Siri Error Error in plugin execution:

Traceback (most recent call last): File "plugin.py", line 2115, in Plugin_setter_callback currentMode = newMode UnboundLocalError: local variable 'newMode' referenced before assignment

HomeKitLink Siri Error
Exc_info: (<class 'UnboundLocalError'>, UnboundLocalError("local variable 'newMode' referenced before assignment"), <traceback object at 0x113d16680>) Exc_Text: Traceback (most recent call last): File "plugin.py", line 2115, in Plugin_setter_callback currentMode = newMode UnboundLocalError: local variable 'newMode' referenced before assignment Stack_info: None

May 5, 2023 at 4:39:34 PM HomeKitLink Siri Error (plugin.py: Function: Plugin_setter_callback line: 2427): Exception : Message : Error in setter callback HomeKitLink Siri Error Traceback: File "plugin.py", line 2115, in Plugin_setter_callback currentMode = newMode

HomeKitLink Siri Error Error in plugin execution:

Traceback (most recent call last): File "plugin.py", line 2115, in Plugin_setter_callback currentMode = newMode UnboundLocalError: local variable 'newMode' referenced before assignment

HomeKitLink Siri Error
Exc_info: (<class 'UnboundLocalError'>, UnboundLocalError("local variable 'newMode' referenced before assignment"), <traceback object at 0x113d082c0>) Exc_Text: Traceback (most recent call last): File "plugin.py", line 2115, in Plugin_setter_callback currentMode = newMode UnboundLocalError: local variable 'newMode' referenced before assignment Stack_info: None

Ghawken commented 1 year ago

Sorry thats a bug. Won’t be long

Ghawken commented 1 year ago

Sorry that was a bit of lazy bug. Should be fixed in 0.6.2 - there now. Thanks for patience!

7RDR7 commented 1 year ago

Thanks Glenn! Upgraded and it's working. Appreciate you making the changes!

7RDR7 commented 1 year ago

Been running for a few days, all good! Only one potential glitch with the AD2USB plugin where I disarmed the panel via HKLS (panel became disarmed), but HKLS did not update the panel status (remained displaying "Night"). Likely not related, but I thought I'd mention. Thanks again for the update! This is a great plugin!