Deprecated: Calling get_class() without arguments is deprecated in /home/bbbeabea/mqttcogs.sailresults.org/wp-includes/class-wp-http.php on line 329
Really Simple – MqttCogs WordPress Plugin

Really Simple

This example shows how to create simple LineChart using the smallest amount of code. Lets start by taking a look at the shortcode. As with all the examples, I’ve added a space after/before any square brackets to make sure that the shortcode is not processed. You need to remove this if you are copying this code!

[ mqttcogs_drawgoogle charttype="LineChart" options="{}" ] 
      [ mqttcogs_data topics="mysensors_out/100/1/1/0/0" ]
[ /mqttcogs_drawgoogle ]

There are two shortcodes you need to use. The outer shortcode mqttcogs_drawgoogle  to tell the plugin that you want to draw a graph and the inner shortcode mqtt_data to tell the plugin what data you want to use.

As you can see from the example, the only required at attribute you need to draw a graph is the topic you want to use as your series. Any attribute that is not specified is set to it’s default value.

The topic that I want to graph is mysensors_out/100/1/1/0/0. This is the standard MySensors format for sensor id 100’s temperature. You don’t have to use MySensors you can graph any MQTT data stream!

The output of this looks like this:




22 Comments

HI ,
I tried to set it according to the instructions, but the mqtt data will not be displayed, only the drop-down components and next…, how to fix it?

What version of MqttCogs are you using?

Have you entered the parameters in the MQttCogs setup section and switched on debugging?

Hi,

I’m trying to achieve the following:

I want to display some temperature from my weather station with only 1 decimal.
The raw mqtt data is something like: 12.5362228 degrees. Ho can I strip the decimals to just one or two decimals?

Hope someone can help me with this.

Greetings

Sorry,

Dit not notice your reply.

The shortcode I use is:
[mqttcogs_drawhtml topics='weather/outTemp_C'] Temperatuur: {0,1} graden  [/mqttcogs_drawhtml]

Hi Arjen,

Apologies for the long delay getting back to you. Work is taking up too much time.

There are some options here I think. This isn’t all of them, just the ones from the top of my head.

Client:
1) You could perhaps write your output into an and write a simple inline javascript function in the onchange event to format your value.

Server (as the data is persisted)
2) The mqttcogs_msg_in_pre hook allows you to manipulate the data before it is persisted to the database.

Server (as the data is extracted from the database)
3) The mqttcogs_topic_pre hook allows you to manipulate the data after it is extracted from the database.

I’d choose (3). It keeps the accuracy in the database and formats the data before it is sent to the client.

I hope this helps.

Chris

Hi Chris

“Sapperlott” thats german, means I m surprised about the efficent support.
Now it works. I can show my IOT data.
Thank you.
Roland

Hi Roland,

Glad to hear it works. I added a lot of functionality in the last couple of weeks. Let me know if there are any other features that might be of use.

I’ve completed items on http://mqttcogs.sailresults.org/faqs/roadmap-or-something

I’m disappointed with the Google Map visualization so I might have a look at a replacement for this (for example, Leaflet) . Otherwise I’ll have a think about where to go next.

Chris

Hello

By using the example, I got this error:

Notice: Undefined index: ajax in /mnt/web305/c3/75/58710675/htdocs/WordPress_SecureMode_01/wp-content/plugins/mqtt-cogs/MqttCogs_Plugin.php on line 1147

The connection to the db is ok, I can see a lot of data.

Hi Roland.

Try the most recent release (published today). I added a minor bugfix to get the ajax calls working just recently and I think that may be the problem. Let me know if this works.

Chris

Hi Chris,

Sorry for the little spam here…

I already fixed my “Challenge”…
It was a syntax error within my cron link…(kind of unique rule from my webhosting )

Thank You very much for Your support.

You did a good job, I like this plugin.

Kindly regards,

Gabriel

Hi Chris,

This I have logged after the launching the cron…

88.86.120.176 – – [06/May/2018:03:15:03 +0200] “GET xxxxxxxxxxxxxxx/web/wp-cron.php HTTP/1.0” 404 51567 “-” “Wget/1.14 (linux-gnu)”

Gabriel

Hi Chris,

I already found some logs but without any errors sice the new version of your plugin. It will be good idea to have possibility of mqttcogs own debugging log.

I have set
debug: ON,
Topic filter # (This may pass all topics I think..),
MQTT version 3_1_1,
Save data for: forever
Read role: anyone
Write role: subscriber
connection recycle: 298

wp-cron.php I have configured to launch every 5 minutes (This is the minimal period given by my webhosting ) I have only possibility to configure link to php script and scheduling with combo-boxes
….so little bit tricky for testing changes with 5- minutes delay 🙂

Gabriel

Hi Chris,

Where is the log file “php_errors.log” situated?

(I don´t have a console possibility within my webadmin page…maybe I need to access with some FTP tool to seek the filenames..)

PS: The warning mentioned above is now fixed but still have no data…( used v1.3)

Thank You

Hi Gabriel,

Yes, I tested with 7.1. I replicated the same error you specified and then fixed for v1.3 (although this shouldn’t stop it from receiving messages).

On my server, it’s in the root of the site. The standard php_errors file I think. If you can get hold of the contents this will help. I should probably provide some way of viewing the log in the code as well.

BTW, what parameters have you used in the setup page? Topic filter #, Debug on etc?

Chris

Hello,
I am very interested in your plugin. I would like to ask you because I dont have anz data in my table updated. It is still empty. I tried lot of things…I have one warning:

Warning: Declaration of MySubscribeCallback::publish($mqtt, $publish_object) should be compatible with sskaje\mqtt\MessageHandler::publish(sskaje\mqtt\MQTT $mqtt, sskaje\mqtt\Message\PUBLISH $publish_object) in /home/users/XXXXXXXXX/XXXXXXXXXX.XXXX.XX/web/wp-content/plugins/mqtt-cogs/MqttCogs_Plugin.php on line 830. Maybe this is the reason. I have also installed the mqtt-spy and I also used cloudmqtt broker like you. The MQTT server/port is in format: tcp://xxx.cloudmqtt.com:xxxxx

Thank You for Your Answer

I’ve done another release (only a couple of check ins) and reinstalled to this site.

Running with PHP v7 causes the logged error that you saw. I’ve fixed the error and done another release. Although on my site it still wrote to the database.

You need to look in the php_errors.log file – this is where the plugin writes it’s log. I get some entries like this. If there are problems with connecting to your mqtt broker you will see that in here.

[04-May-2018 11:02:49 UTC] ERROR Lock is not acqiured
[04-May-2018 11:03:50 UTC] ERROR Lock is not acqiured
[04-May-2018 11:04:51 UTC] ERROR Lock is not acqiured

Chris

Leave a Reply to Gabriel Cancel reply

Your email address will not be published. Required fields are marked *