<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Correct json syntax (MMM-Json-Table)]]></title><description><![CDATA[<p dir="auto">A url with my details in returns the following data about my solar panels;</p>
<pre><code>&lt;overview&gt;
&lt;lastUpdateTime&gt;2020-09-25 17:06:53&lt;/lastUpdateTime&gt;
&lt;lifeTimeData&gt;
&lt;energy&gt;1109407.0&lt;/energy&gt;
&lt;revenue&gt;236.23314&lt;/revenue&gt;
&lt;/lifeTimeData&gt;
&lt;lastYearData&gt;
&lt;energy&gt;1073747.0&lt;/energy&gt;
&lt;/lastYearData&gt;
&lt;lastMonthData&gt;
&lt;energy&gt;397366.0&lt;/energy&gt;
&lt;/lastMonthData&gt;
&lt;lastDayData&gt;
&lt;energy&gt;10979.0&lt;/energy&gt;
&lt;/lastDayData&gt;
&lt;currentPower&gt;
&lt;power&gt;278.9876&lt;/power&gt;
&lt;/currentPower&gt;
&lt;measuredBy&gt;INVERTER&lt;/measuredBy&gt;
&lt;/overview&gt;
</code></pre>
<p dir="auto">If that doesn’t display well on this forum, I have also put a screen grab on DropBox <a href="https://www.dropbox.com/s/x2larxqazl4vau7/Screenshot%202020-09-25%20at%2017.38.02.png?dl=0" target="_blank" rel="noopener noreferrer nofollow ugc">https://www.dropbox.com/s/x2larxqazl4vau7/Screenshot 2020-09-25 at 17.38.02.png?dl=0</a></p>
<p dir="auto">The module <a href="https://github.com/timdows/MMM-JsonTable" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/timdows/MMM-JsonTable</a> shows an example of the config as follows:</p>
<pre><code>{
	module: 'MMM-JsonTable',
	position: 'top_right',
	header: 'HouseDB Sevensegment',
	config: {
		url: 'https://xyz/abc/get.json', // Required
		arrayName: 'items' // Optional
	}
}
</code></pre>
<p dir="auto">I would be most grateful if someone could help me sort out the correct syntax to use within the module? Just one dataset would be fine, and then I can work from there…</p>
<p dir="auto">TIA</p>
]]></description><link>https://forum.magicmirror.builders/topic/13722/correct-json-syntax-mmm-json-table</link><generator>RSS for Node</generator><lastBuildDate>Tue, 21 Jul 2026 19:22:29 GMT</lastBuildDate><atom:link href="https://forum.magicmirror.builders/topic/13722.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 25 Sep 2020 16:44:03 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Correct json syntax (MMM-Json-Table) on Fri, 02 Oct 2020 08:05:25 GMT]]></title><description><![CDATA[<p dir="auto">hi <a class="plugin-mentions-user plugin-mentions-a" href="/user/grinly" aria-label="Profile: grinly">@<bdi>grinly</bdi></a> no worries : )</p>
<p dir="auto">I agree, I think MMM-JsonTable doesn’t like the structure of the json message you’re getting back - it’s expecting to see information laid out in an array and isn’t set up to parse a different message structure.</p>
<p dir="auto">Your investigations into Node-RED sound interesting - it’s not something I’ve tried but just from a quick look you might well be able to get it to act as an intermediary between your inverter and MagicMirror.  If you’ve managed to get Node-RED to call the inverter endpoint for the energy data then that’s a good start.  You’re right, if you go this route I think you’ll still have to clean up/reformat the message for consumption by MMM-JsonTable.  But the Node-RED documentation might help - it does look like there are ways to get data back to the module too - you could perhaps get MMM-JsonTable to call a Node-RED endpoint instead of the inverter directly, and Node-RED could serve “cleaned-up” json back to MM?</p>
<p dir="auto"><a href="https://cookbook.nodered.org/http/serve-json-content" target="_blank" rel="noopener noreferrer nofollow ugc">https://cookbook.nodered.org/http/serve-json-content</a></p>
<p dir="auto">Another option might be to see if there’s an alternative MagicMirror module that can handle (or be configured to handle) a wider range of json (or XML) messages?  Though you might have to get hands-on with a module to adjust it exactly the way you wanted.  If your json message always follows the same format it shouldn’t be too hard to extract the values you’re interested in - I think there are some fairly straightforward modules that would give you an outline of how to request and parse json (e.g. MMM-stocks maybe?).  If you wanted the output shown in a table you could take a look inside MMM-JsonTable and see how it’s done there too.  Just scrolling the 3rd-party modules list there’s also MMM-Tabulator?  I’ve not used this one either but it mentions displaying data from XML or json sources, so it might be worth a try.</p>
]]></description><link>https://forum.magicmirror.builders/post/82650</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/82650</guid><dc:creator><![CDATA[raymondjspigot]]></dc:creator><pubDate>Fri, 02 Oct 2020 08:05:25 GMT</pubDate></item><item><title><![CDATA[Reply to Correct json syntax (MMM-Json-Table) on Thu, 01 Oct 2020 08:28:13 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/raymondjspigot" aria-label="Profile: raymondjspigot">@<bdi>raymondjspigot</bdi></a> Thanks once again for your reply. Even with <code> arrayName: "overview"</code> commented out it returns the same error on screen.</p>
<p dir="auto">From other research, I think that half of my problem is that the url returns “nested” data, which MMM-JsonTable doesn’t like. I did look to work around the problem another way, by getting Node-RED to send the API url, and then “clean up” the message in to the bits I wanted; whilst I could do that, I then ran in to the problem of how to get this back in to MMM-JsonTable :anguished_face:</p>
<p dir="auto">Ho Hum, the delights of programming! (But I won’t give up just yet …)</p>
]]></description><link>https://forum.magicmirror.builders/post/82580</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/82580</guid><dc:creator><![CDATA[grinly]]></dc:creator><pubDate>Thu, 01 Oct 2020 08:28:13 GMT</pubDate></item><item><title><![CDATA[Reply to Correct json syntax (MMM-Json-Table) on Thu, 01 Oct 2020 07:02:20 GMT]]></title><description><![CDATA[<p dir="auto">hi <a class="plugin-mentions-user plugin-mentions-a" href="/user/grinly" aria-label="Profile: grinly">@<bdi>grinly</bdi></a> that’s good progress persuading it to respond with a json message anyway.  It looks like what you’re getting is now more like</p>
<pre><code>{
"overview":
  {
  "lastUpdateTime":"2020-09-30 10:35:31",
  "lifeTimeData":
	{
	  "energy":1162278.0,
	  "revenue":247.86499
	},
  "lastYearData":
	{
	  "energy":1126618.0
	},
  "lastMonthData":
	{
	  "energy":450237.0
	},
  "lastDayData":
	{
	  "energy":1600.0
	},
  "currentPower":
	{
	  "power":1234.6772
	},
"measuredBy":"INVERTER"
  }
}
</code></pre>
<p dir="auto">which does look much more json-ish.  Unfortunately your inverter’s not providing the power and energy data in an array[] format.  In json an array would look more like the Example 1 message - it would be essentially a named list (called <em>items</em> in the example) and show a set of readings, each providing the same kind of datapoints, and contained in the message between <strong>[</strong> and <strong>]</strong>.  I’m guessing that the error you’re seeing is because you’ve provided</p>
<p dir="auto"><code>arrayName: "overview"</code></p>
<p dir="auto">in your config.js, so the module’s looking in the json for an array with that name, and there isn’t one (there’s a json element <em>overview</em>, but it’s not an array.)</p>
<p dir="auto">I haven’t tried using the MMM-JsonTable module so I don’t know for sure - do you get anything displayed by the module if you request the inverter data in json format again but then leave the arrayName blank in your config.js (or comment-out the arrayName entry)?</p>
]]></description><link>https://forum.magicmirror.builders/post/82575</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/82575</guid><dc:creator><![CDATA[raymondjspigot]]></dc:creator><pubDate>Thu, 01 Oct 2020 07:02:20 GMT</pubDate></item><item><title><![CDATA[Reply to Correct json syntax (MMM-Json-Table) on Wed, 30 Sep 2020 10:00:28 GMT]]></title><description><![CDATA[<p dir="auto">OK, I have some progress, in that a very slightly amended url now returns data in json format (I think!). Here is an example of what comes back …</p>
<pre><code>{"overview":{"lastUpdateTime":"2020-09-30 10:35:31","lifeTimeData":{"energy":1162278.0,"revenue":247.86499},"lastYearData":{"energy":1126618.0},"lastMonthData":{"energy":450237.0},"lastDayData":{"energy":1600.0},"currentPower":{"power":1234.6772},"measuredBy":"INVERTER"}}
</code></pre>
<p dir="auto">I have altered my MMM config to be</p>
<pre><code>{
			module: 'MMM-JsonTable',
			position: 'top_right',
			header: 'Solar Panels',
			config: {
				url: 'https://monitoringapi.solaredge.com/%20site/REDACTED/overview.json?api_key=REDACTED',
				arrayName: "overview",
				updateInterval:  '60000',		
			}
		},
</code></pre>
<p dir="auto">But whilst the config.js “runs”, it returns an error on the mirror screen saying “<em>Json data is not of type array! Maybe the config arrayName is not used and should be, or is configured wrong</em>”.</p>
<p dir="auto">Is there anything obvious that I have done wrong?</p>
<p dir="auto">TIA</p>
]]></description><link>https://forum.magicmirror.builders/post/82540</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/82540</guid><dc:creator><![CDATA[grinly]]></dc:creator><pubDate>Wed, 30 Sep 2020 10:00:28 GMT</pubDate></item><item><title><![CDATA[Reply to Correct json syntax (MMM-Json-Table) on Mon, 28 Sep 2020 14:36:56 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/raymondjspigot" aria-label="Profile: raymondjspigot">@<bdi>raymondjspigot</bdi></a> said in <a href="/post/82412">Correct json syntax (MMM-Json-Table)</a>:</p>
<blockquote>
<p dir="auto"><a href="https://github.com/timdows/MMM-JsonTable" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/timdows/MMM-JsonTable</a></p>
</blockquote>
<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/user/raymondjspigot" aria-label="Profile: raymondjspigot">@<bdi>raymondjspigot</bdi></a>  - thank you so much for your reply. Very helpful.</p>
<p dir="auto">You are right re: your first code “window” formatting - that is almost exactly what I see. I now also realise that it is in XML format, rather than json (but I hadn’t when I posted my OP). And you are correct that I need to change the XML in to json.</p>
<p dir="auto">This is all at the edge of my knowledge, but how might I “translate” the XML in to json? By using Node-RED perhaps? I already use NR for another project, but if so, I am not sure how I would then send on the re-formatted message back in to MMM-Json-Table, as does the latter not expect to receive the information from a webpage, rather than from a programme (such ass NR)?</p>
<p dir="auto">That last bit might not even be a sensible question, but I’ll ask it anyway :face_with_stuck-out_tongue_winking_eye:</p>
]]></description><link>https://forum.magicmirror.builders/post/82482</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/82482</guid><dc:creator><![CDATA[grinly]]></dc:creator><pubDate>Mon, 28 Sep 2020 14:36:56 GMT</pubDate></item><item><title><![CDATA[Reply to Correct json syntax (MMM-Json-Table) on Sun, 27 Sep 2020 06:14:58 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/user/grinly" aria-label="Profile: grinly">@<bdi>grinly</bdi></a>  - so (apologies - just to make sure what you’re looking for …)</p>
<p dir="auto">From your screenshot it looks like you’re receiving an XML message back from your inverter (hopefully this comes out ok - something like -</p>
<pre><code>&amp;ltoverview&gt;
  &amp;ltlastUpdateTime&gt;2020-09-25 17:06:53&amp;lt/lastUpdateTime&gt;
  &amp;ltlifeTimeData&gt;
    &amp;ltenergy&gt;1109407.0&amp;lt/energy&gt;
    &amp;ltrevenue&gt;236.23314&amp;lt/revenue&gt;
  &amp;lt/lifeTimeData&gt;
  &amp;ltlastYearData&gt;
    &amp;ltenergy&gt;1073747.0&amp;lt/energy&gt;
  &amp;lt/lastYearData&gt;
etc.
</code></pre>
<p dir="auto">Whereas I think the MMM-JsonTable module is looking for a json response to parse.  Are you wanting to transform the XML message you have into json first, so that MMM-JsonTable can work with it?  The raw json message in Example 1 on <a href="https://github.com/timdows/MMM-JsonTable" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/timdows/MMM-JsonTable</a> shows a simple structure you could aim for, e.g.</p>
<pre><code>{
    "items": [
        {
            "name": "Lifetime Energy",
            "value": "1109407"
        },
        {
            "name": "Lifetime Revenue",
            "value": "236.23314"
        },
        {
            "name": "Energy Last Year",
            "value": "1073747"
        },
        {
            "name": "Last item in my example array for now",
            "value": "3 or something"
        }
    ]
}

</code></pre>
<p dir="auto">which gives MMM-JsonTable an array named “items” (hence arrayName : ‘items’ in the config.js for the module - so you can change the array name as long as the config entry changes to match) and each entry in the <em>items</em> array has 2 datalabel:datavalue pairs in.  You can see the syntax - the array entries go between [ and ], and each entry gets its own { and } with a trailing comma between them.</p>
<p dir="auto">Does this help any?  Hopefully I haven’t misunderstood what you’re trying to achieve :)</p>
]]></description><link>https://forum.magicmirror.builders/post/82412</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/82412</guid><dc:creator><![CDATA[raymondjspigot]]></dc:creator><pubDate>Sun, 27 Sep 2020 06:14:58 GMT</pubDate></item></channel></rss>