mitch7391 / homebridge-cmd4-AdvantageAir

Catered shell script to integrate air conditioner control units by Advantage Air into HomeKit using the plug-in homebridge-cmd4.
MIT License
38 stars 5 forks source link

[Pull Request] Added fancy timers, enhancements and bug fixes #79

Closed uswong closed 1 year ago

uswong commented 1 year ago

name: Pull Request about: Add new features, enhancements and bug fixes to homebridge-cmd4-AdvantageAir. title: "[Pull Request] Added fancy timers, enhancements and bug fixes." labels: pull-request assignees: mitch7391


Added 3 extra fancy timers to turn on the aircon in specific mode -Cool, Heat or Vent. Some improvements were made, and some bugs found were fixed.

Is your pull request related to a problem or a new feature? Please describe:

  1. Timer issues: There are times when I would like to switch the running aircon from one mode to another after a period of time. The existing "Aircon Timer" is only capable of turning on or off the aircon, it has no control over the aircon mode.

  2. Improvements/bug fixes: (a) TargetTemperature is changed for all zones when the "set temperature" is changed in Thermostat. While it is all good for non-myZone users but it should not be that way for myZone users.

    (b) No waiting in between trys in "setAirConUsingIteration".

    (c) A jq failure message is a bit confusing for unit tests

    (d) In some cases, curl "setAircon", "setLights" or "setThings" commands seem to have executed successfully with a return code of 0 (rc=0) but have a feedback message of "{Ack: false}". This "{Ack: false}" feedback message is an indication that the intended action did not end up changing anything in AA system for some reasons. So far this kind of errors have not been captured by error log because the command has a return code of 0.

    (e) Current version of AirConServer does not return any feedback messages for curl "setAircon", "setLights" or "setThings" commands.

    Please take note that the bugs above are non-fatal.

Describe the solution you'd have implemented:

  1. Added a set of codes in AdvAir.sh to accommodate 3 fancy timers to turn on the aircon in specific mode: Cool, Heat or Vent. Users have an option to use or not to use these fancy timers via "ConfigCreator".

  2. (a) Changed codes in AdvAir.sh such that when myZone users changed the "set temperature" on Thermostat, only the "targetTemperature" of the zone defined as myZone is changed. No change for non-myZone users, they will still have the "targetTemperature" of all the zones changed when the Thermostat "set temperature" is changed.

    (b) coded in a 1.0s wait in between trys in "setAirConUsingIterations".

    (c) Added the word "failed" in the message for jq failed case.

    (d) The curl feedback message is checked for the word "false", if present, a return code of 5 (rc=5) is assigned so that the error is captured in the error log.

    (e) The curl feedback messages were coded in AirConServer.js making the AirConServer more like a real AdvantageAir system than ever before but it is still not quite 100% yet but good enough for unit testing.

  3. The following changes were also done to compliment the implementations listed above: (a) added an option for detailed debug log in config.schema.json.

    (b) added an optional checkbox to include fancy timers in index.html (Please see the screenshot below).

    (c) updated ConfigCreator.sh to include an option to create the config for fancy timers.

    (d) updated server.js to allow the checking of fancy timers' config.

    (e) added unit tests to test for fancy timers and updated some unit tests to reflect the changes done in improvements and bug fixes.

Do your changes pass local testing:

Additional context:

All these added features, enhancements and bug fixes are all under the hood changes. Exiting users will not see any real visible changes in homekit. However, if they would like to include the fancy timers, all they need to do is to re-run the "ConfigCreator" with the fancy timers checkbox selected.

Shown below is a screen shot of the UI of homebridge-cmd4-advantageair. The red arrows show the optional checkbox to include the extra fancy timers and an option to enable detailed debug log:

image

uswong commented 1 year ago

Hey Mitch,

I have updated this PR in the light of a successful test using Cmd4 v7.0.0 beta.

Cheers, Ung Sing

uswong commented 1 year ago

Hey Mitch,

Here are some useful info for the users as regards to the 2 optional items during the initial setup of the plugin:

  1. "Fan" vs "FanSwitch" setup: “FanSwitch” setup is to have the “FanSpeed” control as a secondary accessory attached to the “Fan” on/off switch. image

    The advantage of “FanSwitch” setup is that when the “Aircon” is on Cool, Heat or Dry and the “Fan” is off, Homekit users still can see the current fanSpeed setting on the Homekit tile. Shown below is an example of such scenario showing the current “FanSpeed” to be “25% Speed” which is equivalent to a “low” speed. image

  2. What are the extra Fancy Timers: Fancy Timers consists of three individual timers:

    1. Aircon Heat Timer
    2. Aircon Cool Timer
    3. Aircon Fan Timer

      Fancy Timers will turn on or off the Aircon in specific mode, ie Heat, Cool or Vent after a certain user specified time. In contrast, the existing Aircon Timer will turn on the Aircon in whatever mode the Aircon was turned off before the fact.

I have sent an email to you on quite a few weeks ago on this and I thought it may be more traceable to repeat the info here.

mitch7391 commented 1 year ago

Thanks for updates Ung Sing, I will try to have a look over this today, worst case tomorrow :) are we looking to roll this out before cmd4 takes the beta to master?

uswong commented 1 year ago

are we looking to roll this out before cmd4 takes the beta to master?

Not necessary. We can roll this out whenever you are ready. All changes are under the hood changes.

The main update I did was to take out the workaround I have on the "Set" endless loop which is now going to be taken care of by Cmd4 v7. Other minor updates are minor changes in ConfigCreator.sh and CheckConfig.sh to make it more robust in looking for config.json file especially for HOOBS users.

mitch7391 commented 1 year ago

And we are published Ung Sing :)

uswong commented 1 year ago

Excellent! You are super-efficient!

v3.9.0 runs very well and there is no more "cmd4-advantageair plugin not found" error on homebridge restart. I did not have to clear my cmd4-advantageair config.

mitch7391 commented 1 year ago

I did not have to clear my cmd4-advantageair config.

I was hoping this the case, but I could not be bothered reverting it all be 100% sure haha... Thanks for confirming this!