ciknowles / mqtt-cogs

Wordpress mqtt plugin
MIT License
22 stars 9 forks source link

Unable to view graph with code example #15

Closed mycael closed 1 year ago

mycael commented 2 years ago

Hello, We meet a problem to display value in our wordpress page. The MQTT messages we send from MQTTBox or Node-Red app for exemple appears well in the database with the topic and the payload. image

But the snippet code doesn't work on our page. In WP settings page of MQTT cogs, the "MQTT data" tab is empty.

We try the code : [mqttcogs_drawhtml topic= 'test/valnum' ] Valeur : {0,0} [/mqttcogs_drawhtml] and nothing happens on the page.

or this one : [mqttcogs_drawgoogle options="{width:'100%'}"] [mqttcogs_data topics="test/valnum"] [/mqttcogs_drawgoogle]

And for this second, we get the message : Not enough columns given to draw the requested chart. Have you an idea what we're doing wrong ? Thank you !

ciknowles commented 2 years ago

Hi,

Confirm that you can see data on your page with just

[mqttcogs_data topics="test/valnum"]

Then try

[mqttcogs_drawgoogle ajax="true" charttype="Table" options="{width: '100%', height: '100%'}]
       [mqttcogs_data topics="test/valnum"]
[/mqttcogs_drawgoogle]

Might be just that you need to give it a chart type.

Chris

ciknowles commented 2 years ago

Also, might be worth checking out this post

Google visualization charts are really good but the table one isn't...

Chris

mycael commented 2 years ago

Thank you for your help ! Unfortunately, with the code below : [mqttcogs_data topics="test/valnum"] I get : {"cols":[{"id":"utc","label":"utc","type":"datetime"}],"rows":[]}

The others tests give tables without data : image

ciknowles commented 2 years ago

Hi,

So you are not getting any data. Try adding in a limit and a from, see if that gets you some data.

Chris

On 29/03/2022 20:44, Michael Guarisco wrote:

Thank you for your help ! Unfortunately, with the code below : [mqttcogs_data topics="test/valnum"] I get : {"cols":[{"id":"utc","label":"utc","type":"datetime"}],"rows":[]}

The others tests give tables without datas : image https://user-images.githubusercontent.com/7772190/160694024-268abc73-871d-4a7a-ab6f-42b72e5651de.png

— Reply to this email directly, view it on GitHub https://github.com/ciknowles/mqtt-cogs/issues/15#issuecomment-1082305711, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD5TPI277WL5TASFOEEMNDTVCNMTDANCNFSM5R6XKWSA. You are receiving this because you commented.Message ID: @.***>

mycael commented 2 years ago

It still doesn't work. I wonder if the database is populated but the plugin can't display anything. Do I need special permissions in the database? Does the payload have to have a particular form? I just place a single numeric value in the payload.

seanhuang5104 commented 1 year ago

Similar issue here, I can see data using only short code of [mqttcogs_data ]. but for the drawing part will get "Uncaught ReferenceError: alltables is not defined at datatablesdrawer.js?ver=2.3:2:1" for both datatable or goorle chart draw.

ciknowles commented 1 year ago

Hi, I will take a look at this. What version of the code are you using? Chris

seanhuang5104 commented 1 year ago

the version is 2.32 runs on PHP 7.4.33

seanhuang5104 commented 1 year ago

some updates here. the "allcharts" in "shortcodeDrawGoogle" is missing due to "wp_localize_script" fails. I move "wp_register_script" of chartdrawer, google_loadecharts and loadgoogle to "shortcodeDrawGoogle" right before the "wp_enqueue_script" lines. then variable "allcharts" start to appear as normal.

After modifications, it works for me perfectly.

ciknowles commented 1 year ago

FYI, I am currently looking at this.

ciknowles commented 1 year ago

Ok, I released a new version 3.0 of mqttcogs. The table output is now working in:

https://mqttcogs.sailresults.org/examples/how-to-output-a-table/ https://mqttcogs.sailresults.org/examples/mqttcogs-now-supports-datatables/

I've also updated the documentation as some of the graphs were no longer working due to missing data.