@homebridge-plugins/homebridge-shelly-energy 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/NOTICE +6 -0
- package/README.md +8 -3
- package/SECURITY.md +26 -0
- package/eslint.config.js +10 -0
- package/lib/control.js +7 -6
- package/lib/cycles.js +8 -11
- package/lib/engine-devices.js +1229 -0
- package/lib/engine-reports.js +324 -0
- package/lib/engine-shared.js +92 -0
- package/lib/engine-steps.js +926 -0
- package/lib/engine-util.js +1 -40
- package/lib/engine.js +501 -1822
- package/lib/hap-tiles.js +90 -21
- package/lib/homebridge-ui/handlers.js +42 -1
- package/lib/homebridge-ui/public/app.js +3417 -0
- package/lib/homebridge-ui/public/index.html +44 -645
- package/lib/homebridge-ui/public/style.css +144 -0
- package/lib/hosts.js +13 -3
- package/lib/icons.js +111 -0
- package/lib/import.js +68 -30
- package/lib/insights.js +0 -1
- package/lib/matter-devices.js +3 -7
- package/lib/matter-tiles.js +38 -3
- package/lib/patterns.js +137 -6
- package/lib/platform.js +141 -50
- package/lib/private-dir.js +20 -0
- package/lib/recorder.js +272 -0
- package/lib/shelly-devices.js +180 -5
- package/lib/shelly-em.js +246 -13
- package/lib/web-auth.js +32 -16
- package/lib/web.js +81 -74
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@homebridge-plugins/homebridge-shelly-energy` will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## v1.1.0 (2026-11-22)
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- feat: bring in the original author's 1.7.6 with gap filling, safer saves, rooms and recordings
|
|
10
|
+
- fix(ui): escape a device's id in the room picker
|
|
11
|
+
- fix: refuse hex and whole-number addresses that fetch reads as internet addresses
|
|
12
|
+
- fix: don't fill a gap of more than 31 days, so a clock jump keeps the real days
|
|
13
|
+
- fix: keep merged steps on the chosen appliance when another room has one of the same name
|
|
14
|
+
- fix: keep the day's figures numbers when a run began with a shared step
|
|
15
|
+
- fix: move a merged appliance's shared steps across too, so its runs still end
|
|
16
|
+
- fix: let an appliance a device used to measure be merged into another
|
|
17
|
+
- fix: don't end a variable load's run with the cap meant for on/off appliances
|
|
18
|
+
- fix: stop a failed recording's timer, so it can't cut the next recording short
|
|
19
|
+
- fix: compare the settings page's key as bytes, so an odd key can't crash homebridge
|
|
20
|
+
- fix: carry on reading when the clock is put back right after running ahead
|
|
21
|
+
- fix: write the save file by its path, so the plugin checks don't see a write outside storage
|
|
22
|
+
- test: split a long object in the save test, for the lint rules
|
|
23
|
+
- test: wait for both matter plugs' watts before checking them
|
|
24
|
+
|
|
5
25
|
## v1.0.0 (2026-11-22)
|
|
6
26
|
|
|
7
27
|
### Changed
|
package/NOTICE
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
Homebridge Shelly Energy (@homebridge-plugins/homebridge-shelly-energy)
|
|
2
|
+
|
|
3
|
+
This plugin includes appliance icons from Google's Material Symbols
|
|
4
|
+
(https://fonts.google.com/icons), Copyright Google LLC, licensed under the
|
|
5
|
+
Apache License, Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0).
|
|
6
|
+
They are kept as SVG paths in lib/icons.js; their shapes are unchanged.
|
package/README.md
CHANGED
|
@@ -20,11 +20,15 @@ Homebridge plugin that learns your appliances from a Shelly whole-house energy m
|
|
|
20
20
|
- learns your appliances from the power steps that repeat, and counts each one's runs and energy per day and per hour
|
|
21
21
|
- shows each appliance in Apple Home as a **Matter outlet with live watts and energy**, plus an **Other** outlet for the rest
|
|
22
22
|
- reads Shelly plugs, relays and meters, and Matter plugs, for exact figures, and can find your Shellys on the network
|
|
23
|
+
- keeps a **live connection** to Gen2 and newer Shellys, so each switch and change in watts arrives the moment it happens
|
|
23
24
|
- learns each appliance's cycles (Eco, Quick…) and shows the time left in a run
|
|
24
|
-
-
|
|
25
|
-
-
|
|
25
|
+
- can combine devices into one appliance (two lamps, or a hob on two circuits), and tells similar appliances apart by their power factor and start spike
|
|
26
|
+
- works out the cost per day and per hour, by appliance or by room, a forecast for the month or bill (from the bill day you set) against an optional budget, and money-saving tips from your own readings
|
|
27
|
+
- fills gaps in the readings (a restart, Wi-Fi dropping out) from the meter's own energy count, so the day's total still adds up
|
|
28
|
+
- can show HomeKit tiles for when an appliance is running, a **Cheap Power Now** tile, and alert tiles for an appliance running long or the month going over budget
|
|
29
|
+
- can record a day of readings to a file, so recognition can be checked on your real data
|
|
26
30
|
- Everything stays on your home network: no account, no cloud. The plugin only reads, and never switches anything.
|
|
27
|
-
- Everything is set up on the plugin's own page in the Homebridge UI.
|
|
31
|
+
- Everything is set up on the plugin's own page in the Homebridge UI. The same page can also be opened from a browser on your home network, behind a PIN, and can be set to view only.
|
|
28
32
|
|
|
29
33
|
### Prerequisites
|
|
30
34
|
|
|
@@ -61,6 +65,7 @@ Homebridge plugin that learns your appliances from a Shelly whole-house energy m
|
|
|
61
65
|
- To [@Wazza151](https://github.com/Wazza151): the creator of this plugin.
|
|
62
66
|
- To the creators/contributors of [homebridge-appliance-monitor](https://github.com/rummeyer/homebridge-appliance-monitor) (MIT), whose ideas the run learning of measured appliances is based on, and whose matter.js controller calls the Matter device reading follows.
|
|
63
67
|
- To the creators/contributors of [matter.js](https://github.com/matter-js/matter.js), which reads your Matter devices.
|
|
68
|
+
- To Google's [Material Symbols](https://fonts.google.com/icons) (Apache License 2.0, see NOTICE), used for the appliance icons.
|
|
64
69
|
- To the creators/contributors of [Homebridge](https://homebridge.io) who make this plugin possible.
|
|
65
70
|
|
|
66
71
|
### Disclaimer
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Security
|
|
2
|
+
|
|
3
|
+
## Reporting a problem
|
|
4
|
+
|
|
5
|
+
Please report security problems privately, through this repository's **Security → Report a vulnerability** page, not in a
|
|
6
|
+
public issue. Say what you found, how to see it, and which version you were on.
|
|
7
|
+
|
|
8
|
+
## How the plugin protects your home
|
|
9
|
+
|
|
10
|
+
- **Nothing leaves your home network.** No accounts, cloud services or analytics. Shelly and Matter addresses must be on the
|
|
11
|
+
home network; anything else is refused. Find Shellys asks only the Homebridge computer's own network, and only when pressed.
|
|
12
|
+
- **Read-only to your devices.** It never switches a Shelly or Matter device; Apple Home tiles only show.
|
|
13
|
+
- **Your data is this account's only.** Its folder (`home-energy` in Homebridge's storage) and everything in it, including the
|
|
14
|
+
Matter controller's credentials, backups and recordings, can be opened only by the account Homebridge runs as.
|
|
15
|
+
- **The settings page** reaches the plugin through a socket file only that account can open, with a random key: no network port.
|
|
16
|
+
- **The optional web page** (off until a PIN is set) answers home-network addresses and names only, and only requests from its
|
|
17
|
+
own page. The PIN (6 to 32 characters) is kept as a scrypt hash; a signed-in browser holds a random key in an HttpOnly,
|
|
18
|
+
SameSite=Strict cookie for 30 days. Five wrong PINs make that address wait 10 minutes, and 30 from the whole network pause
|
|
19
|
+
sign-in for everyone. It can be set to **view only**. It can never change its own PIN or settings.
|
|
20
|
+
- **Plain HTTP.** The web page isn't encrypted, like most home devices' pages: anyone who can watch your Wi-Fi traffic could see
|
|
21
|
+
the PIN. Use it only on a network you trust, and keep it view-only if others use your Wi-Fi.
|
|
22
|
+
|
|
23
|
+
## Packages
|
|
24
|
+
|
|
25
|
+
The plugin uses matter.js and the Homebridge UI helper. Every change is built and linted on each supported Node version and
|
|
26
|
+
checked by CodeQL, and Dependabot opens a pull request when a package has an update or a fix.
|
package/eslint.config.js
CHANGED
|
@@ -46,6 +46,16 @@ export default antfu(
|
|
|
46
46
|
},
|
|
47
47
|
typescript: false,
|
|
48
48
|
},
|
|
49
|
+
{
|
|
50
|
+
// the settings page's browser script keeps its page state below the functions that use it
|
|
51
|
+
files: ['lib/homebridge-ui/public/app.js'],
|
|
52
|
+
rules: {
|
|
53
|
+
'no-use-before-define': [
|
|
54
|
+
'error',
|
|
55
|
+
{ classes: false, functions: false, variables: false },
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
},
|
|
49
59
|
{
|
|
50
60
|
files: ['**/*.md'],
|
|
51
61
|
rules: {
|
package/lib/control.js
CHANGED
|
@@ -43,12 +43,14 @@ export function startControl({ dataDir, actions, log }) {
|
|
|
43
43
|
})
|
|
44
44
|
res.end(s)
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
// compared as bytes: a key with as many letters but a non-ASCII one has more bytes, and timingSafeEqual throws on that
|
|
47
|
+
const given = Buffer.from(String(req.headers['x-key'] || ''))
|
|
48
|
+
const want = Buffer.from(key)
|
|
47
49
|
if (
|
|
48
50
|
req.method !== 'POST'
|
|
49
51
|
|| req.url !== '/api'
|
|
50
|
-
|| given.length !==
|
|
51
|
-
|| !crypto.timingSafeEqual(
|
|
52
|
+
|| given.length !== want.length
|
|
53
|
+
|| !crypto.timingSafeEqual(given, want)
|
|
52
54
|
) {
|
|
53
55
|
return reply(403, { error: 'Not allowed' })
|
|
54
56
|
}
|
|
@@ -73,10 +75,9 @@ export function startControl({ dataDir, actions, log }) {
|
|
|
73
75
|
} catch {
|
|
74
76
|
return reply(400, { error: 'Bad request' })
|
|
75
77
|
}
|
|
76
|
-
|
|
77
|
-
const fn = Object.hasOwn(actions, String(body?.action))
|
|
78
|
+
const fn = typeof body?.action === 'string' && Object.hasOwn(actions, body.action)
|
|
78
79
|
? actions[body.action]
|
|
79
|
-
:
|
|
80
|
+
: null // its own actions only
|
|
80
81
|
if (typeof fn !== 'function') {
|
|
81
82
|
return reply(400, { error: `Unknown action "${String(body?.action).slice(0, 40)}"` })
|
|
82
83
|
}
|
package/lib/cycles.js
CHANGED
|
@@ -58,17 +58,14 @@ export function progStats(s) {
|
|
|
58
58
|
}
|
|
59
59
|
const dur = median(runs.map(c => c.dur))
|
|
60
60
|
const mins = Math.ceil(dur / 60)
|
|
61
|
-
const prof = Array.from(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
: null
|
|
70
|
-
},
|
|
71
|
-
)
|
|
61
|
+
const prof = Array.from({
|
|
62
|
+
length: Math.min(mins, MAX_MIN),
|
|
63
|
+
}, (_, i) => {
|
|
64
|
+
const v = runs.map(c => c.prof[i]).filter(x => x != null)
|
|
65
|
+
return v.length
|
|
66
|
+
? median(v)
|
|
67
|
+
: null
|
|
68
|
+
})
|
|
72
69
|
return {
|
|
73
70
|
id: p.id,
|
|
74
71
|
name: p.name,
|