I’d suggest that you make that a separate program. Archiver simply inserts the data into the database. Make a notifier program that periodically queries the database, looks for specific conditions and does something (like send email) if it finds those conditions met.
Those sound good . . ,
I intend to add events to archive.js that will trigger other applications that will do the actual checking and notification. This works great with nodejs since it’s non-blocking.
Simply put, archive.js will fire off an event.
I’ve sitting home, watching The Simpson’s, and thinking about your suggestion. Running a single query every X seconds may actually be the simplest way to handle this.
It will also allow others to write their own code to customize the events.
While testing the new code, I found an error in the old code. Please download again.
sudo wget -N http://fsoft.com/wfarchiver/archive.js
I found an error so please download again.
sudo wget -N http://fsoft.com/wfarchiver/daily-stats.js
Thanks Gary … so without the [ I assume;
I’m having trouble getting it working … I did your previous updates also
sudo wget -N http://wf.fsoft.com/wfarchiver/alter-tables5.js
and
node alter-tables5.js
but getting
2018-08-03 15:19:01 Starting WFArchiver v1.4.4
2018-08-03 15:19:01 Listening on: 0.0.0.0:50222
2018-08-03 15:19:08 Error in insertHubStatus
in the archive.log
Is that expected?
Thanks for your help.
Download archive.js and let me know what the log shows.
Maybe the uid/pwd/dbname that I edit in the .js file??
I want to know if any of you have an interest of having the GPIO pins on the Raspberry Pi available.
I have been playing with turning on pins for the following:
Firmware Update
Lightning
Rain
Hub Reboot
Lost Hub Status
Lost Device Status
Hub reboot???
Yes. I forget to add that one.
Hi Gary, I’m having dificultly in installing WFarchiver on my Pi. At the last instruction “node create-database-tables.js” I’m unable to connect to the db.
“Connecting to SQL
error when connecting to db: { Error: connect ECONNREFUSED 127.0.0.1:3306
at Object._errnoException (util.js:992:11)
at _exceptionWithHostPort (util.js:1014:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1186:14)
--------------------
at Protocol._enqueue (/home/pi/wfarchiver/node_modules/mysql/lib/protocol/Protocol.js:144:48)
at Protocol.handshake (/home/pi/wfarchiver/node_modules/mysql/lib/protocol/Protocol.js:51:23)
at Connection.connect (/home/pi/wfarchiver/node_modules/mysql/lib/Connection.js:118:18)
at Timeout.sqlConnect [as _onTimeout] (/home/pi/wfarchiver/create-database-tables.js:97:6)
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
at Timer.listOnTimeout (timers.js:290:5)
code: ‘ECONNREFUSED’,
errno: ‘ECONNREFUSED’,
syscall: ‘connect’,
address: ‘127.0.0.1’,
port: 3306,
fatal: true }”
Any thoughts as to what I’m missing here?
Cheers Ian
Check to see if you followed these instructions:
<!-- Edit the config file for MariaDB -->
sudo nano /etc/mysql/my.cnf
<!-- At the end of the file add the following two lines -->
[mysqld]
bind-address = 0.0.0.0
<!-- Save the file and exit ctrl-O <enter> ctrl-X -->
<!-- Restart MariaDB with the following -->
sudo /etc/init.d/mysql restart
Thanks Gary, all good just a small typo error.
Many thanks Ian
Here is the first addition GPIO on the Pi.
Software debouncing???
Yes, software debouncing.
Does your implementation allows the use of the GPIOs by other software running on the RPi in parallel… for shure not the same pins
What use case do you consider according to the button ?
Yes. Other applications can use any of the IO pins as allowed.
The button is used to simulate the contacts that are on a tipping bucket.