Skip to content

Commit

Permalink
Merge pull request #70 from Luligu/dev
Browse files Browse the repository at this point in the history
Release 1.0.4
  • Loading branch information
Luligu authored Oct 17, 2024
2 parents a43060e + 915307c commit 916564f
Show file tree
Hide file tree
Showing 25 changed files with 1,016 additions and 112 deletions.
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ All notable changes to this project will be documented in this file.

If you like this project and find it useful, please consider giving it a star on GitHub at https://github.com/Luligu/matterbridge-shelly and sponsoring it.

## [1.0.4] - 2024-10-17

### Added

- [shelly]: Added support for shellyht (Shelly H&T Gen 1) with firmware v1.14.0-gcb84623 and added Jest test (components: Temperature, Humidity and Battery). Verified and tested by Tamer.
- [shelly]: Added mdns Jest test for shellyht (Shelly H&T Gen 1) with firmware v1.14.0-gcb84623.

### Changed

- [package]: Updated dependencies.

<a href="https://www.buymeacoffee.com/luligugithub">
<img src="./yellow-button.png" alt="Buy me a coffee" width="120">
</a>

## [1.0.3] - 2024-10-15

### Added
Expand All @@ -12,7 +27,7 @@ If you like this project and find it useful, please consider giving it a star on

### Changed

- [BTHome]: Changed required version of matterbridge to 1.5.9.
- [plugin]: Changed required version of matterbridge to 1.5.9.
- [package]: Updated dependencies.

<a href="https://www.buymeacoffee.com/luligugithub">
Expand Down
25 changes: 5 additions & 20 deletions matterbridge-shelly.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@
"exposeSwitch": {
"description": "Choose how to expose the shelly switches: as a switch (don't use it for Alexa), light or outlet",
"type": "string",
"enum": [
"switch",
"light",
"outlet"
],
"enum": ["switch", "light", "outlet"],
"default": "outlet"
},
"switchList": {
Expand All @@ -55,12 +51,7 @@
"exposeInput": {
"description": "Choose how to expose the shelly inputs: disabled, contact, momentary or latching switch (you may need to pair again the controller when changed)",
"type": "string",
"enum": [
"disabled",
"contact",
"momentary",
"latching"
],
"enum": ["disabled", "contact", "momentary", "latching"],
"default": "disabled"
},
"inputContactList": {
Expand All @@ -87,10 +78,7 @@
"exposeInputEvent": {
"description": "Choose weather to expose the shelly input events: momentary or disabled (you may need to pair again the controller when changed)",
"type": "string",
"enum": [
"momentary",
"disabled"
],
"enum": ["momentary", "disabled"],
"default": "disabled"
},
"inputEventList": {
Expand All @@ -103,10 +91,7 @@
"exposePowerMeter": {
"description": "Choose how to expose the shelly power meters: disabled, matter13 (will use Matter 1.3 electricalSensor)",
"type": "string",
"enum": [
"disabled",
"matter13"
],
"enum": ["disabled", "matter13"],
"default": "disabled"
},
"blackList": {
Expand Down Expand Up @@ -202,4 +187,4 @@
"default": false
}
}
}
}
34 changes: 17 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "matterbridge-shelly",
"version": "1.0.3",
"version": "1.0.4",
"description": "Matterbridge shelly plugin",
"author": "https://github.com/Luligu",
"license": "Apache-2.0",
Expand Down Expand Up @@ -127,4 +127,4 @@
"typescript": "5.6.3",
"typescript-eslint": "8.9.0"
}
}
}
10 changes: 8 additions & 2 deletions rock-s0/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ then Localization, Change Timezone.
```
rsetup
```

then User Settings, Change Hostname

then check /etc/hosts
Expand All @@ -52,7 +53,7 @@ set the hostname of the device (change rock-s0 with the new hostname you set bef

127.0.1.1 rock-s0

# Samba without password
# Samba without password (optional)

Copy the file smb.conf to /etc/samba/smb.conf

Expand Down Expand Up @@ -111,6 +112,10 @@ sudo apt install cockpit btop -y
sudo apt upgrade
```

# Install matterbridge cockpit plugin

copy the four files from cockpit directory to "\usr\share\cockpit\matterbridge"

# Prevent the journal logs to grow

```
Expand Down Expand Up @@ -162,6 +167,7 @@ sudo curl https://raw.githubusercontent.com/Luligu/matterbridge-shelly/dev/rock-
```

change twice the hostname with the new hostname you set before

```
sudo nano /etc/systemd/system/matterbridge.service
```
Expand Down Expand Up @@ -189,4 +195,4 @@ sudo systemctl start matterbridge

```
sudo journalctl -u matterbridge.service -f --output cat
```
```
27 changes: 27 additions & 0 deletions rock-s0/cockpit/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8" />
<title>Matterbridge Management</title>
<link rel="stylesheet" href="matterbridge.css" type="text/css">
<script type="text/javascript" src="../base1/cockpit.js"></script>
<script type="text/javascript" src="../manifests.js"></script>
<script type="text/javascript" src="matterbridge.js"></script>
</head>

<body>
<div id="content">
<h1>Matterbridge Dashboard</h1>
<button id="frontend-button">Open the frontend</button>
<div id="status">Loading Matterbridge status...</div>
<div id="matterbridge-current">Loading Matterbridge current version...</div>
<div id="matterbridge-latest">Loading Matterbridge latest version...</div>
<div id="shelly-current">Loading Shelly plugin current version...</div>
<div id="shelly-latest">Loading Shelly plugin latest version...</div>
<h4>System logs:</h4>
<div id="logs">Fetching logs...</div>
</div>
</body>

</html>
11 changes: 11 additions & 0 deletions rock-s0/cockpit/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "matterbridge",
"title": "Matterbridge Management",
"version": "1.0",
"menu": {
"index": {
"label": "Matterbridge"
}
},
"content-security-policy": "default-src 'self'; script-src 'self'; style-src 'self';"
}
18 changes: 18 additions & 0 deletions rock-s0/cockpit/matterbridge.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#content {
font-family: Arial, sans-serif;
padding: 20px;
}

button {
padding: 5px 10px;
margin: 10px 0;
}

#status,
#matterbridge-current,
#matterbridge-latest,
#shelly-current,
#shelly-latest,
#logs {
margin: 10px 0;
}
109 changes: 109 additions & 0 deletions rock-s0/cockpit/matterbridge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/* eslint-disable no-control-regex */
/* eslint-disable no-console */
// Wait for Cockpit to fully initialize
cockpit.transport.wait(function () {
console.log('Matterbridge Cockpit extension loaded');

// Fetch and display the Matterbridge status
function fetchStatus() {
cockpit
.spawn(['systemctl', 'is-active', 'matterbridge'])
.then(function (status) {
document.getElementById('status').innerText = `Status: ${status.trim().replace('\n', '')}`;
})
.catch(function (error) {
console.error('Error fetching Matterbridge status:', error);
document.getElementById('status').innerText = 'Error fetching status.';
});
}

// Fetch and display the Matterbridge current version
function fetchMatterbridgeCurrent() {
cockpit
.spawn(['npm', 'list', '-g', 'matterbridge'])
.then(function (status) {
// Extract the version number using a regular expression
const versionMatch = status.match(/matterbridge@(\d+\.\d+\.\d+)/);
const version = versionMatch ? versionMatch[1] : 'Unknown';
document.getElementById('matterbridge-current').innerText = `Current version: ${version}`;
})
.catch(function (error) {
console.error('Error fetching Matterbridge current version:', error);
document.getElementById('matterbridge-current').innerText = 'Error fetching Matterbridge current version.';
});
}

// Fetch and display the Matterbridge latest version
function fetchMatterbridgeLatest() {
cockpit
.spawn(['npm', 'show', 'matterbridge', 'version'])
// cockpit.spawn(["whoami"])
.then(function (status) {
document.getElementById('matterbridge-latest').innerText = `Latest version: ${status.trim()}`;
})
.catch(function (error) {
console.error('Error fetching Matterbridge latest version:', error);
document.getElementById('matterbridge-latest').innerText = 'Error fetching Matterbridge latest version.';
});
}

// Fetch and display the Shelly plugin current version
function fetchShellyCurrent() {
cockpit
.spawn(['npm', 'list', '-g', 'matterbridge-shelly'])
.then(function (status) {
// Extract the version number using a regular expression
const versionMatch = status.match(/matterbridge-shelly@(\d+\.\d+\.\d+)/);
const version = versionMatch ? versionMatch[1] : 'Unknown';
document.getElementById('shelly-current').innerText = `Shelly plugin current version: ${version}`;
})
.catch(function (error) {
console.error('Error fetching Shelly plugin current version:', error);
document.getElementById('shelly-current').innerText = 'Error fetching Shelly plugin current version.';
});
}

// Fetch and display the Shelly plugin latest version
function fetchShellyLatest() {
cockpit
.spawn(['npm', 'show', 'matterbridge-shelly', 'version'])
// cockpit.spawn(["whoami"])
.then(function (status) {
document.getElementById('shelly-latest').innerText = `Shelly plugin latest version: ${status.trim()}`;
})
.catch(function (error) {
console.error('Error fetching Shelly plugin latest version:', error);
document.getElementById('shelly-latest').innerText = 'Error fetching Shelly plugin latest version.';
});
}

// Fetch logs
function fetchLogs() {
cockpit
.spawn(['journalctl', '-u', 'matterbridge', '--no-pager', '-n', '20', '-o', 'cat'])
.then(function (logs) {
// const filteredLogs = logs.split('\n').filter(line => !line.includes('matterbridge.service')).join('\n');
logs = logs.replace(/\x1B\[[0-9;]*[m|s|u|K]/g, '');
document.getElementById('logs').innerText = logs;
})
.catch(function (error) {
console.error('Error fetching logs:', error);
document.getElementById('logs').innerText = 'Error fetching logs.';
});
}

// Reload the Matterbridge configuration
document.getElementById('frontend-button').addEventListener('click', function () {
const hostname = window.location.hostname;
const newUrl = `http://${hostname}:8283`;
window.open(newUrl, '_blank');
});

// Initial fetch of status and logs
fetchStatus();
fetchMatterbridgeCurrent();
fetchMatterbridgeLatest();
fetchShellyCurrent();
fetchShellyLatest();
fetchLogs();
});
Loading

0 comments on commit 916564f

Please sign in to comment.