timdows / mmm-jsontable Goto Github PK
View Code? Open in Web Editor NEWA module for the MagicMirror project which creates a table filled with a list gathered from a json request.
License: MIT License
A module for the MagicMirror project which creates a table filled with a list gathered from a json request.
License: MIT License
Hey, love this module, but couldn't get it to work.
My origin: https://api.myjson.com/bins/z68sj
My config:
config: {
url: 'https://api.myjson.com/bins/z68sj'
}
But getting Awaiting json data
on the screen..
Hi,
First, thank you for creating this module, as a hobby programmer it made it very easy to implement my project into the MM without knowing anything about js.
I saw how enthusiastically you implemented the Font Awesome idea and I was hoping maybe you could help out with some basic colors.
I made a table to display Air quality information from a co2 sensor and i'd like to color code it so that if the CO2 levels are high the row is then displayed in yellow and red (depending on the levels). the other rows that display temperature and humidity should ideally stay white.
would it be possible to had a simple "color"-key to the json so that it is then changed in the table... "color":"yellow"
If not is there any other way i could implement this?
thank you
Hello, I'm trying to retrieve my sheet from google spreadsheets , but module says "awaiting"
The data in "entry/feed/gsx.." category, I'm not sure what is wrong with my code, but needs your touches.
I also need create loop for bringing with prefix "gsx " values.
URL
{ module: 'MMM-JsonTable', position: 'top_left', header: 'Majken', config: { url: 'https://spreadsheets.google.com/feeds/list/1dVwsdP3K49XGTaixhTTzuybEz4nFubtQzB_Qa32c4ZM/od6/public/values?alt=json', // Required arrayName: 'object/feed/entry' // Optional } },
Allthough I follow the exact examples in the readme file, I receive this error:
0|mm | [10.08.2023 12:51.58.234] [ERROR] (node:7568) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token '�', "��{
0|mm | "... is not valid JSON
0|mm | at JSON.parse ()
0|mm | at Response.json (file:///home/pi/MagicMirror/modules/MMM-JsonTable/node_modules/node-fetch/src/body.js:149:15)
0|mm | at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
0|mm | (Use electron --trace-warnings ...
to show where the warning was created)
0|mm | [10.08.2023 12:51.58.235] [ERROR] (node:7568) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
The issue is in the URL format: 'https://server.vdplas.net:8083/thuis.json' . Because when entering 'https://jsonplaceholder.typicode.com/users' it works perfectly, the table is shown, but when entering the former URL, even when there is the exact same file located, it does not work.
What is wrong in the format? Is it the : ?
Hi @timdows ,
I've tried to solve this for two days by now but with no luck.
Hope you can help since I can't really see where the problem with position 5 is.
From console log I have this error:
[2020-09-23 16:08:12.958] [LOG] http://192.168.1.50/home/pi/MagicMirror/modules/MMM-JsonTable/prova.json
[2020-09-23 16:08:12.967] [ERROR] Whoops! There was an uncaught exception...
[2020-09-23 16:08:12.968] [ERROR] SyntaxError: Unexpected token < in JSON at position 5
at JSON.parse (<anonymous>:null:null)
at Request._callback (/home/pi/MagicMirror/modules/MMM-JsonTable/node_helper.js:14:21)
at Request.self.callback (/home/pi/MagicMirror/node_modules/request/request.js:185:22)
at Request.emit (events.js:200:13)
at Request.<anonymous> (/home/pi/MagicMirror/node_modules/request/request.js:1154:10)
at Request.emit (events.js:200:13)
at IncomingMessage.<anonymous> (/home/pi/MagicMirror/node_modules/request/request.js:1076:12)
at Object.onceWrapper (events.js:288:20)
at IncomingMessage.emit (events.js:205:15)
at endReadableNT (_stream_readable.js:1154:12)
at processTicksAndRejections (internal/process/task_queues.js:84:9)
[2020-09-23 16:08:12.971] [ERROR] MagicMirror will not quit, but it might be a good idea to check why this happened. Maybe no internet connection?
[2020-09-23 16:08:12.972] [ERROR] If you think this really is an issue, please open an issue on GitHub: https://github.com/MichMich/MagicMirror/issues
This is the config array:
{
module: 'MMM-JsonTable',
position: 'top_right',
header: 'Dati ultima corsa',
config: {
url: 'http://192.168.1.50/home/pi/MagicMirror/modules/MMM-JsonTable/prova.json',
arrayName: "items",
tryFormatDate: true
}
While this is the JSON content (UTF encoded, no BOM characters):
{
"items": [
{
"name":"Data",
"value":"20/9/20"
},
{
"name":"Distanza",
"value":"10 Km"
},
{
"name":"Durata",
"value":"0:52:30"
},
{
"name":"Passo",
"value":"0:5:15"
},
{
"name":"VDOT",
"value":"38"
}
]
}
Thank you in advance for your precious support.
Flavio
Hope someone can help me to read in my data of fronius converter
Can I read this data into mmm json table?
Thanks
Hi, I'm totally new to this but I wanted to know how would I go about modifying this module to add in a API key in the header so I can pull in the json feed? Here is the request example I'm given that i'd like to use.
curl --get --include 'https://transloc-api-1-2.p.mashape.com/arrival-estimates.json agencies=yale&callback=call'
-H 'X-Mashape-Key: lM66qSxXHcmsh5qSfHLz5vvHrP7zp1Ra8ncjsnCDxETtwCYwJP'
-H 'Accept: application/json'
Can you make this work with MagicMirror 2.18 when I try to use it I get a black screen.
Removing it makes my MM work again.
This is the data from the json file I am incorporating.
"data": [
[
"2020-10-30 07:46",
75.79,
35.00,
46.20,
71.92
]
]
First off, if there is a way for it to omit the second line of data (75.79) that would be ideal as it is redundant and confusing. Second, i used this string in my config, however, the descriptive row didn't populate. any thoughts?
url: 'http://10.0.1.150/transfer/log.json?start-time=0&end-time=60', // Required
arrayName: 'data', // Optional
tryFormatDate: 'true',
descriptiveRow: 'DateTempDewpointHumidityTemp'
How can I use the module without node_helper only for local file?
On my computer the table looks good, with even spacing.
But on my actual mirror, raspberry with its web browser the spacing is off. It is lined up but there is no spacing.
I guess I could solve it with descriptiveRow and even make it invisible but that would add on the height.
Any ideas? Maybe an option to make the width fixed?
json
{
"domoticz": [
{
"name": "Temp ute / uppe / nere",
"value1": " ",
"value2": "8.0 C",
"value3": "23.2 C",
"value4": "Error"
},
{
"name": "Sval / Varm/ Sol / Luftf.",
"value1": "22.9 C",
"value2": "26.2 C",
"value3": "27.2 C",
"value4": "60%"
},
{
"name": "Majken får mat",
"value1": " ",
"value2": " ",
"value3": "om",
"value4": "7 dagar"
},
{
"name": "Lilla garagedörren",
"value1": " ",
"value2": " ",
"value3": " ",
"value4": "Låst"
},
{
"name": "FTX / Garage / VVB",
"value1": " ",
"value2": "100 W",
"value3": "14 W",
"value4": "293 W"
},
{
"name": "Server / Terrarium",
"value1": " ",
"value2": " ",
"value3": "73 W",
"value4": "148 W"
},
{
"name": "Förbrukning idag",
"value1": " ",
"value2": " ",
"value3": "10.6 kWh",
"value4": "19.6 kr"
}
]
}
jsontable.php
$sendback0 = array( 'name' => 'Temp ute / uppe / nere', 'value1' => ' ', 'value2' => $tempute, 'value3' => $tempuppe, 'value4' => $tempnere );
$sendback1 = array( 'name' => 'Sval / Varm/ Sol / Luftf.', 'value1' => $tempsvalzon, 'value2' => $tempvarmzon, 'value3' => $tempsolplats, 'value4' => $luftfuktighet );
$sendback2 = array( 'name' => $majkenheader, 'value1' => ' ', 'value2' => ' ', 'value3' => $majkenheader2, 'value4' => $daystogo );
$sendback3 = array( 'name' => 'Lilla garagedörren', 'value1' => ' ', 'value2' => ' ', 'value3' => ' ', 'value4' => $string_door );
$sendback4 = array( 'name' => 'FTX / Garage / VVB', 'value1' => ' ', 'value2' => WattORkiloWatt($ftxPower), 'value3' => WattORkiloWatt($lvpGaragePower), 'value4' => WattORkiloWatt($NibePower) );
$sendback5 = array( 'name' => 'Server / Terrarium', 'value1' => ' ', 'value2' => ' ', 'value3' => WattORkiloWatt($serverPower), 'value4' => WattORkiloWatt($terrariumPower) );
$sendback6 = array( 'name' => 'Förbrukning idag', 'value1' => ' ', 'value2' => ' ', 'value3' => $forbrukning . ' kWh', 'value4' => $elkostnad . ' kr' );
$sendback['domoticz'] = array( $sendback0, $sendback1, $sendback2, $sendback3, $sendback4, $sendback5, $sendback6 );
header('Content-type:application/json;charset=utf-8');
echo json_encode( $sendback, JSON_PRETTY_PRINT ) ;
config.js
{
module: 'MMM-JsonTable',
position: 'top_right',
//header: 'Majken',
config: {
url: 'http://192.168.44.15/jsontable.php', // Required
arrayName: 'domoticz', // Optional
updateInterval: 60000, //Milliseconds between the refersh
//keepColumns: ["name", "value1", "value2", "value3", "value4"],
}
},
I apologize is this is an obvious issue, I am sort of a coding rookie. I am running an icecast server and I wanted to leverage your module to show currently playing tracks on my magic mirror. I dont feel the icecast server provides the best formatted json hence not correctly identifying an array parameter. I was curious if you could point me in the right direction to get your Module to display the currently playing track. it is the title: nested in the Json response. Thanks you for your wonderful module.
Here is the json output.
{
"icestats": {
"admin": "[email protected]",
"host": "radio.phreakn.tel",
"location": "Earth",
"server_id": "Icecast 2.4.4",
"server_start": "Mon, 21 Dec 2020 02:41:56 -0500",
"server_start_iso8601": "2020-12-21T02:41:56-0500",
"source": {
"genre": "Science and Technology",
"listener_peak": 4,
"listeners": 0,
"listenurl": "http://radio.station.com:8000/stream",
"server_description": "Defcon talks and live performaces",
"server_name": "WirelessPhreak Radio",
"server_type": "audio/mpeg",
"server_url": "https://www.wirelessphreak.com",
"stream_start": "Thu, 24 Dec 2020 19:40:44 -0500",
"stream_start_iso8601": "2020-12-24T19:40:44-0500",
"title": "DEF_CON_Safe_Mode_-_Shadowvex",
"dummy": null
}
}
}
From the JSON data:
[{"cid":"PWER","data":[{"1531345190000":345}],"sid":"743125","units":"kWm","age":6}]
I see the following displayed:
PWER | [object Object] | 743125 | kWm | 6
Which is to say, way better than any of the other JSON modules (which don't seem to be able to parse my source at all)
I'm not very well versed in javascript and I was wondering if you could help me get that number "345" and make it possible to display?
That's my main goal. Having a weird format, and including a bunch of stuff I don't need is completely fine. I just want that number.
Thank you for making this!
Hey @timdows thank you for this great module!
Maybe i am doing something wrong? i am trying to get the data from "mres" and "Forbruk" to be displayed on two different modules.
The config i've been trying to use is under arrayName:
tried same for "Forbruk"
am i missing something?
{"status":"success","url":"/soppel","method":"GET","data":[{"Forbrok":[{"deviceName":"Power consumption","currentValue":"Now: 3009 watts","currentTarget":" ","lastUpdate":"Limit: 5000 watt"},{"deviceName":"Varmepumpe","currentValue":"Now:25.8°C,","currentTarget":"Target:21°C,","lastUpdate":"Home override: true"},{"deviceName":"Hotwater","currentValue":"Now:44.38°C,","currentTarget":"Last heat complete","lastUpdate":"66.9 : 05:46 @ 19-12-2022 "},{"deviceName":"Last update","currentValue":" ","currentTarget":" ","lastUpdate":"23:27 19-12-2022"}]},{"mren":[{"avfallstype":"Restavfall","dato":"30-12-2022"},{"avfallstype":"Matavfall","dato":"30-12-2022"},{"avfallstype":"Papiravfall","dato":"30-12-2022"},{"avfallstype":"Plastemballasje","dato":"30-12-2022"},{"avfallstype":"Glass- og metallemballasje","dato":"30-12-2022"}]}]}
Just now learning to code.
I can get the table to show on the display but it is showing as waiting on Json data.
I am using a local hosted file. To test it, i put the Raw Json data in a JSON file but still no luck.
Is there a way to check to see if the file is being reached or any trouble shooting ideas you can give would be great.
Hi.
I am trying to get your module to work :)
i have the json url: http://xmlopen.rejseplanen.dk/bin/rest.exe/departureBoard?id=731643902&format=json
This i my config.
module: 'MMM-JsonTable',
position: 'bottom_right',
header: 'Bus tider ',
config: {
url: 'https://xmlopen.rejseplanen.dk/bin/rest.exe/departureBoard?id=731643902&format=json'
arrayName: 'Departure',
keepColumns: ["Name"] // Optional
}
},
I have made the adding to line 61 in MMM-Json.js [all]
Hi again
I want to change that module name, here are my steps, but it doesnt work.
Changed config array module
`{
module: 'MMM-JsonTable-2',
position: 'bottom_left',
header: 'Test Result',
config: {
url: 'https://spreadsheets.google.com/feeds/list/1dVwsdP3K49XGTaixhTTzuybEz4nFubtQzB_Qa32c4ZM/2/public/values?alt=json',
arrayName: 'entry'
}
2- changed /module directory name to `MMM-JsonTable-2
3- Change Js name to "MMM-JsonTable-2.js"
4- Inside the Js, changed register module name to "MMM-JsonTable-2"
Module.register("MMM-JsonTable-2", {
I 'didn't touch node_helper.js
when I run the code , it doesnot work. (show loading)
Please help me on it
Hello! I'm trying out your module to display some statistics from my coffee machine.
I would like to be able to use small "icons". I'm thinking if I define in the json for example the fa-icons, se below... And also if possible, if an image is inserted that could be displayed as well...
Here is an example of my json...
{
"cups":[
{
"icon":"fa-calendar",
"data":"Senaste bryggning",
"value":"2019-03-07",
"type":""
},
{
"icon":"fa-clock-o",
"data":"Klockan",
"value":"17:32:06",
"type":""
},
{
"icon":"fa-coffee",
"data":"Totalt antal bryggda koppar",
"value":60,
"type":"st"
},
{
"icon":"img=http://10.0.0.30/img/magicmirror/buttons/coffeebeans-512x512.png",
"data":"Kostnad b\u00f6nor (alla koppar)",
"value":319.2,
"type":"kr"
},
{
"icon":"fa-cog",
"data":"Kostnad b\u00f6nor \/ kopp",
"value":5.32,
"type":"kr"
},
{
"icon":"fa-cogs",
"data":"Kostnad maskin \/ kopp",
"value":408.17,
"type":"kr"
},
{
"icon":"fa-diamond",
"data":"Kostnad totalt \/ kopp",
"value":413.49,
"type":"kr"
}
]
}
In this example I would like to get the "icons" from font awesome displayed instead of the text, and when the img= is present, the picture should be displayed instead.
Result in this case would be:
I hope you get what I mean. :)
Best regards Erik
Hi,
would it be possible to extend the module with the feature of handling nested arrays?
actually after parsing i get a (object Object) even if i point to the right key :/
thank you!
Very nice module thanks.
I don't know if this is only for your module, since I don't use many other modules with update every 10 second, like I have with your module.
Is it possible to disable the blink?
What am I doing wrong here?
My table is way more stretched than your examples.
{
module: 'MMM-JsonTable',
position: 'top_left',
header: 'Majken',
config: {
url: 'http://192.168.xx.xx/echo.php', // Required
arrayName: 'domoticz' // Optional
}
},
{
"domoticz": [
{
"name": "Sval sida",
"value": "0.0 C, 0 %"
},
{
"name": "Solplats",
"value": "23.2 C"
},
{
"name": "L\u00e5g v\u00e4nster",
"value": "21.6 C"
},
{
"name": "H\u00f6g mitten",
"value": "21.9 C"
},
{
"name": "L\u00e5g h\u00f6ger",
"value": "21.6 C"
},
{
"name": "Dvalbox",
"value": "13.1 C"
},
{
"name": "Temperatur ute",
"value": "4.9 C"
},
{
"name": "Temperatur inne",
"value": "20.8 C"
},
{
"name": "Varmvatten",
"value": "45.2 C"
}
]
}
Hi, Is there any way to load a local JSON file?
I am currently running a python3 script to create a .json file in the MMM-JsonTable directory in valid JSON, but it does not seem to load the file, it just says "Awaiting JSON"? I have tried loading a file from an online URL and it loaded fine? Is it just not supported to load a local file?
Cheers in advance!
Someone already had that problem with the local JSON File, but I cannot fix it for me. It always says Awaiting for json data...
The file is located in the folder MMM-JsonTable as a test.json- file and url in the config.js is 'file:///home/pi/MagicMirror/modules/MMM-JsonTable/test.json'. Does anyobdy have a solution?
My test.json-file looks by the way
{ "items": [ { "name": "Watt", "value": "234.6" }, { "name": "Test", "value": "3 kwH" } ] }
This is what I've got but it says "awaiting json data..."
[
{
"councilReference":"CC-###/##/#",
"dateReceived":"2021-06-16",
"address":"some address",
"description":"some length description.",
"authority":"Council"
},
{
"councilReference":"SC-####/##",
"dateReceived":"2021-06-16",
"address":"some address",
"description":"some length description.",
"authority":"Council"
}
]
Hi,
Is it possible to limit displayed data form json? I've got this feed from smog sensor http://api.gios.gov.pl/pjp-api/rest/data/getData/92 and I really need only first (or first three) readings.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.