If you have installed the PBTH app and have a Price Zone device, this si how you can load the data to a sheet
Currently you need to manually create a tab in your sheet to match the name ('NordpoolPrices') |
First create this HomeyScript
/* HomeyScript for parsing and creating a Nordpool prices input to Easy Logger NOTE. Changed format for runFlowCardAction: Homey Pro prior 2023: id: 'set-cell-delimited-data', Homey Pro 2023: id: 'homey:app:no.bwa.easy-logger:set-cell-delimited-data', This is an example of data that will come from PBTH So if you need to test or debug, change JSON.parse(input); til JSON.parse( typical_input ); and run manually */ var typical_input = '{"0":0.0849,"1":0.0826,"2":0.0826,"3":0.0808,"4":0.0815,"5":0.084,"6":0.0837,"7":0.0839,"8":0.0849,"9":0.087,"10":0.0859,"11":0.084,"12":0.0854,"13":0.0864,"14":0.0907,"15":0.097,"16":0.109,"17":0.1299,"18":0.1195,"19":0.1016,"20":0.0951,"21":0.094,"22":0.0893,"23":0.0852}' var input = (args + '').replaceAll("'",'"'); // JSON.parse liker ikke ', men liker heller " async function setCell(cellName, cellData) { try { await Homey.flow.runFlowCardAction({ uri: 'homey:app:no.bwa.easy-logger', id: 'homey:app:no.bwa.easy-logger:set-cell-delimited-data', args: { 'cell-name': cellName, 'delimited-data': '' + cellData }, }); console.log("setCell ", cellName, " data", cellData); } catch(err) { console.log(err); } } // use this to debug input from flow ... // await setCell("NordpoolPrices!A1", input); const textFromJSON = JSON.parse(input); const t = Object.entries(textFromJSON); var cellContent = '={'; for(let i=0; i<t.length; i++){ cellContent += (t[i][1]); if(i < (t.length-1)) cellContent += ';'; } cellContent += '}'; cellContent = cellContent.replaceAll('.',','); // nummer format konvertering fra . til , await setCell("NordpoolPrices!A2", cellContent); |
Then create this flow :
Then you should get something like thisĀ