Skip to content

Commit

Permalink
Add support for Yale Home (non-US API)
Browse files Browse the repository at this point in the history
  • Loading branch information
hufftheweevil committed Oct 31, 2023
1 parent 2ea9704 commit a0e0a7a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package.json
@@ -1,13 +1,13 @@
{
"name": "node-red-contrib-august",
"version": "1.1.0",
"version": "1.2.0",
"description": "Node-RED node to connect to August locks",
"main": "index.js",
"scripts": {},
"author": "hufftheweevil",
"license": "MIT",
"dependencies": {
"august-api": "^1.4.0"
"august-api": "^1.5.0"
},
"node-red": {
"version": ">=2.0.0",
Expand Down
20 changes: 18 additions & 2 deletions red/august-account.html
Expand Up @@ -14,7 +14,8 @@
category: 'config',
defaults: {
augustId: { type: 'text', required: true },
validated: { type: 'boolean', value: false }
validated: { type: 'boolean', value: false },
api: { type: 'text', value: 'August' }
},
credentials: {
password: { type: 'password', required: true }
Expand All @@ -28,7 +29,8 @@
let getConfig = () => ({
installId: this.id,
augustId: $('#node-config-input-augustId').val(),
password: $('#node-config-input-password').val()
password: $('#node-config-input-password').val(),
api: $('#node-input-api').val()
})

let validationContainer = $('#august-validation')
Expand Down Expand Up @@ -107,6 +109,10 @@
)
})
}
},
oneditsave: function () {
// Manually save value
this.api = $('#node-input-api').val()
}
})
</script>
Expand All @@ -120,6 +126,16 @@
<label for="node-config-input-password"><i class="fa fa-lock"></i> Password</label>
<input type="password" id="node-config-input-password" />
</div>
<div class="form-row">
<label for="node-input-api"><i class="fa fa-key"></i> API</label>
<div style="display: inline-block; position: relative; width: 70%; height: 20px;">
<select id="node-input-api" style="width: 50%">
<option value="August">August</option>
<option value="Yale Access">Yale Access</option>
<option value="Yale Home">Yale Home</option>
</select>
</div>
</div>
<div class="form-row" style="display:flex">
<label for="node-config-input-validated"><i class="fa fa-check"></i> Validated</label>
<div id="august-validation" style="display:flex; flex-direction:column; gap:10px"></div>
Expand Down
3 changes: 2 additions & 1 deletion red/august-account.js
Expand Up @@ -16,7 +16,8 @@ module.exports = function (RED) {
this.api = new AugustAPI({
installId: config.id, // Use node ID (means any new config node must be validated)
augustId: config.augustId,
password: this.credentials.password
password: this.credentials.password,
countryCode: config.api === 'Yale Home' ? 'non-US' : 'US' // Can be any value other than 'US' for Yale Home
})
this.api.validated = config.validated // TEST ONLY
} catch (err) {
Expand Down

0 comments on commit a0e0a7a

Please sign in to comment.