Skip to content

Commit

Permalink
Merge pull request #7 from Luligu/dev
Browse files Browse the repository at this point in the history
Release 0.3.2
  • Loading branch information
Luligu authored Jun 21, 2024
2 parents 8f5a56b + 3d15c0f commit 97e387a
Show file tree
Hide file tree
Showing 10 changed files with 349 additions and 31 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

All notable changes to this project will be documented in this file.

## [0.3.2] - 2024-06-21

### Added

- [Gen1]: PowerMeter.

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

## [0.3.1] - 2024-06-19

First published release.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Features:

- Shellies are automatically discovered using mDNS.
- Discovered shellies are stored in local storage for quick loading on startup.
- In this first release, the components exposed are lights (with brightness), switches, rollers and meters.
- In this first release, the components exposed are lights (with brightness), switches, rollers and meters (with EveHistory electrical measurements).
- Shellies are controlled locally, eliminating the need for cloud or MQTT (which can be disabled).
- Shelly Gen 1 devices are controlled using the CoIoT protocol (see the note below).
- Shelly Gen 2 and Gen 3 devices are controlled using WebSocket.
Expand Down
6 changes: 3 additions & 3 deletions matterbridge-shelly.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"default": "switch"
},
"exposeInput": {
"description": "Choose how to expose the shelly inputs: disabled, contact or momentary switch",
"description": "Choose how to expose the shelly inputs: disabled, contact or momentary switch (under development)",
"type": "string",
"enum": [
"disabled",
Expand All @@ -42,14 +42,14 @@
"default": "disabled"
},
"exposePowerMeter": {
"description": "Choose how to expose the shelly power meters: disabled, matter13 (use Matter 1.3 electricalSensor) or evehistory (use Matter EveHistoryCluster)",
"description": "Choose how to expose the shelly power meters: disabled, matter13 (will use Matter 1.3 electricalSensor, don't use it now) or evehistory (use Matter EveHistoryCluster)",
"type": "string",
"enum": [
"disabled",
"matter13",
"evehistory"
],
"default": "disabled"
"default": "evehistory"
},
"blackList": {
"description": "The devices in the list will not be exposed. Use the device id (e.g. shellyplus2pm-5443b23d81f8)",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "matterbridge-shelly",
"version": "0.3.1",
"version": "0.3.2",
"description": "Matterbridge shelly plugin",
"author": "https://github.com/Luligu",
"license": "Apache-2.0",
Expand Down
31 changes: 29 additions & 2 deletions src/coapServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,38 @@ export class CoapServer extends EventEmitter {
this.log.debug(
` - id: ${CYAN}${s.I}${db} type ${CYAN}${s.T}${db} description ${CYAN}${s.D}${db} unit ${CYAN}${s.U}${db} range ${CYAN}${s.R}${db} block ${CYAN}${s.L}${db}`,
);
if (s.D === 'output') desc.push({ id: s.I, component: b.D.replace('_', ':'), property: 'ison', range: s.R });
if (s.D === 'brightness') desc.push({ id: s.I, component: b.D.replace('_', ':'), property: 'brightness', range: s.R });

// sys component
if (s.D === 'mode') desc.push({ id: s.I, component: 'sys', property: 'profile', range: s.R });
if (s.D === 'deviceTemp' && s.U !== 'F' && b.D === 'device') desc.push({ id: s.I, component: 'sys', property: 'temperature', range: s.R }); // SHSW-25
if (s.D === 'voltage' && b.D === 'device') desc.push({ id: s.I, component: 'sys', property: 'voltage', range: s.R }); // SHSW-25

// light component
if (s.D === 'output') desc.push({ id: s.I, component: b.D.replace('_', ':'), property: 'state', range: s.R });
if (s.D === 'brightness') desc.push({ id: s.I, component: b.D.replace('_', ':'), property: 'brightness', range: s.R });
if (s.D === 'gain') desc.push({ id: s.I, component: b.D.replace('_', ':'), property: 'brightness', range: s.R });
if (s.D === 'red') desc.push({ id: s.I, component: b.D.replace('_', ':'), property: 'red', range: s.R });
if (s.D === 'green') desc.push({ id: s.I, component: b.D.replace('_', ':'), property: 'green', range: s.R });
if (s.D === 'blue') desc.push({ id: s.I, component: b.D.replace('_', ':'), property: 'blue', range: s.R });
if (s.D === 'white') desc.push({ id: s.I, component: b.D.replace('_', ':'), property: 'white', range: s.R });
if (s.D === 'power' && b.D.startsWith('light')) desc.push({ id: s.I, component: 'meter:0', property: 'power', range: s.R });
if (s.D === 'energy' && b.D.startsWith('light')) desc.push({ id: s.I, component: 'meter:0', property: 'total', range: s.R });

// relay component
if (s.D === 'power' && b.D.startsWith('relay')) desc.push({ id: s.I, component: b.D.replace('_', ':').replace('relay', 'meter'), property: 'power', range: s.R });
if (s.D === 'energy' && b.D.startsWith('relay')) desc.push({ id: s.I, component: b.D.replace('_', ':').replace('relay', 'meter'), property: 'total', range: s.R });

// roller component
if (s.D === 'roller') desc.push({ id: s.I, component: b.D.replace('_', ':'), property: 'state', range: s.R });
if (s.D === 'rollerPos') desc.push({ id: s.I, component: b.D.replace('_', ':'), property: 'current_pos', range: s.R });
if (s.D === 'rollerStopReason') desc.push({ id: s.I, component: b.D.replace('_', ':'), property: 'stop_reason', range: s.R });
if (s.D === 'rollerPower') desc.push({ id: s.I, component: 'meter:0', property: 'power', range: s.R });
if (s.D === 'rollerEnergy') desc.push({ id: s.I, component: 'meter:0', property: 'total', range: s.R });

// emeter component
if (s.D === 'voltage' && b.D.startsWith('emeter')) desc.push({ id: s.I, component: b.D.replace('_', ':'), property: 'voltage', range: s.R }); // SHEM
if (s.D === 'power' && b.D.startsWith('emeter')) desc.push({ id: s.I, component: b.D.replace('_', ':'), property: 'power', range: s.R });
if (s.D === 'energy' && b.D.startsWith('emeter')) desc.push({ id: s.I, component: b.D.replace('_', ':'), property: 'total', range: s.R });
});
});
this.log.debug(`parsing ${MAGENTA}decoding${db}:`);
Expand Down
233 changes: 233 additions & 0 deletions src/mock/shellyrgbw2-EC64C9D3FFEF.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
{
"shelly": {
"type": "SHRGBW2",
"mac": "EC64C9D3FFEF",
"auth": false,
"fw": "20221013-134509/v1.12-1-g1abbae93c-rgbw2-prod",
"discoverable": false,
"longid": 1,
"num_outputs": 1
},
"settings": {
"device": {
"type": "SHRGBW2",
"mac": "EC64C9D3FFEF",
"hostname": "shellyrgbw2-EC64C9D3FFEF",
"num_outputs": 1
},
"wifi_ap": {
"enabled": false,
"ssid": "shellyrgbw2-EC64C9D3FFEF",
"key": ""
},
"wifi_sta": {
"enabled": true,
"ssid": "FibreBox_X6-12A4C7",
"ipv4_method": "dhcp",
"ip": null,
"gw": null,
"mask": null,
"dns": null
},
"wifi_sta1": {
"enabled": false,
"ssid": null,
"ipv4_method": "dhcp",
"ip": null,
"gw": null,
"mask": null,
"dns": null
},
"ap_roaming": {
"enabled": false,
"threshold": -70
},
"mqtt": {
"enable": false,
"server": "192.168.33.3:1883",
"user": "",
"id": "shellyrgbw2-EC64C9D3FFEF",
"reconnect_timeout_max": 60,
"reconnect_timeout_min": 2,
"clean_session": true,
"keep_alive": 60,
"max_qos": 0,
"retain": false,
"update_period": 30
},
"coiot": {
"enabled": true,
"update_period": 15,
"peer": "",
"execute_enable": false
},
"sntp": {
"server": "time.google.com",
"enabled": true
},
"login": {
"enabled": false,
"unprotected": false,
"username": "admin"
},
"pin_code": "",
"name": "My Shelly RGBW2",
"fw": "20221013-134509/v1.12-1-g1abbae93c-rgbw2-prod",
"factory_reset_from_switch": true,
"discoverable": false,
"build_info": {
"build_id": "20221013-134509/v1.12-1-g1abbae93c-rgbw2-prod",
"build_timestamp": "2022-10-13T13:45:09Z",
"build_version": "1.0"
},
"cloud": {
"enabled": true,
"connected": true
},
"timezone": null,
"lat": null,
"lng": null,
"tzautodetect": true,
"tz_utc_offset": 7200,
"tz_dst": false,
"tz_dst_auto": true,
"time": "11:11",
"unixtime": 1718961096,
"led_status_disable": false,
"debug_enable": false,
"allow_cross_origin": false,
"fw_mode": "SHRGBW2!color",
"actions": {
"active": false,
"names": [
"btn_on_url",
"btn_off_url",
"out_on_url",
"out_off_url",
"longpush_url",
"shortpush_url"
]
},
"hwinfo": {
"hw_revision": "dev-prototype",
"batch_id": 0
},
"mode": "color",
"alt_modes": [
"white"
],
"dcpower": 1,
"lights": [
{
"name": null,
"ison": false,
"red": 0,
"green": 0,
"blue": 255,
"white": 0,
"gain": 50,
"transition": 1000,
"effect": 0,
"default_state": "switch",
"auto_on": 0,
"auto_off": 0,
"schedule": false,
"btn_type": "toggle",
"btn_reverse": 0,
"night_mode": {
"enabled": false,
"start_time": "00:00",
"end_time": "00:00",
"brightness": 0
},
"schedule_rules": []
}
],
"night_mode": {
"enabled": false,
"start_time": "00:00",
"end_time": "00:00",
"brightness": 0
},
"eco_mode_enabled": true
},
"status": {
"wifi_sta": {
"connected": true,
"ssid": "FibreBox_X6-12A4C7",
"ip": "192.168.1.226",
"rssi": -54
},
"cloud": {
"enabled": true,
"connected": true
},
"mqtt": {
"connected": false
},
"time": "11:11",
"unixtime": 1718961096,
"serial": 8,
"has_update": true,
"mac": "EC64C9D3FFEF",
"cfg_changed_cnt": 0,
"actions_stats": {
"skipped": 0
},
"mode": "color",
"input": 0,
"lights": [
{
"ison": false,
"source": "input",
"has_timer": false,
"timer_started": 0,
"timer_duration": 0,
"timer_remaining": 0,
"mode": "color",
"red": 0,
"green": 0,
"blue": 255,
"white": 0,
"gain": 50,
"effect": 0,
"transition": 0,
"power": 0,
"overpower": false
}
],
"meters": [
{
"power": 0,
"is_valid": true,
"overpower": false,
"timestamp": 1718968296,
"counters": [
0,
0,
0
],
"total": 0
}
],
"inputs": [
{
"input": 0,
"event": "",
"event_cnt": 0
}
],
"update": {
"status": "pending",
"has_update": true,
"new_version": "20230913-113259/v1.14.0-gcb84623",
"old_version": "20221013-134509/v1.12-1-g1abbae93c-rgbw2-prod",
"beta_version": "20231107-164040/v1.14.1-rc1-g0617c15"
},
"ram_total": 51688,
"ram_free": 39488,
"fs_size": 233681,
"fs_free": 152608,
"uptime": 355
}
}
Loading

0 comments on commit 97e387a

Please sign in to comment.