Stock info to Dummy Sensor

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
BlueMotion
Posts: 10
Joined: Thursday 04 June 2020 15:10
Target OS: NAS (Synology & others)
Domoticz version: 2020.2
Location: Subtropical Scandinavia (Fryslan)
Contact:

Stock info to Dummy Sensor

Post by BlueMotion »

Somehow I found it interesting to get stock information from the web and place it into a dummy sensor.
While all my logic is in Node-Red I started there.

Starting with a timestamp with an interval between time I do a http-request
I read out the website https://www.beleggen.nl/koersen/aex.aspx
followed by a html edit for the table: ".tableissue tbody tr"
After some magic with filtering, spliting and replacing I've got specific info for specific Stocks.
eg: From the website:

Fonds Koers +/- % Open Hoog Laag Tijd
AEX 683,72 +6,64 +1,02% 680,43 683,79 679,08 12:55:15
ABN AMRO BANK N.V. 9,096 +0,328 +3,72% 8,850 9,120 8,850 12:55:15
ADYEN NV 2.142,000 -51,000 -2,19% 2.200,000 2.200,000 2.137,000 12:55:11

Into:

idx: 378
svalue: "3.821"
svalue2: "0.084"
perc: "2.25"
open: "3.761"
hoog: "3.833"
laag: "3.76"

To process this info to Domoticz

Code: Select all

    msg.payload={};
    msg.payload.idx=378;
    msg.payload.svalue = parseFloat(obj[1]).toString();
    msg.payload.svalue2= parseFloat(obj[2]).toString();
    msg.payload.perc = parseFloat(obj[3]).toString();
    msg.payload.open= parseFloat(obj[4]).toString();
    msg.payload.hoog = parseFloat(obj[5]).toString();
    msg.payload.laag = parseFloat(obj[6]).toString();
    
Now the thing!! :-)
I insert a dummy sensor with a subtype custom sensor.
The only info which appears on the sensor is the svalue above...

To make this sensor a little more useful I would insert the svalue2 as well to see the differences and to color it red or green.
Finally I present this info into my Dashticz page.

Can anyone help? Which Dummy Sensor do I have to use? Or how to (mis) use the P1 sensor with subdevices..
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest