homebridge-myplace 2.0.2 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,4 +1,8 @@
1
1
  ### Homebridge-myplace - An independent plugin for Homebridge bringing Advantage Air MyPlace system, its smaller siblings (E-zone, MyAir, MyAir4, etc) and its cousins (e.g. Fujitsu AnywAir) to Homekit
2
- ##### v2.0.2 (2024-09-18)
2
+ ##### v2.1.0 (2024-10-18)
3
+
4
+ ###### (1) Added a Thermostat on each temperature controlled Zone
5
+ ###### (2) Enhanced UUID generation
6
+ ###### (3) Bug fixes
7
+ ###### (4) Update to README.md
3
8
 
4
- ###### (1) Re-coded ConfigCreator to use jq to create all config and enabled updating of devices info in config.json even when it is run from terminal.
package/CheckConfig.sh CHANGED
@@ -1,22 +1,13 @@
1
1
  #!/bin/bash
2
2
  #
3
- # This script is to check the Cmd5 configuration file for myplace plugin
3
+ # This script is to check the MyPlace configuration file for myplace plugin
4
4
  #
5
5
  # Usage ./CheckConfig.sh
6
6
  #
7
7
 
8
- # define the possible names for MyPlace platform
9
- cmd5Platform1="\"platform\": \"MyPlace\""
10
- cmd5Platform2="\"platform\": \"homebridge-myplace\""
11
-
12
- # define some file variables
13
- homebridgeConfigJson="" # homebridge config.json
14
- configJson="config.json.copy" # a working copy of homebridge config.json
15
-
16
8
  # fun color stuff
17
9
  BOLD=$(tput bold)
18
10
  TRED=$(tput setaf 1)
19
- #TGRN=$(tput setaf 2)
20
11
  TYEL=$(tput setaf 3)
21
12
  TPUR=$(tput setaf 5)
22
13
  TLBL=$(tput setaf 6)
@@ -27,13 +18,14 @@ function readHomebridgeConfigJson()
27
18
  INPUT=""
28
19
  homebridgeConfigJson=""
29
20
  getHomebridgeConfigJsonPath
30
- if [ "${fullPath}" != "" ]; then homebridgeConfigJson="${fullPath}"; fi
31
-
32
- # if no config.json file found, ask user to input the full path
33
- if [ -z "${homebridgeConfigJson}" ]; then
34
- homebridgeConfigJson=""
21
+ if [ "${fullPath}" != "" ]; then
22
+ homebridgeConfigJson="${fullPath}"
23
+ echo "${TLBL}INFO: Valid Homebridge config.json found: ${homebridgeConfigJson}${TNRM}"
24
+ echo ""
25
+ else
26
+ # if no valid config.json file found, ask user to manually specify the full path
35
27
  echo ""
36
- echo "${TPUR}WARNING: No valid Homebridge config.json file located by the script!${TNRM}"
28
+ echo "${TPUR}WARNING: No valid Homebridge config.json located by the script!${TNRM}"
37
29
  echo ""
38
30
  until [ -n "${INPUT}" ]; do
39
31
  echo "${TYEL}Please enter the full path of your Homebridge config.json file,"
@@ -41,7 +33,6 @@ function readHomebridgeConfigJson()
41
33
  read -r -p "${BOLD}> ${TNRM}" INPUT
42
34
  if [ -z "${INPUT}" ]; then
43
35
  echo "${TPUR}WARNING: No Homebridge config.json file specified"
44
- cleanUp
45
36
  exit 1
46
37
  elif expr "${INPUT}" : '[./a-zA-Z0-9]*/config.json$' >/dev/null; then
47
38
  if [ -f "${INPUT}" ]; then
@@ -60,29 +51,21 @@ function readHomebridgeConfigJson()
60
51
  INPUT=""
61
52
  fi
62
53
  done
63
- fi
64
- if [ -f "${homebridgeConfigJson}" ]; then
65
- if [ -z "${INPUT}" ]; then
66
- echo "${TLBL}INFO: The Homebridge config.json found: ${homebridgeConfigJson}${TNRM}"
54
+ # check that this specified config.json is valid - has "MyPlace" platform in it.
55
+ fullPath="${homebridgeConfigJson}"
56
+ checkForMyPlacePlatformInFile
57
+ if [ -z "${myPlacePlatformFound}" ]; then
67
58
  echo ""
59
+ echo "${TRED}ERROR: MyPlace Config specified in \"${homebridgeConfigJson}\" is invalid. Please ensure that homebridge-myplace plugin is installed and configured${TNRM}"
60
+ exit 1
68
61
  else
69
62
  echo ""
70
- echo "${TLBL}INFO: The Homebridge config.json specified: ${homebridgeConfigJson}${TNRM}"
63
+ echo "${TLBL}INFO: Valid Homebridge config.json specified: ${homebridgeConfigJson}${TNRM}"
71
64
  echo ""
72
65
  fi
73
- # expand the json just in case it is in compact form
74
- jq --indent 4 '.' "${homebridgeConfigJson}" > "${configJson}"
75
- checkForPlatformCmd5InHomebridgeConfigJson
76
- if [ -z "${validFile}" ]; then
77
- echo ""
78
- echo "${TRED}ERROR: no Cmd5 Config found in \"${homebridgeConfigJson}\"! Please ensure that Homebridge-MyPlace plugin is installed${TNRM}"
79
- cleanUp
80
- exit 1
81
- fi
82
66
  fi
83
67
  }
84
68
 
85
-
86
69
  function getGlobalNodeModulesPathForFile()
87
70
  {
88
71
  file="$1"
@@ -170,8 +153,8 @@ function getHomebridgeConfigJsonPath()
170
153
  if [ -n "${Hoobs}" ]; then
171
154
  fullPath="${MYPLACE_SH_PATH%/*/*/*}/config.json"
172
155
  if [ -f "${fullPath}" ]; then
173
- checkForCmd5PlatformNameInFile
174
- if [ -z "${cmd5PlatformNameFound}" ]; then
156
+ checkForMyPlacePlatformInFile
157
+ if [ -z "${myPlacePlatformFound}" ]; then
175
158
  fullPath=""
176
159
  fi
177
160
  return
@@ -183,8 +166,8 @@ function getHomebridgeConfigJsonPath()
183
166
  1)
184
167
  fullPath="/var/lib/homebridge/config.json"
185
168
  if [ -f "${fullPath}" ]; then
186
- checkForCmd5PlatformNameInFile
187
- if [ -n "${cmd5PlatformNameFound}" ]; then
169
+ checkForMyPlacePlatformInFile
170
+ if [ -n "${myPlacePlatformFound}" ]; then
188
171
  return
189
172
  else
190
173
  fullPath=""
@@ -194,8 +177,8 @@ function getHomebridgeConfigJsonPath()
194
177
  2)
195
178
  fullPath="$HOME/.homebridge/config.json"
196
179
  if [ -f "${fullPath}" ]; then
197
- checkForCmd5PlatformNameInFile
198
- if [ -n "${cmd5PlatformNameFound}" ]; then
180
+ checkForMyPlacePlatformInFile
181
+ if [ -n "${myPlacePlatformFound}" ]; then
199
182
  return
200
183
  else
201
184
  fullPath=""
@@ -208,8 +191,8 @@ function getHomebridgeConfigJsonPath()
208
191
  for ((i = 1; i <= noOfInstances; i ++)); do
209
192
  fullPath=$(echo "${foundPath}"|sed -n "${i}"p)
210
193
  if [ -f "${fullPath}" ]; then
211
- checkForCmd5PlatformNameInFile
212
- if [ -n "${cmd5PlatformNameFound}" ]; then
194
+ checkForMyPlacePlatformInFile
195
+ if [ -n "${myPlacePlatformFound}" ]; then
213
196
  return
214
197
  else
215
198
  fullPath=""
@@ -223,8 +206,8 @@ function getHomebridgeConfigJsonPath()
223
206
  for ((i = 1; i <= noOfInstances; i ++)); do
224
207
  fullPath=$(echo "${foundPath}"|sed -n "${i}"p)
225
208
  if [ -f "${fullPath}" ]; then
226
- checkForCmd5PlatformNameInFile
227
- if [ -n "${cmd5PlatformNameFound}" ]; then
209
+ checkForMyPlacePlatformInFile
210
+ if [ -n "${myPlacePlatformFound}" ]; then
228
211
  return
229
212
  else
230
213
  fullPath=""
@@ -238,8 +221,8 @@ function getHomebridgeConfigJsonPath()
238
221
  for ((i = 1; i <= noOfInstances; i ++)); do
239
222
  fullPath=$(echo "${foundPath}"|sed -n "${i}"p)
240
223
  if [ -f "${fullPath}" ]; then
241
- checkForCmd5PlatformNameInFile
242
- if [ -n "${cmd5PlatformNameFound}" ]; then
224
+ checkForMyPlacePlatformInFile
225
+ if [ -n "${myPlacePlatformFound}" ]; then
243
226
  return
244
227
  else
245
228
  fullPath=""
@@ -253,8 +236,8 @@ function getHomebridgeConfigJsonPath()
253
236
  for ((i = 1; i <= noOfInstances; i ++)); do
254
237
  fullPath=$(echo "${foundPath}"|sed -n "${i}"p)
255
238
  if [ -f "${fullPath}" ]; then
256
- checkForCmd5PlatformNameInFile
257
- if [ -n "${cmd5PlatformNameFound}" ]; then
239
+ checkForMyPlacePlatformInFile
240
+ if [ -n "${myPlacePlatformFound}" ]; then
258
241
  return
259
242
  else
260
243
  fullPath=""
@@ -266,60 +249,15 @@ function getHomebridgeConfigJsonPath()
266
249
  done
267
250
  }
268
251
 
269
- function checkForPlatformCmd5InHomebridgeConfigJson()
270
- {
271
- validFile=""
272
- for ((tryIndex = 1; tryIndex <= 2; tryIndex ++)); do
273
- case $tryIndex in
274
- 1)
275
- validFile=$(grep -n "${cmd5Platform1}" "${configJson}"|cut -d":" -f1)
276
- if [ -n "${validFile}" ]; then
277
- return
278
- fi
279
- ;;
280
- 2)
281
- validFile=$(grep -n "${cmd5Platform2}" "${configJson}"|cut -d":" -f1)
282
- if [ -n "${validFile}" ]; then
283
- return
284
- fi
285
- ;;
286
- esac
287
- done
288
- }
289
-
290
- function checkForCmd5PlatformNameInFile()
291
- {
292
- cmd5PlatformNameFound=""
293
-
294
- for ((Index = 1; Index <= 2; Index ++)); do
295
- case $Index in
296
- 1)
297
- cmd5PlatformName=$(echo "${cmd5Platform1}"|cut -d'"' -f4)
298
- cmd5PlatformNameFound=$(grep -n "\"${cmd5PlatformName}\"" "${fullPath}"|cut -d":" -f1)
299
- if [ -n "${cmd5PlatformNameFound}" ]; then
300
- return
301
- fi
302
- ;;
303
- 2)
304
- cmd5PlatformName=$(echo "${cmd5Platform2}"|cut -d'"' -f4)
305
- cmd5PlatformNameFound=$(grep -n "\"${cmd5PlatformName}\"" "${fullPath}"|cut -d":" -f1)
306
- if [ -n "${cmd5PlatformNameFound}" ]; then
307
- return
308
- fi
309
- ;;
310
- esac
311
- done
312
- }
313
-
314
-
315
- function cleanUp()
252
+ function checkForMyPlacePlatformInFile()
316
253
  {
317
- rm -f "${configJson}"
254
+ myPlacePlatformFound=""
255
+ myPlacePlatformFound=$(grep -n "\"MyPlace\"" "${fullPath}" )
318
256
  }
319
257
 
320
258
  # main starts here
321
259
 
322
- echo "${TYEL}This script is to check that the Cmd5 configuration file meets all requirements${TNRM}"
260
+ echo "${TYEL}This script is to check that the MyPlace configuration file meets all requirements${TNRM}"
323
261
  echo ""
324
262
 
325
263
  echo "${TYEL}CheckConfig engine:${TNRM}"
@@ -369,5 +307,4 @@ readHomebridgeConfigJson
369
307
  if [[ -f "${homebridgeConfigJson}" && -f "${MYPLACE_SH_PATH}" ]]; then
370
308
  echo "${TYEL}CheckConfig in progress.......${TNRM}"
371
309
  node "${CHECKCONFIG_PATH}" "$MYPLACE_SH_PATH" "${homebridgeConfigJson}"
372
- cleanUp
373
310
  fi
@@ -131,6 +131,16 @@ class Cmd5PriorityPollingQueue
131
131
  // Abort this Set request
132
132
  return;
133
133
  }
134
+ // Reject Set requests to change Thermostat targetHeatingCoolingState for Zone Thermostat
135
+ if ( this.typeIndex == 57 && this.displayName.match ( / Thermostat$/ ) &&
136
+ characteristicString == 'TargetHeatingCoolingState'
137
+ )
138
+ {
139
+ let storedValue = this.cmd5Storage.getStoredValueForIndex( accTypeEnumIndex );
140
+ this.service.getCharacteristic( CMD5_ACC_TYPE_ENUM.properties[ accTypeEnumIndex ].characteristic ).updateValue( storedValue );
141
+ // Abort this Set request
142
+ return;
143
+ }
134
144
  // Turn on the Zone when this Zone is set as myZone
135
145
  else if ( this.typeIndex == 20 && this.displayName.match ( / Zone$/ ) &&
136
146
  characteristicString == 'RotationDirection' && value == 0