Skip to content

Commit

Permalink
Merge pull request #86 from Luligu/dev
Browse files Browse the repository at this point in the history
Release 1.3.13
  • Loading branch information
Luligu authored Jul 11, 2024
2 parents e9b5a46 + 437ac43 commit eb520d1
Show file tree
Hide file tree
Showing 17 changed files with 100 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-buildx-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
--platform linux/amd64,linux/arm64,linux/arm/v7 \
-f docker/Dockerfile.main \
-t luligu/matterbridge:latest \
-t luligu/matterbridge:1.3.12 \
-t luligu/matterbridge:1.3.13 \
--push .
docker manifest inspect luligu/matterbridge:latest
timeout-minutes: 60
36 changes: 36 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Publish to npm

on:
release:
types: [created]

jobs:
publish:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: npm install

- name: Lint the project
run: npm run lint

- name: Test the project
run: npm run test

- name: Build the project
run: npm run build

- name: Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ bridge-groups.json
# storage
.matterbridge.json
.matterbridge.backup.json
node_storage
/storage
/node_storage

# eslint
.eslintrc
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@ 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 and sponsoring it.

## [1.3.13] - 2024-07-11

### Added

### Changed

- [frontend]: The Logs window in the Home page has the same filter as the Logs page.
- [matterbridge]: The plugins debug is now indipendent from matterbridge debug and matter.js log level. It can be set from the plugin config.

### Fixed

- [frontend]: Fix Home page for mobile (the page doesn't "jump" anymore with touchscreens).
- [matterbridge]: Fixed npm ignore for exports.
- [matterbridge]: Fixed load plugin when the don't have author and description.

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

## [1.3.12] - 2024-07-10

### Added
Expand Down
6 changes: 3 additions & 3 deletions frontend/build/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"files": {
"main.css": "/static/css/main.b4d28450.css",
"main.js": "/static/js/main.3105733e.js",
"main.js": "/static/js/main.42130514.js",
"static/js/453.d855a71b.chunk.js": "/static/js/453.d855a71b.chunk.js",
"index.html": "/index.html",
"main.b4d28450.css.map": "/static/css/main.b4d28450.css.map",
"main.3105733e.js.map": "/static/js/main.3105733e.js.map",
"main.42130514.js.map": "/static/js/main.42130514.js.map",
"453.d855a71b.chunk.js.map": "/static/js/453.d855a71b.chunk.js.map"
},
"entrypoints": [
"static/css/main.b4d28450.css",
"static/js/main.3105733e.js"
"static/js/main.42130514.js"
]
}
2 changes: 1 addition & 1 deletion frontend/build/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/matterbridge 32x32.png"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><title>Matterbridge</title><link rel="manifest" href="/manifest.json"/><script defer="defer" src="/static/js/main.3105733e.js"></script><link href="/static/css/main.b4d28450.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/matterbridge 32x32.png"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><title>Matterbridge</title><link rel="manifest" href="/manifest.json"/><script defer="defer" src="/static/js/main.42130514.js"></script><link href="/static/css/main.b4d28450.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
1 change: 0 additions & 1 deletion frontend/build/static/js/main.3105733e.js.map

This file was deleted.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions frontend/build/static/js/main.42130514.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion frontend/src/components/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ function Home() {

<div className="MbfWindowDiv" style={{flex: '1 1 auto', width: '100%', overflow: 'hidden'}}>
<div className="MbfWindowHeader" style={{ flexShrink: 0 }}>
<p className="MbfWindowHeaderText" style={{ display: 'flex', justifyContent: 'space-between' }}>Logs <span style={{ fontWeight: 'normal' }}>Filter: debug level "{logDebugLevel}" and search "{logSearchCriteria}"</span></p>
<p className="MbfWindowHeaderText" style={{ display: 'flex', justifyContent: 'space-between' }}>Logs <span style={{ fontWeight: 'normal', fontSize: '12px',marginTop: '2px' }}>Filter: logger level "{logDebugLevel}" and search "{logSearchCriteria}"</span></p>
</div>
<div style={{ flex: '1 1 auto', margin: '0px', padding: '0px', overflow: 'auto'}}>
<WebSocketComponent wssHost={wssHost} debugLevel={logDebugLevel} searchCriteria={logSearchCriteria}/>
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/components/Logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import InputLabel from '@mui/material/InputLabel';
import MenuItem from '@mui/material/MenuItem';
import Select from '@mui/material/Select';

// export const MatterbridgeInfoContext = React.createContext();

function Logs() {
const [wssHost, setWssHost] = useState(null);
const [debugLevel, setDebugLevel] = useState(localStorage.getItem('logFilterLevel')??'debug');
Expand Down
43 changes: 15 additions & 28 deletions frontend/src/components/WebSocketComponent.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
/* global DocumentTouch */
import React, { useState, useEffect, useRef } from 'react';
import useWebSocket from './useWebSocket';

const detectTouchscreen = () => {
let hasTouchscreen = false;
if ('ontouchstart' in window || (window.DocumentTouch && document instanceof DocumentTouch)) {
hasTouchscreen = true;
}
return hasTouchscreen;
};

function WebSocketComponent(props) {
const { wssHost, debugLevel, searchCriteria } = props;
const [ message, setMessage ] = useState('');
const { messages, sendMessage } = useWebSocket(wssHost, debugLevel, searchCriteria);
const endOfMessagesRef = useRef(null); // Create a ref for scrolling purposes
const [isHovering, setIsHovering] = useState(false); // State to track mouse hover

// console.log(`WebSocketComponent: wssHost: ${wssHost} debugLevel: ${debugLevel} searchCriteria: ${searchCriteria}`);

// Scroll to the bottom of the message list on every update, only if already at bottom
const handleMouseEnter = () => setIsHovering(true);
const handleMouseLeave = () => setIsHovering(false);

// Scroll to the bottom of the message list on every update, only if the user is not hovering and not on a touchscreen
useEffect(() => {
if (!isHovering) {
if (!isHovering && !detectTouchscreen()) {
// console.log(`isHovering: ${isHovering}`);
endOfMessagesRef.current.scrollIntoView({ behavior: 'smooth' });
}
}, [messages, isHovering]);

return (
<div style={{ margin: '0px', padding: '0px' }}>
<ul onMouseEnter={() => setIsHovering(true)} onMouseLeave={() => setIsHovering(false)}>
<ul onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave}>
{messages.map((msg, index) => (
<li key={index} dangerouslySetInnerHTML={{ __html: msg }} />
))}
Expand All @@ -32,26 +42,3 @@ function WebSocketComponent(props) {
}

export default WebSocketComponent;

/*
<div>
<ul style={{ margin: '10px', padding: '10px' }}
onMouseEnter={() => setIsHovering(true)}
onMouseLeave={() => setIsHovering(false)}>
{messages.map((msg, index) => (
<li key={index}>{msg}</li>
))}
<div ref={endOfMessagesRef} /> {// Invisible element to mark the end }
</ul>
</div>
<input
type="text"
value={message}
onChange={(e) => setMessage(e.target.value)}
placeholder="Enter message"
/>
<button onClick={() => { sendMessage(message); setMessage(''); }}>
Send Message
</button>
*/
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "matterbridge",
"version": "1.3.12",
"version": "1.3.13",
"description": "Matterbridge plugin manager for Matter",
"author": "https://github.com/Luligu",
"license": "Apache-2.0",
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export * from '@project-chip/matter.js/util';
export * from '@project-chip/matter.js/schema';
export * from '@project-chip/matter.js/tlv';

// TODO Remove in august 2024
export * from 'matter-history';

export * from './matterbridge.js';
Expand Down
14 changes: 7 additions & 7 deletions src/matterbridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,8 @@ export class Matterbridge extends EventEmitter {
// Update the plugin information
plugin.name = packageJson.name as string;
plugin.version = packageJson.version as string;
plugin.description = packageJson.description as string;
plugin.author = packageJson.author as string;
plugin.description = (packageJson.description as string) ?? 'No description';
plugin.author = (packageJson.author as string) ?? 'Unknown';
} else {
this.log.info(`Error parsing plugin ${plg}${plugin.name}${nf}. Trying to reinstall it from npm.`);
try {
Expand Down Expand Up @@ -1717,15 +1717,15 @@ export class Matterbridge extends EventEmitter {
// Call the default export function of the plugin, passing this MatterBridge instance, the log and the config
if (pluginInstance.default) {
const config: PlatformConfig = await this.loadPluginConfig(plugin);
const log = new AnsiLogger({ logName: plugin.description, logTimestampFormat: TimestampFormat.TIME_MILLIS, logDebug: (config.debug as boolean) ?? false });
const log = new AnsiLogger({ logName: plugin.description ?? 'No description', logTimestampFormat: TimestampFormat.TIME_MILLIS, logDebug: (config.debug as boolean) ?? false });
const platform = pluginInstance.default(this, log, config) as MatterbridgePlatform;
platform.name = packageJson.name;
platform.config = config;
platform.version = packageJson.version;
plugin.name = packageJson.name;
plugin.description = packageJson.description;
plugin.description = packageJson.description ?? 'No description';
plugin.version = packageJson.version;
plugin.author = packageJson.author;
plugin.author = packageJson.author ?? 'Unknown';
plugin.type = platform.type;
plugin.platform = platform;
plugin.loaded = true;
Expand Down Expand Up @@ -3403,7 +3403,7 @@ export class Matterbridge extends EventEmitter {
if (command === 'update') {
this.log.info('Updating matterbridge...');
try {
await this.spawnCommand('npm', ['install', '-g', 'matterbridge', '--loglevel=verbose']);
await this.spawnCommand('npm', ['install', '-g', 'matterbridge' /* , '--loglevel=verbose'*/]);
this.log.info('Matterbridge has been updated. Full restart required.');
} catch (error) {
this.log.error('Error updating matterbridge');
Expand All @@ -3429,7 +3429,7 @@ export class Matterbridge extends EventEmitter {
param = param.replace(/\*/g, '\\');
this.log.info(`Installing plugin ${plg}${param}${nf}...`);
try {
await this.spawnCommand('npm', ['install', '-g', param, '--loglevel=verbose']);
await this.spawnCommand('npm', ['install', '-g', param /* , '--loglevel=verbose'*/]);
this.log.info(`Plugin ${plg}${param}${nf} installed. Full restart required.`);
} catch (error) {
this.log.error(`Error installing plugin ${plg}${param}${er}`);
Expand Down
12 changes: 9 additions & 3 deletions src/matterbridgeDevice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -671,10 +671,9 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods<typeof Device
}

/**
* Serializes the Matterbridge device into a serialized object.
* Deserializes the device into a serialized object.
*
* @param pluginName - The name of the plugin.
* @returns The serialized Matterbridge device object.
* @returns The deserialized MatterbridgeDevice.
*/
static deserialize(serializedDevice: SerializedMatterbridgeDevice): MatterbridgeDevice {
const device = new MatterbridgeDevice(serializedDevice.deviceTypes);
Expand Down Expand Up @@ -707,6 +706,7 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods<typeof Device
/**
* Returns a default static EveHistoryClusterServer object with the specified voltage, current, power, and consumption values.
* This shows up in HA as a static sensor!
* @deprecated This method is deprecated and will be removed in a future version.
* @param voltage - The voltage value (default: 0).
* @param current - The current value (default: 0).
* @param power - The power value (default: 0).
Expand Down Expand Up @@ -743,6 +743,7 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods<typeof Device
/**
* Create a default static EveHistoryClusterServer object with the specified voltage, current, power, and consumption values.
* This shows up in HA as a static sensor!
* @deprecated This method is deprecated and will be removed in a future version.
* @param voltage - The voltage value (default: 0).
* @param current - The current value (default: 0).
* @param power - The power value (default: 0).
Expand All @@ -755,6 +756,7 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods<typeof Device

/**
* Creates a room Eve History Cluster Server.
* @deprecated This method is deprecated and will be removed in a future version.
*
* @param history - The MatterHistory object.
* @param log - The AnsiLogger object.
Expand Down Expand Up @@ -826,6 +828,7 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods<typeof Device

/**
* Creates a Weather Eve History Cluster Server.
* @deprecated This method is deprecated and will be removed in a future version.
*
* @param history - The MatterHistory instance.
* @param log - The AnsiLogger instance.
Expand Down Expand Up @@ -900,6 +903,7 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods<typeof Device

/**
* Creates an Energy Eve History Cluster Server.
* @deprecated This method is deprecated and will be removed in a future version.
*
* @param history - The MatterHistory object.
* @param log - The AnsiLogger object.
Expand Down Expand Up @@ -992,6 +996,7 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods<typeof Device

/**
* Creates a Motion Eve History Cluster Server.
* @deprecated This method is deprecated and will be removed in a future version.
*
* @param history - The MatterHistory object.
* @param log - The AnsiLogger object.
Expand Down Expand Up @@ -1069,6 +1074,7 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods<typeof Device

/**
* Creates a door EveHistoryCluster server.
* @deprecated This method is deprecated and will be removed in a future version.
*
* @param history - The MatterHistory instance.
* @param log - The AnsiLogger instance.
Expand Down

0 comments on commit eb520d1

Please sign in to comment.