amcolash / MMM-json-feed

A MagicMirror module that displays information from any json source
MIT License
17 stars 15 forks source link

Can't display values #14

Open Geoffibs opened 5 years ago

Geoffibs commented 5 years ago

Firstly, thank you for your help earlier in the year with multiple sources. Illness had prevented me from trying but a lot better now so dragged my MM out to play with again.

I have the latest version of MMM-json-feed and my issue is that I can't display individual values that worked previously. If I leave the "values:" out of config, it displays the json contents fine so I'm sure it's me just being daft but I just cannot get the right format it needs. I've not tried the earlier versions as I like the new one with multiple URL's so I can get my data from different devices.

I have attached the json data it gets.

I've tried playing around with the array function and just a plain values: ["Temperature", Humidity","Pressure"]

But I either get nothing displaying (other than the title) or "Error fetching data".

I do appreciate you are onto other things so if you have a quick moment to look at it I would be really grateful.

Thank you.

This is the config that displays the full json data. (the values are correct, it's very wet and very cold here in the UK!)

            {
                    module: "MMM-json-feed",
                    position: "top_left",
                    config: {
                    urls: [
                            "http://192.168.0.121/json?tasknr=1"
                            ],
                    title: "Rear Garden",
                    values: [
                            ]
                     }
            },

This is the result:

{ "TaskValues": [ {"ValueNumber":1, "Name":"Temperature", "NrDecimals":2, "Value":0.96 }, {"ValueNumber":2, "Name":"Humidity", "NrDecimals":2, "Value":100.00 }, {"ValueNumber":3, "Name":"Pressure", "NrDecimals":2, "Value":1016.90 }], "TTL":60000, "DataAcquisition": [ {"Controller":1, "IDX":0, "Enabled":"false" }, {"Controller":2, "IDX":0, "Enabled":"false" }, {"Controller":3, "IDX":0, "Enabled":"false" }], "TaskInterval":60, "Type":"Environment - BMx280", "TaskName":"rrenv", "TaskEnabled":"true", "TaskNumber":1 }

amcolash commented 5 years ago

Sorry for the late response. Hopefully this should work for your purposes. Please update the module as well (directions on github page).

{
  module: 'MMM-json-feed',
  position: 'top_right',
  config: {
    urls: [ "http://192.168.0.121/json?tasknr=1" ],
    title: "Rear Garden",
    arrayName: "TaskValues",
    values: [ "Name", "Value" ],
    replaceName: [
      [ "Name", "" ]
    ]
  }
}
Geoffibs commented 5 years ago

That's great thanks, I'm getting there now. Only 2 small issues I have is I can't display the name and value on the same line, and I can't bring in the humidity and pressure, only the temperature even by adding in the extra lines.

amcolash commented 5 years ago

Interesting, could you send a full json file or url? The given data above worked fine for me when I was testing. As for on the same line, let me think on that...

Geoffibs commented 5 years ago

edit: Please look at the next entry - it's better on a PC webpage than MagicMirror.

Thanks for looking into this, I'm sure it's just me being a plonker. I had to add the word "value" in { "Name", ""} or it displayed value: and the value but it still shows still on another line. The device is internal only without any security (only an esp8266) so can't expose it the full URL JSON without the filtered bit (?tasknr=1) above is:

{"System":{ "Build":20102, "Git Build":"mega-20180723", "System libraries":"ESP82xx Core 2_4_1, NONOS SDK 2.2.1(cfd48f3), LWIP: 2.0.3", "Plugins":48, "Plugin description":" [Normal]", "Local time":"2019-01-14 15:51:16", "Unit":21, "Name":"RRENV", "Uptime":680, "Last boot cause":"Manual reboot", "Reset Reason":"Software/System restart", "Load":10.40, "Load LC":18465, "Free RAM":16216 }, "WiFi":{ "Hostname":"RRENV-21", "IP config":"Static", "IP":"192.168.0.121", "Subnet Mask":"255.255.255.0", "Gateway IP":"192.168.0.1", "MAC address":"84:F3:EB:9F:40:38", "DNS 1":"8.8.8.8", "DNS 2":"0.0.0.0", "SSID":"(o) (o) Boobs", "BSSID":"E0:51:63:AC:B3:2A", "Channel":1, "Connected msec":40813878, "Last Disconnect Reason":1, "Last Disconnect Reason str":"(1) Unspecified", "Number reconnects":0, "RSSI":-78 }, "Sensors":[ { "TaskValues": [ {"ValueNumber":1, "Name":"Temperature", "NrDecimals":2, "Value":6.98 }, {"ValueNumber":2, "Name":"Humidity", "NrDecimals":2, "Value":100.00 }, {"ValueNumber":3, "Name":"Pressure", "NrDecimals":2, "Value":1021.02 }], "DataAcquisition": [ {"Controller":1, "IDX":0, "Enabled":"false" }, {"Controller":2, "IDX":0, "Enabled":"false" }, {"Controller":3, "IDX":0, "Enabled":"false" }], "TaskInterval":60, "Type":"Environment - BMx280", "TaskName":"rrenv", "TaskEnabled":"true", "TaskNumber":1 }, { "TaskValues": [ {"ValueNumber":1, "Name":"level", "NrDecimals":2, "Value":962.00 }], "DataAcquisition": [ {"Controller":1, "IDX":0, "Enabled":"false" }, {"Controller":2, "IDX":0, "Enabled":"false" }, {"Controller":3, "IDX":0, "Enabled":"false" }], "TaskInterval":60, "Type":"Analog input - internal", "TaskName":"rrlite", "TaskEnabled":"true", "TaskNumber":2 } ], "TTL":60000 }

Geoffibs commented 5 years ago

Before you look at this - I've just loaded the Magic Mirror it on a PC webpage and it displays the Humidity and Pressure so something on the MM side of things. The value is still on a newline though. Thanks, Geoff

amcolash commented 5 years ago

I added in some code to handle putting things on a single line, definitely hackish at the moment but I am pretty busy and should probably rewrite this module soon anyways.

Not sure about your MM not getting data correctly, sounds like a potential issue on the esp side - I have had some flakey interactions with my own esp devices if not set up properly with their code.

Anyways, update and then modify your config to have singleLine: true and change the replaceName array as well to match.

{
    module: 'MMM-json-feed',
    position: "top_left",
    config: {
        urls: [
            "http://192.168.0.121/json?tasknr=1"
        ],
        title: "Rear Garden",
        arrayName: "TaskValues",
        values: [
            "Name",
            "Value"
        ],
        singleLine: true,
        replaceName: [
            ["Name", ""],
            ["Value", " "]
        ]
    }
}
Geoffibs commented 5 years ago

Single line solution is perfect, thank you.

I worded the way it is only showing the first line badly. What I meant was on the PI MagicMirror browser it only shows one line. Using a PC connecting to the same PI (not the esp directly) it shows all correct lines so something in the MM browser. Strange.

Yes, the full json data is crazy the way it is formatted. I'm using espeasy firmware. I can filter it though by task though using ?tasknr=1 at the end of the url which will strip out all the others and only give me: { "TaskValues": [ {"ValueNumber":1, "Name":"Temperature", "NrDecimals":2, "Value":0.96 }, {"ValueNumber":2, "Name":"Humidity", "NrDecimals":2, "Value":100.00 }, {"ValueNumber":3, "Name":"Pressure", "NrDecimals":2, "Value":1016.90 }], "TTL":60000, "DataAcquisition": [ {"Controller":1, "IDX":0, "Enabled":"false" }, {"Controller":2, "IDX":0, "Enabled":"false" }, {"Controller":3, "IDX":0, "Enabled":"false" }], "TaskInterval":60, "Type":"Environment - BMx280", "TaskName":"rrenv", "TaskEnabled":"true", "TaskNumber":1 }

Instead of everything I sent in my previous mail. so, ?tasknr=2 would give me the part of the large json from another sensor and so on, so I'm not as worried about that now I can use multiple urls.

Only issue for me now is the single line in the MM browser. Temperature, instead of temperature, pressure, humidity.

Thank you once again, I really do appreciate this.

amcolash commented 5 years ago

I am not sure if this is all fixed for you now. Can I close this issue?

Geoffibs commented 5 years ago

Sort of thank you.

Everything now works from a data point of view but it will only display a single line on the MM browser on the PI. If I call the PI MM from a chrome browser on a PC then it displays perfectly. I'm not calling the ESP, the actual mm for a remote screen.

i.e.

MM is on 192.168.0.120 displays only the first line (temperature) If I call the MM from chrome on a PC - 192.168.0.120:8080 it displays the 3 lines. Temp/humidity/pressure

I'm assuming this is an issue with the MM browser but not sure if there is something in the formatting you can work your magic on?

Thanks Andrew.

amcolash commented 5 years ago

could you send a screenshot to clarify what you mean? things look fine from my perspective (in browser) and don't have access to a pi at the moment...

On Sat, Feb 2, 2019 at 3:14 PM Geoffibs notifications@github.com wrote:

Sort of thank you.

Everything now works from a data point of view but it will only display a single line on the MM browser on the PI. If I call the PI MM from a chrome browser on a PC then it displays perfectly. I'm not calling the ESP, the actual mm for a remote screen.

i.e.

MM is on 192.168.0.120 displays only the first line (temperature) If I call the MM from chrome on a PC - 192.168.0.120:8080 it displays the 3 lines. Temp/humidity/pressure

I'm assuming this is an issue with the MM browser but not sure if there is something in the formatting you can work your magic on?

Thanks Andrew.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/amcolash/MMM-json-feed/issues/14#issuecomment-460007713, or mute the thread https://github.com/notifications/unsubscribe-auth/AH5hLUouUWgfzYuG14Dx5Hc2juQhs94Lks5vJhu8gaJpZM4ZUyxp .

Geoffibs commented 5 years ago

Yes, I'm not at home at the moment so will do it tomorrow. Your right though, it's great in a browser.

Geoffibs commented 5 years ago

Great on a browser but on the PI in the MM itself it displays only the first line. I'm using the default browser install within MagicMirror.

mmmjsondisplayoutputs

amcolash commented 5 years ago

Weird, unfortunately I can't help out too much on that without some more info and am not sure why this is an issue. I checked your sample data on my magic mirror with no issues.

You could try disabling any other modules (to make sure they are not overlapping). Have you updated both the base Magic Mirror with apt-get update && apt-get upgrade? Have you updated the Magic Mirror repo with cd MagicMirror && git pull?

Can't help much more than that unfortunately since I can't repro this on any of my devices (running latest versions of MM).

Geoffibs commented 5 years ago

Thanks Andrew. Nothing overlapping. Just to throw another curveball in, the earlier version of MMM-json-feed displays it fine but can't use that as I want multiple URLs. In saying that, I haven't got the very latest version of Midori on the PI as I'm running it on a ZeroW and can't get it working so a couple of versions behind. Must be that. Thank you anyway for all your help, it's really appreciated.

amcolash commented 5 years ago

I have a very strong feeling that the multiple urls are interfering with your setup. Try with one single url, then have multiple json modules stacked and see if you can work it out that way. Honestly, a lot of these features are far outside the scope of this fun little test repo (as it started). Wish you the best on this one!

Geoffibs commented 5 years ago

Good news - the issue is definitely because of older versions of MM and Midori. I couldn't upgrade with it being on a pi ZeroW due to the ARM and electron support so I finally rebuilt completely enabling me to do a few workarounds. Thank you again for a great module. Works great.

One display question (wouldn't be me if I didn't want it changing.....) When it has multiple lines, is there a way to remove the seperating lines underneath? I only really want the underline on the title. I've tried a few things in custom.css but that doesn't seem to having an effect other than font. When using quite a few, it gets difficult to read. (for me) Thanks again. image

AndreDeux-Montanges commented 4 years ago

@Geoffibs I commented these lines in MMM-json-feed.js and no more line between items. //var hr = document.createElement("hr"); //hr.style = "border-color: #444;" //tableElement.appendChild(hr); sorry to mess with your code @amcolash :-)

@amcolash , thanks for the module, i am able to fetch status of my devices in Homeseer now !

I am looking at changing the font for a smaler size as I need to list 13 items pair (name,value) Each item takes 2 lines one for name and one for value ( singleline:true ) puts ALL 13 pairs on same line

Wish I could format this way name : value name : value name : value

I am running latest version of magicmirror2, on a PI 3B

here is my config :

{module: 'MMM-json-feed', position: 'bottom_left', config: { arrayName: "Devices",
singleLine:false, values:["name","status"], urls: ['http://192.168.20.102/JSON?request=getstatus&ref=309,312,315,318,321,324,325,326,329,343,346,362' ], replaceName: [ [ "Name", ""], [ "status","" ] ]

              }

},