Closed uswong closed 2 years ago
Hey Ung Sing, I can see you had added 'ac1' in the script as the default; which was going to be my first question off the bat. Nice job on this as it will not affect current users with only one aircon and not require any changes from them :p everything looks great!
I can see you had added 'ac1' in the script as the default;
yes, no change whatsoever required for existing users with single aircon system.
Hey Ung Sing; first day off out of night shifts and finally testing this locally. I notice just about all of my unit tests fail now:
31 tests, 25 failures, 2 skipped
Is this the same for you?
Also another question, the flip
constant can go after 'thing:Garage'
and not affect anything yeah? Just looks neater and thought I would check before I update the Wiki.
Hi Mitch, you need to update your unit tests
to JohnT's latest version. I have included it in my PR under the /test subdirectory.
and yes the flip
can be anywhere.
As in this PR just approved or a coming one? As that is what I have tested haha...
It should be in the one just approved. Let me double check whether that is the correct one.
Yes, that is the one.
The red highlighted one is an extra one of my own testing. Tt will fail on that one and you can ignore that.
Hmmm well I have 25 failures, not one or a couple lol
pi@homebridge:/tmp/homebridge-cmd4-AdvantageAir $ npm run test
> homebridge-cmd4-advantageair@3.3.0-beta.5 pretest
> if [ ! -d 'node_modules' ];then printf ' test is only done in a development environment
> ';exit 1; fi
> homebridge-cmd4-advantageair@3.3.0-beta.5 test
> npm run allBats && npm run testjs && npm run check && npm run lint
> homebridge-cmd4-advantageair@3.3.0-beta.5 allBats
> bats test/*.bats
✗ AdvAir ( ezone inline ) Test PassOn1 Get Brightness z01
(from function `assert_equal' in file node_modules/bats-assert/src/assert.bash, line 91,
in test file test/GetBrightness.bats, line 55)
`assert_equal "$status" 0' failed
-- values do not equal --
expected : 0
actual : 127
--
✗ AdvAir ( ezone inline ) Test PassOn1 Get Brightness z03
(from function `assert_equal' in file node_modules/bats-assert/src/assert.bash, line 91,
in test file test/GetBrightness.bats, line 63)
`assert_equal "$status" 0' failed
-- values do not equal --
expected : 0
actual : 127
--
✗ AdvAir ( ezone inline ) Test PassOn5 Get CurrentHeatingCoolingState
(from function `assert_equal' in file node_modules/bats-assert/src/assert.bash, line 91,
in test file test/GetCurrentHeatingCoolingState.bats, line 31)
`assert_equal "$status" "$e_status" ]' failed
-- values do not equal --
expected : 0
actual : 127
--
✗ AdvAir ( ezone ) Test PassOn1 Get CurrentHeatingCoolingState
(from function `assert_equal' in file node_modules/bats-assert/src/assert.bash, line 91,
from function `_common_compareAgainstEzone' in file ./test/setup, line 77,
in test file test/GetCurrentHeatingCoolingState.bats, line 39)
`_common_compareAgainstEzone Get Blah CurrentHeatingCoolingState TEST_ON' failed
-- values do not equal --
expected : 0
actual : 127
--
✗ AdvAir ( ezone inline ) Test PassOn5 Get CurrentTemperature
(from function `assert_equal' in file node_modules/bats-assert/src/assert.bash, line 91,
in test file test/GetCurrentTemperature.bats, line 38)
`assert_equal "$status" "$e_status"' failed
-- values do not equal --
expected : 0
actual : 127
--
✗ AdvAir ( ezone inline ) Test PassOn1 Get CurrentTemperature z01
(from function `assert_equal' in file node_modules/bats-assert/src/assert.bash, line 91,
in test file test/GetCurrentTemperature.bats, line 54)
`assert_equal "$status" "$e_status"' failed
-- values do not equal --
expected : 0
actual : 127
--
✗ AdvAir ( zones inline ) Test PassOn1 Get CurrentTemperature z01
(from function `assert_equal' in file node_modules/bats-assert/src/assert.bash, line 91,
in test file test/GetCurrentTemperature.bats, line 69)
`assert_equal "$status" "$e_status"' failed
-- values do not equal --
expected : 0
actual : 127
--
✗ AdvAir ( zones inline ) Test PassOn1 Get CurrentTemperature z03
(from function `assert_equal' in file node_modules/bats-assert/src/assert.bash, line 91,
in test file test/GetCurrentTemperature.bats, line 83)
`assert_equal "$status" "$e_status"' failed
-- values do not equal --
expected : 0
actual : 127
--
✗ AdvAir ( ezone inline ) Test PassOn1 Get CurrentTemperature with NoSensor Data (creating new myAirConstants
(from function `assert_equal' in file node_modules/bats-assert/src/assert.bash, line 91,
in test file test/GetCurrentTemperature.bats, line 103)
`assert_equal "$status" "$e_status"' failed
-- values do not equal --
expected : 0
actual : 127
--
✗ AdvAir ( ezone inline ) Test PassOn1 Get CurrentTemperature with NoSensor Data (with cached myAirConstants
(from function `assert_equal' in file node_modules/bats-assert/src/assert.bash, line 91,
in test file test/GetCurrentTemperature.bats, line 116)
`assert_equal "$status" 0' failed
-- values do not equal --
expected : 0
actual : 127
--
✗ AdvAir ( ezone inline ) Test PassOn1 Get CurrentTemperature with NoSensor Data
(from function `assert_equal' in file node_modules/bats-assert/src/assert.bash, line 91,
in test file test/GetNoSensors.bats, line 29)
`assert_equal "${lines[1]}" "25.4"' failed
-- values do not equal --
expected : 25.4
actual : 0
--
✗ AdvAir ( ezone inline ) Test PassOn5 Get On
(from function `assert_equal' in file node_modules/bats-assert/src/assert.bash, line 91,
in test file test/GetOn.bats, line 31)
`assert_equal "$status" "$e_status" ]' failed
-- values do not equal --
expected : 0
actual : 127
--
✗ AdvAir ( ezone ) Test PassOn1 Get On
(from function `assert_equal' in file node_modules/bats-assert/src/assert.bash, line 91,
from function `_common_compareAgainstEzone' in file ./test/setup, line 77,
in test file test/GetOn.bats, line 42)
`_common_compareAgainstEzone Get Fan On TEST_ON' failed
-- values do not equal --
expected : 0
actual : 127
--
✗ AdvAir ( zones ) Test PassOn1 Get On z01
(from function `assert_equal' in file node_modules/bats-assert/src/assert.bash, line 91,
from function `_common_compareAgainstZones' in file ./test/setup, line 55,
in test file test/GetOn.bats, line 50)
`_common_compareAgainstZones Get Fan On z01 TEST_ON' failed
-- values do not equal --
expected : 0
actual : 127
--
✗ AdvAir ( zones inline ) Test PassOn5 Get StatusLowBattery z01
(from function `assert_equal' in file node_modules/bats-assert/src/assert.bash, line 91,
in test file test/GetStatusLowBattery.bats, line 32)
`assert_equal "$status" "$z_status" ]' failed
-- values do not equal --
expected : 0
actual : 127
--
✗ AdvAir ( zones ) Test PassOn1 Get StatusLowBattery z01
(from function `assert_equal' in file node_modules/bats-assert/src/assert.bash, line 91,
from function `_common_compareAgainstZones' in file ./test/setup, line 55,
in test file test/GetStatusLowBattery.bats, line 41)
`_common_compareAgainstZones Get Blah StatusLowBattery z01 TEST_ON' failed
-- values do not equal --
expected : 0
actual : 127
--
✗ AdvAir ( ezone inline ) Test PassOn5 Get TargetHeatingCoolingState
(from function `assert_equal' in file node_modules/bats-assert/src/assert.bash, line 91,
in test file test/GetTargetHeatingCoolingState.bats, line 31)
`assert_equal "$status" "$e_status" ]' failed
-- values do not equal --
expected : 0
actual : 127
--
✗ AdvAir ( ezone ) Test PassOn1 Get TargetHeatingCoolingState
(from function `assert_equal' in file node_modules/bats-assert/src/assert.bash, line 91,
from function `_common_compareAgainstEzone' in file ./test/setup, line 77,
in test file test/GetTargetHeatingCoolingState.bats, line 40)
`_common_compareAgainstEzone Get Blah TargetHeatingCoolingState TEST_ON' failed
-- values do not equal --
expected : 0
actual : 127
--
✗ AdvAir ( ezone inline ) Test PassOn5 Get TargetTemperature
(from function `assert_equal' in file node_modules/bats-assert/src/assert.bash, line 91,
in test file test/GetTargetTemperature.bats, line 32)
`assert_equal "$status" "$e_status" ]' failed
-- values do not equal --
expected : 0
actual : 127
--
✗ AdvAir ( ezone ) Test PassOn1 Get TargetTemperature
(from function `assert_equal' in file node_modules/bats-assert/src/assert.bash, line 91,
from function `_common_compareAgainstEzone' in file ./test/setup, line 77,
in test file test/GetTargetTemperature.bats, line 42)
`_common_compareAgainstEzone Get Blah TargetTemperature TEST_ON' failed
-- values do not equal --
expected : 0
actual : 127
--
✓ AdvAir ( ezone inline ) Get PassOn1 TemperatureDisplayUnits ( inline )
✓ AdvAir ( ezone ) Get PassOn1 TemperatureDisplayUnits ( inline )
✗ AdvAir ( ezone inline ) Test Invalid Option 'BLAH'
(from function `assert_equal' in file node_modules/bats-assert/src/assert.bash, line 91,
in test file test/InvalidOption.bats, line 21)
`assert_equal "$status" "1"' failed
-- values do not equal --
expected : 1
actual : 127
--
✗ AdvAir ( ezone inline ) Test IP PassOn1
(from function `assert_equal' in file node_modules/bats-assert/src/assert.bash, line 91,
in test file test/InvalidOption.bats, line 34)
`assert_equal "$status" "0"' failed
-- values do not equal --
expected : 0
actual : 127
--
- AdvAir ( ezone / zone ) Test ../homebridge.log.txt (skipped: Skipping test. No ../homebridge.log.txt from /tmp/homebridge-cmd4-AdvantageAir/test)
✗ AdvAir ( ezone inline ) Test PassOn5 Set On 1
(from function `assert_equal' in file node_modules/bats-assert/src/assert.bash, line 91,
in test file test/SetOn.bats, line 25)
`assert_equal "${lines[0]}" "Setting url: http://192.168.0.173:2025/setAircon?json={ac1:{info:{state:on,mode:vent}}}"' failed
-- values do not equal --
expected : Setting url: http://192.168.0.173:2025/setAircon?json={ac1:{info:{state:on,mode:vent}}}
actual : /tmp/homebridge-cmd4-AdvantageAir/node_modules/bats/lib/bats-core/test_functions.bash: line 37: ./compare/AdvAir.sh: No such file or directory
--
✗ AdvAir ( zones inline ) Test PassOn1 Set On 1 z01
(from function `assert_equal' in file node_modules/bats-assert/src/assert.bash, line 91,
in test file test/SetOn.bats, line 39)
`assert_equal "${lines[0]}" "${e_lines[0]}"' failed
-- values do not equal --
expected : Setting url: http://192.168.0.173:2025/setAircon?json={ac1:{zones:{z01:{state:open}}}}
actual : /tmp/homebridge-cmd4-AdvantageAir/node_modules/bats/lib/bats-core/test_functions.bash: line 37: ./compare/AdvAir.sh: No such file or directory
--
✗ AdvAir ( ezone inline ) Test PassOn1 Set TargetHeatingCoolingState 1
(from function `assert_equal' in file node_modules/bats-assert/src/assert.bash, line 91,
in test file test/SetTargetHeatingCoolingState.bats, line 23)
`assert_equal "$status" "$e_status" ]' failed
-- values do not equal --
expected : 0
actual : 127
--
- Sample Test (How to Skip) (skipped: This test is skipped just to show that skippping can be done.)
✓ Sample Test Check Status of run command
✓ Sample Test Check stdout of command
31 tests, 25 failures, 2 skipped
that's a bit strange. Mine all passed.
Please check GetBrightness.bats
to see if it looks like this or not.
Looks the same to me:
# Understanding these test cases
#
# What we are trying to do is compare the execution of AdvAir.sh with either
# the previous ezone/zones scripts or some expected output. In that way
# you can rerun these tests after any change to AdvAir.sh and gaurantee the
# result in production without having to try every possible scenario.
# Unit tests have a setup function before and a teardown function after each
# test. These can be ignored if you are just trying to figure out what
# went wrong. Remember that what we are testing is BASH shell commands you can
# execute them also from the command line.
# For example:
# cd test
# ln -s ./testData/dataPassOn5 ./data
# ./compare/AdvAir.sh Get Blah Brightness z01 192.168.50.99 TEST_ON
#
# Results to stdout:
# Try 0
# Try 1
# Try 2
# Try 3
# Try 4
# 100
#
#
# Note: TEST_ON is so that we do not actually talk to the real device,
# instead jq parses the given testData.
#
# Then afterwards:
# $status - is the result of the ./compare/AdvAir.sh command
# ${lines[0]} - is an array of text from the ./compare/AdvAir.sh command
# assert_equal "${lines[0]}" "Try 0" - compares the output in line 0.
setup()
{
load './test/setup'
_common_setup
}
teardown()
{
_common_teardown
}
@test "AdvAir ( ezone inline ) Test PassOn1 Get Brightness z01" {
# We symbolically link the directory of the test we want to use.
ln -s ./testData/dataPassOn1 ./data
# The original scripts do not have this function, so you can only
# test against known data
run ./compare/AdvAir.sh Get Blah Brightness z01 192.168.50.99 TEST_ON
assert_equal "$status" 0
assert_equal "${lines[0]}" "Try 0"
assert_equal "${lines[1]}" "100"
}
@test "AdvAir ( ezone inline ) Test PassOn1 Get Brightness z03" {
ln -s ./testData/dataPassOn1 ./data
run ./compare/AdvAir.sh Get Blah Brightness z03 192.168.50.99 TEST_ON
assert_equal "$status" 0
assert_equal "${lines[0]}" "Try 0"
assert_equal "${lines[1]}" "85"
}
Oh, I wonder... You have changed all the IP addresses to your own? I think they all used to be based on mine haha...
I did not change any IP address, that was JohnT's version. I only done a very minor eidts on the SetOn.bats and SetTargetHeatingCoolingTemperature.bats to reflect that I do not have a Get
before a Set
on those.
My IP is 192.168.0.31.
All good, I will take a look if the IP address change fixes them for me; otherwise I am not terribly concerned at this point as it will not affect users.
name: Pull Request about: add an improvement to homebridge-cmd4-AdvantageAir. title: "Added support for multiple aircon systems and ability to flip open/close" labels: pull-request assignees: mitch7391
Added support for multiple aircon systems and added the ability to flip the garage's or gate's open/close
Is your pull request related to a problem or a new feature? Please describe: New features:
ac1
,ac2
,ac3
,ac4
andac5
)queryAirConWithIterations()
+ quite a bit of other refinements.SetOn.bats
andSetTargetHeatingCoolingTemperature.bats
of JohnT's latestunit tests
. JohnT updated theunit tests
to reflect the use of the new functionqueryAirConWithIterations()
.Describe the solution you'd have implemented:
ac1
,ac2
,ac3
,ac4
,ac5
) which can be specified with a constant instate_cmd_suffix
flip
which can be specified instate-cmd-suffix
of garage/gate accessory to enable the flipping of open/close display on HomekitDo your changes pass local testing:
unit tests
(JohnT's latest version) and passed local testing on my E-zone system but have to rely on other users to test the flipping of garage open/close and aircon system other than ac1.Additional context:
ac2
orac3
orac4
orac5
) specified as a constant instate_cmd_suffix
.Below is a sample config of accessory
Thermostat
for aircon systemac2
:flip
in your garage or gate accessory'sstate_cmd_sufix
: