Skip to content

Commit fb4b0c6

Browse files
author
Orlin Dimitrov
committed
Merge feature/stock-monitor-vc-production into dev
2 parents ba30bce + 458f32d commit fb4b0c6

File tree

7 files changed

+42
-29
lines changed

7 files changed

+42
-29
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
All notable changes to this project will be documented in this file.
44

55
## 2026-03
6+
- Promote `http-integrations/finance-yahoo/stock-monitor_vc.shelly.js` to production: rename from `stock-monitor.shelly.js`, fix mJS compatibility (`Number.isFinite``isFinite`, `padStart``pad2` helper), add screenshot to README
67
- Add `the_pill/MODBUS/wirenboard/WB-MIR-v-3/wb_mir_v3_ir.shelly.js`, a dedicated under-development IR utility for WB-MIR v3 learn/play/dump/erase operations
78
- Promote all `the_pill/MODBUS/wirenboard/WB-MIR-v-3/*.shelly.js` scripts to production and add them to `examples-manifest.json`
89
- Set WB-MIR v3 boolean Virtual Component labels to `OFF` and `ON` via `meta.ui.titles`

SHELLY_MJS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ howto/switch-read.shelly.js: Example - Reading Switch status
163163
===
164164
Example of reading Switch component's status.
165165

166+
http-integrations/finance-yahoo/stock-monitor_vc.shelly.js: Yahoo Finance stock monitor with virtual components
167+
===
168+
Polls Yahoo Finance chart API for a stock symbol and updates
169+
166170
http-integrations/http-handlers/http-handlers.shelly.js: Shelly HTTP script handling GET requests, query strings
167171
===
168172
This script registers a HTTP handler endpoint and implements simple logic for requests and handlers for

examples-manifest.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,11 @@
189189
"title": "Example - Reading Switch status",
190190
"description": "Example of reading Switch component's status."
191191
},
192+
{
193+
"fname": "http-integrations/finance-yahoo/stock-monitor_vc.shelly.js",
194+
"title": "Yahoo Finance stock monitor with virtual components",
195+
"description": "Polls Yahoo Finance chart API for a stock symbol and updates"
196+
},
192197
{
193198
"fname": "http-integrations/http-handlers/http-handlers.shelly.js",
194199
"title": "Shelly HTTP script handling GET requests, query strings",

http-integrations/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ HTTP endpoints, notifications, metrics, and external service integrations.
66
Use these when you need Shelly to talk to external services or expose data via HTTP.
77
## Scripts
88

9-
- `finance-yahoo/stock-monitor.shelly.js` (see `finance-yahoo/README.md`)
9+
- `finance-yahoo/stock-monitor_vc.shelly.js` (see `finance-yahoo/README.md`)
1010
- `http_post_watts_to_thingspeak/http_post_watts_to_thingspeak.shelly.js`
1111
- `http-handlers/http-handlers.shelly.js`
1212
- `http-notify-on-power-threshold/http-notify-on-power-threshold.shelly.js`

http-integrations/finance-yahoo/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ You want a quick market snapshot on your Shelly dashboard, but most finance widg
1111
- Maker building simple finance-aware automations from HTTP data
1212

1313
## Files
14-
- [`stock-monitor.shelly.js`](stock-monitor.shelly.js): Yahoo Finance poller + Virtual Component updater
14+
- [`stock-monitor_vc.shelly.js`](stock-monitor_vc.shelly.js): Yahoo Finance poller + Virtual Component updater
15+
16+
## Screenshot
17+
This screenshot shows the Stock Monitor Virtual Components group in the Shelly UI with current price, open/close, high/low, volume, daily change, and last update timestamp.
18+
19+
![Stock Monitor screenshot](screenshot.png)
1520

1621
## What It Updates
1722
- `number:200` current price
@@ -31,5 +36,4 @@ You want a quick market snapshot on your Shelly dashboard, but most finance widg
3136
4. Repeats every 5 minutes
3237

3338
## Notes
34-
- Script status is currently under development.
3539
- The default symbol in the script is `SLYG.DE`; edit `STOCK_SYMBOL` to your preferred ticker.
77.5 KB
Loading

http-integrations/finance-yahoo/stock-monitor.shelly.js renamed to http-integrations/finance-yahoo/stock-monitor_vc.shelly.js

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
/**
2-
* @title Yahoo Finance stock monitor with virtual components
3-
* @description Polls Yahoo Finance chart API for a stock symbol and updates
4-
* Virtual Components with current price, daily delta, and quote fields.
5-
* @status under development
6-
* @link https://github.com/ALLTERCO/shelly-script-examples/blob/main/http-integrations/finance-yahoo/stock-monitor.shelly.js
7-
*/
8-
9-
/**
10-
* Stock Price Monitor
11-
*
12-
* Fetches one-day quote data for STOCK_SYMBOL and writes values to Virtual
13-
* Components.
14-
*
15-
* Virtual Components used:
16-
* - number:200..205 Price, volume, open, close, low, high
17-
* - text:200..202 Symbol, daily change, last updated
18-
*/
19-
20-
const STOCK_SYMBOL = 'SLYG.DE';
1+
/**
2+
* @title Yahoo Finance stock monitor with virtual components
3+
* @description Polls Yahoo Finance chart API for a stock symbol and updates
4+
* Virtual Components with current price, daily delta, and quote fields.
5+
* @status production
6+
* @link https://github.com/ALLTERCO/shelly-script-examples/blob/main/http-integrations/finance-yahoo/stock-monitor_vc.shelly.js
7+
*/
8+
9+
/**
10+
* Stock Price Monitor
11+
*
12+
* Fetches one-day quote data for STOCK_SYMBOL and writes values to Virtual
13+
* Components.
14+
*
15+
* Virtual Components used:
16+
* - number:200..205 Price, volume, open, close, low, high
17+
* - text:200..202 Symbol, daily change, last updated
18+
*/
19+
20+
const STOCK_SYMBOL = 'SLYG.DE';
2121

2222
const vcComponents = {
2323
group: {
@@ -96,17 +96,16 @@ function getTimestamp(ts) {
9696
return new Date(ts).toString().split('GMT')[0].trim();
9797
}
9898

99+
function pad2(n) { return (n < 10 ? "0" : "") + n; }
100+
99101
function getDate(ts) {
100102
const date = new Date(ts);
101-
return (
102-
String(date.getDate()).padStart(2, "0") + "-" +
103-
String(date.getMonth() + 1).padStart(2, "0")
104-
);
103+
return pad2(date.getDate()) + "-" + pad2(date.getMonth() + 1);
105104
}
106105

107106
function formatNum(n) {
108107
const x = Number(n);
109-
return Number.isFinite(x) ? Number(x.toFixed(2)) : 0;
108+
return isFinite(x) ? Number(x.toFixed(2)) : 0;
110109
}
111110

112111
function getComponentByKey(key) {
@@ -171,4 +170,4 @@ function updateStockPrice() {
171170
updateStockPrice();
172171

173172
// Run every 5 minutes
174-
Timer.set(5 * 60 * 1000, true, updateStockPrice);
173+
Timer.set(5 * 60 * 1000, true, updateStockPrice);

0 commit comments

Comments
 (0)