Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
mqtt plugin question
#11
Gerard: do you have a repository where your MQTT code resides or is it just local?

Dan: I completely agree that writes should be limited to prolong the life of the device.   I've been running some home automation software for a few years now.  All sensor data and graphs are stored in a compressed ramdisk (zram) and is synced up to a cloud several times per day.  If the device reboots it just downloads the last "cloud backup" back into zram disk and continues as normal.  ( more on zram at the end )

It appears to me that SIP will be a good platform to build on.  Environment data could be kept in small arrays in RAM.  Weather forecast, temperature, wind, soil moisture constantly change.  Gerald is right in that it will be the software logic that tie the data together.

I'll keep reading through the code to familiarize myself with the back-end of SIP.

==== zram ====
# if you are not worried about RAM size just use tmpfs /dev/shm.  If you need more ram-disk space use zram as follows:
modprobe zram num_devices=1
echo 10M > /sys/block/zram0/disksize
mkfs.ext2 /dev/zram0
mount /dev/zram0 /my_storage
#https://wiki.gentoo.org/wiki/Zram

Dean M.
Reply
#12
My wife tells me it is time for bed... Poked around a bit sip.py
* line 56 & 77 - globally makes weather adjustments for all stations that allow weather adj.

Integrating soil moisture sensors will need variable adjustment for each station/zone (not global). ( external sensors MQTT).

e.g.
* user option "Lower Threshold" to choose how dry to let the soil get before starting a cycle OR increasing duration. ( hot dry days )
* user option "Upper Threshold" to choose how wet to let the soil get before stop/cancel a cycle OR decrease duration. (rainy cool damp days)
* detect if moisture sensor values are not changing (dead battery) switch back to regular schedule ( don't over/under water )

* duration to run the station for is already in the SIP program ( deep or shallow watering )
* do we let moisture sensors adjust both start/stop time and duration? Maybe have multiple start times and the moisture sensors allow the program to run or not?
* user option to choose how long to wait once it is dry - some plants/roots require being dry and not too wet - some plants can't dry out. Over-watering = fungus, moss & root damage. Under-watering = wilting, dying, dwarfed.

* chart to track trends and make adjustments. (Send watering times/duration back over MQTT to home automation system for analysis and graphing ) This eliminates the need to store data/graphs on the irrigation controller.

To get some ideas: I'll read some manuals for irrigation controllers that include moisture sensors. e.g. the following two are simple as they just turn the zone off if the Upper Threshold % is out of bounds. No lower threshold. Includes a chart for types of soil.
http://www.rainbird.com/landscape/produc.../SMRTY.htm
http://edis.ifas.ufl.edu/ae437

This one is more advanced and has some great features Upper and Lower threshold plus calibration:
http://www.baselinesystems.com/mediafile...th_SMS.pdf
Reply
#13
Hi Dean,

Great input!

Just a couple of quick suggestions to help understand the code:

1. You may have already seen the gv_reference.txt file in the SIP directory. If not, it has descriptions of the variables SIP uses. The var names are short and not very descriptive. This is another hold over from the Arduino origin of the code.

2. There is a plugin_adjustment() function in helpers.py line 274. It allows a plugin to adjust the irrigation time.

What are you using to view/edit the code?
I have been using the Eclipse IDE (Oxygen). It is free and has a lot of great features including "Remote system explorer" which lets you browse the folders and files on one or more Pis using SSH. It also has a terminal for communicating with the Pi and of course an editor for working with the code. You can also copy files between a Pi and the host computer or between 2 Pis.

The image below shows the eclipse screen. The left panel is the remote Pi's directory structure, the center panel is the editor, the bottom panel is the terminal and the right panel is an outline of the document that is open in the editor.

   

I have been thinking about writing a tutorial on setting up Eclipse to program Pis. It is just a matter of finding the time and hoping my wife won't drag me away from the computer.

Dan
Reply
#14
(2018 Jan 18, 07:00 AM)dmonty Wrote: Gerard: do you have a repository where your MQTT code resides or is it just local?

The mqtt code is in my local repo but has to be intensively tested. This might take a while. Also I'm thinking of combining the existing mqtt plugins in a new one so that no more "inter-plugin" communication is required. At the moment the code will completely discard the client object and when the broker is available again the client is created again. After that the subscriptions have to be made again.  Al of this works fine as long as the broker downtime is at least a minute (heartbeat interval). What I don't like is the handling (or lack of) of short disruptions. So I might rewrite the whole stuff to make it more stable and neat.

About extending the mqtt and sip functionality as you, I also have some ideas, especially Mysensors integration, but also know Dan is redesigning sip. Before start coding maybe the future of sip has to be written down first. 

The small heartbeat implementation can be found on Github
Not sure if Dan likes of dislikes it, if the first is true he can copy the changes of I can create a pull request.

--Gerard
Reply
#15
Gerard,

I am making good progress with the irrigation program changes. It will probably be another week or so until it is finished. I had started working on that some time ago so there was already some code to work with but there was a contribution by a user of individual station durations that requires additional changes. One thing that caused me hesitation was the problem of converting existing program data to a new format. This time around I started from the oposite direction and wrote a small Python module first to do the conversion. It can be run stand-alone or be imported and run by SIP when someone updates the software. The new data format is making the SIP code easier to read because program elements have descriptive names rather than list indexes.

I'll take a look at your heartbeat implementation. It will probably be easiest to include it with the other code changes.

Dan
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)