Skip to content

Commit

Permalink
0.1.6 with configurable storage location
Browse files Browse the repository at this point in the history
  • Loading branch information
sammachin committed Jan 19, 2025
1 parent 62e28c7 commit dcd5c22
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 1 deletion.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [0.1.6] - 2025-01-19

### Changed
The controller now supports a configurable storage location, see the README for details of how this can be changed, My default the package will continue to use the default of $HOME/.matter.
Changing this on a configured system without manually copying the files to the new location will result in errors.
If you are running Node-RED in a container like Docker then you will likely want to update this to a persistant file storage location.


## [0.1.5] - 2025-01-16

### Fixed
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ If the device uses Thread rather than WiFi then it will be using the Thread Bord

This controller exposes a lower level of Matter compared to most consumer systems (eg Apple, Google etc) This is to allow for support of all possible device types without requiring a vast number of nodes and options to be created. Eventually I may create additional nodes for specific device control if there is demand.

### Storage Location

Matter.js requires a persistant file store to keep detauls of the fabric configuration, keys, device IDs etc. By default this is in a .matter folder in the users home dir.
From v.0.1.6 this path is configurable, so if running Node-RED under Docker you will need to set this to a path backed by persistant storage (eg /data)

You Should set this path _before_ you start commisioning any devices as changing it with existing devices can cause a crash. However if you want to move the location from the default to a new path you should stop node red and then move all the files in ~/.matter to the new location. Then start Node-RED and edit the location in the controller config node.


### Device Setup
In order to start using the controller you will need to be able to commision a device,
Expand Down
17 changes: 17 additions & 0 deletions controller.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
defaults: {
name: {value:""},
networkInterface : {required: true},
storageLocation: {required: true},
logLevel: {value: "ERROR"}
},
label: function() {
Expand All @@ -29,6 +30,17 @@
.error(function(e) {
console.log(e.status);
})
console.log(this.storageLocation)
if (!this.storageLocation){
$.get('_mattercontroller/homedir', function(r) {
defaultLocation=(`${r}/.matter`)
let sLoc = document.getElementById('node-config-input-storageLocation');
sLoc.value = defaultLocation
})
.error(function(e) {
console.log(e.status);
})
}
}
});
</script>
Expand All @@ -45,6 +57,11 @@
<select type="text" id="node-config-input-networkInterface" style="width:50%;" >
</select>
</div>
<div class="form-row">
<label for="node-config-input-storageLocation">Storage Location</label>
<input type="text" id="node-config-input-storageLocation" style="width:50%;" >
</select>
</div>
<div class="form-row">
<label for="node-config-input-logLevel">Log Level</label>
<select type="text" id="node-config-input-logLevel" style="width:50%;" >
Expand Down
9 changes: 9 additions & 0 deletions controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = function(RED) {
var node = this;
node.started = false
node.networkInterface = config.networkInterface
node.storageLocation = config.storageLocation
switch (config.logLevel) {
case "FATAL":
Logger.defaultLogLevel = 5;
Expand All @@ -33,6 +34,14 @@ module.exports = function(RED) {
break;
}
Environment.default.vars.set('mdns.networkInterface', node.networkInterface);
let ss = environment.get(StorageService);
if (node.storageLocation){
ss.location = node.storageLocation;
environment.set(StorageService, ss)
node.log(`Using Custom Storage Location: ${ss.location}`)
} else {
node.log(`Using Default Storage Location: ${ss.location}`)
}
node.commissioningController = new CommissioningController({
environment: {
environment,
Expand Down
6 changes: 6 additions & 0 deletions editor_apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,10 @@ RED.httpAdmin.get('/_mattermodel/cluster/:clid/attribute/:attr/options', RED.aut
let data = attributeOptions(req.params.clid, req.params.attr)
res.send(data)
})

RED.httpAdmin.get('/_mattercontroller/homedir', RED.auth.needsPermission('admin.write'), function(req,res){
const homedir = require('os').homedir();
res.send(homedir)
})

}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sammachin/node-red-matter-controller",
"version": "0.1.5",
"version": "0.1.6",
"description": "Matter Device Controller for Node-RED",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit dcd5c22

Please sign in to comment.