Temperature Profiles


 

D Peart

TVWBB Pro
Original post:
http://tvwbb.com/showthread.php?221...ontroller-Part-1&p=61219&viewfull=1#post61219

I was able to cobble (with the help of a good friend) something that worked on the client, but that also meant I had to have my client always connected which is problematic.

I made some more smoked sausage a few weeks back and wished I had this feature. Maybe we could have this in the alarm code? I could see something where you would be able to set an alarm, be it time, or temperature based, that would trigger an action. The actions could be send a text, change the temperature, buzz a speaker, flash an LED, set another alarm. If we could set another alarm we could create, I think, the temperature profile. Where I could say set temp 100, after 2 hours set temperature 160 until probe 1 is 160.

I wish I could help write this stuff, but I'm more a hardware guy than software. Unfortunately my friend can no longer help me with software anymore so I'm posting here to see if others like this idea and maybe a software guy could help write it :)

thanks,
dave
 
It isn't up to programming at this point, it is just script fu. All one has to do is add three lines to /usr/lib/lua/luci/lucid/linkmeter.lua:
Code:
  if tonumber(thresh) > 0 then
    nixio.syslog("notice", "Alarm "..probeIdx..alarmType.." started ringing")
-- add the 3 lines between here
    if nixio.fork() == 0 then
      nixio.exec("/root/alarm.sh", probeIdx.." "..alarmType.." "..thresh)
    end
-- and here
  else

And then create a /root/alarm.sh script that does what you want when the alarms ring, such as this one that:
-- When the pit probe goes over 140 degrees, it sets the alarm and setpoint to 160
-- When 160 is reached it waits 2 hours then turns the temp down to 50 and sends an email
Code:
#!/bin/sh

# Index of probe (0-3)
PROBEIDX=$0
# Alarm type H or L
ALARMTYPE=$1
# Trigger temerature
THRESH=$2

if [ "$PROBEIDX" -ne 0 ] ; then
  exit
fi

if [ "$THRESH" -eq 140 ] ; then
  # up the setpoint to 160
  lmclient LMST,sp,160
  # set the probe 0 high alarm for 160
  lmclient LMST,al,,160
  exit
fi

if [ "$THRESH" -eq 160 ] ; then
  # turn the alarm off
  lmclient LMST,al,,0
  # and trigger a callback in 2 hours
  at now +2 hours << EOF
/root/alarm.sh $PROBEIDX $ALARMTYPE 999
EOF
  exit
fi

if [ "$THRESH" -eq 999 ] ; then
  lmclient LMST,sp,50
  mail -s "Food is done" you@youremail.com << EOF
  The food is done now at this time
EOF
This of course relies on mail and at being on the linkmeter which I don't think they are for non-Pi
 
Bryan,

thanks for the example. I'll have to look at it and play a little.

I don't find the lines in the linkmeter.lua that you say to insert the new lines between. How do I tell if I have the latest/greatest?

thanks
dave
 
Last edited:
That was added 22 days ago, which should be available if you get the package from
opkg install http://capnbry.net/linkmeter/snapshots/trunk/packages/linkmeter_2_brcm47xx.ipk

They're both labeled version 2 so that might create some interesting warnings so let me know if it doesn't upgrade and we'll work it out. I apologize for not having a better upgrade mechanism but I just haven't had time for it. As with all things LinkMeter, I am still constantly working on it but sometimes, like in this case, they're not obviously available. I'm trying to figure out how to pass an environment to the script, I think it is actually broken in nixio because nobody is actually using this code.
 
Bryan,

You are correct, it doesn't want to update because it says it is already up to date.

root@OpenWrt:/# opkg install http://capnbry.net/linkmeter/snapshots/trunk/packag
es/linkmeter_2_brcm47xx.ipk
Downloading http://capnbry.net/linkmeter/snapshots/trunk/packages/linkmeter_2_brcm47xx.ipk.
Package linkmeter (2) installed in root is up to date.


dave

That was added 22 days ago, which should be available if you get the package from
opkg install http://capnbry.net/linkmeter/snapshots/trunk/packages/linkmeter_2_brcm47xx.ipk

They're both labeled version 2 so that might create some interesting warnings so let me know if it doesn't upgrade and we'll work it out. I apologize for not having a better upgrade mechanism but I just haven't had time for it. As with all things LinkMeter, I am still constantly working on it but sometimes, like in this case, they're not obviously available. I'm trying to figure out how to pass an environment to the script, I think it is actually broken in nixio because nobody is actually using this code.
 
Is this on a WRT54GL or the RPi? On my Linksys it overwrites just fine. I don't have access to my Pi right now to try it but you can either try:
opkg --force-reinstall install (url)
or
opkg remove linkmeter
opkg install (url)
 
This is for the RPi.

I tried -force and it didn't like it, so I then did the remove/install and get . ..

root@OpenWrt:/usr/lib/lua/luci/lucid# opkg install http://capnbry.net/linkmeter/
snapshots/trunk/packages/linkmeter_2_brcm47xx.ipk
Downloading http://capnbry.net/linkmeter/snapshots/trunk/packages/linkmeter_2_brcm47xx.ipk.
Unknown package 'linkmeter'.
Collected errors:
* pkg_hash_fetch_best_installation_candidate: Packages for linkmeter found, but incompatible with the architectures configured
* opkg_install_cmd: Cannot install package linkmeter.

dave

Is this on a WRT54GL or the RPi? On my Linksys it overwrites just fine. I don't have access to my Pi right now to try it but you can either try:
opkg --force-reinstall install (url)
or
opkg remove linkmeter
opkg install (url)
 
After looking at this closer, it looks like that package is for the 54gl (broadcom?). Not sure if you have a different package for the RPi.

dave


This is for the RPi.

I tried -force and it didn't like it, so I then did the remove/install and get . ..

root@OpenWrt:/usr/lib/lua/luci/lucid# opkg install http://capnbry.net/linkmeter/
snapshots/trunk/packages/linkmeter_2_brcm47xx.ipk
Downloading http://capnbry.net/linkmeter/snapshots/trunk/packages/linkmeter_2_brcm47xx.ipk.
Unknown package 'linkmeter'.
Collected errors:
* pkg_hash_fetch_best_installation_candidate: Packages for linkmeter found, but incompatible with the architectures configured
* opkg_install_cmd: Cannot install package linkmeter.

dave
 
Oh this is on the Pi. Iiii don't have a place to put those packages I suppose. I've actually committed this to git but am waiting to hear back from Jow about a bug in nixio.exece(). The committed version gives you access to all the HeaterMeter variables. So if you can wait a day I'll build up some new packages with this in it.
 
No problem.

As always, thanks for the help :)
dave

Oh this is on the Pi. Iiii don't have a place to put those packages I suppose. I've actually committed this to git but am waiting to hear back from Jow about a bug in nixio.exece(). The committed version gives you access to all the HeaterMeter variables. So if you can wait a day I'll build up some new packages with this in it.
 
Alright, this is something that had to be fixed in nixio, so you can try to just pull the luci-lib-nixio package from my build directory, but I think it is going to want to require all the rest of LuCI r9411 as well. If that works you can just grab the linkmeter package there and be good to go. If not, it is probably easier to just back up your config using the web interface and flash the new snapshot then restore your config.

This adds script support for alarms via /usr/share/linkmeter/alarm*
  • /usr/share/linkmeter/alarm = This script is called when an alarm begins ringing. The environment is set with every piece of HeaterMeter configuration available at the time, as well as which alarm triggered the call. You probably do not want to change it. It calls other executables.
  • /usr/share/linkmeter/alarm-(probeindex)(alarmtype) = e.g. alarm-0H is probe 0 (pit) high alarm. Whichever alarm is ringing calls the file specific to that alarm. This can be any linux executable, a shell script, or a lua script. It inherits the environment of the main alarm script.
  • /usr/share/linkmeter/alarm-all = The default script called if no alarm-specific script is available. This will be renamed to alarm-default because I just realized while typing this that that's a much better name for it. But for now, alarm-all
Remember, that all alarm* files MUST BE EXECUTABLE. That is, they much be chmod +x.

What variables are available? Well, all of them!
Code:
al_probe - Probe that caused the alarm
al_type - Type of alarm L or H
al_thresh - The alarm threshold trigger value
sp - Setpoint
pcurr* - Current probe temperatures of all probes
pname* - Probe names
ucid - HeaterMeter version
the list goes on and on. Do a `set` (shell script) or `nixio.getenv()` (lua) to dump them all.
 
I was able to install the luci-lib-nixio package followed by the linkmeter_2 package.

I see the alarm script, so I'll give it whirl.

BTW, after installing the new linkmeter package, upon reboot of the AVR (which happened automatically) the LCD screen displayed the ip address for the RPi. I liked that, but is there a way to get it back? After hitting a button it went away.

thanks
dave

Alright, this is something that had to be fixed in nixio, so you can try to just pull the luci-lib-nixio package from my build directory, but I think it is going to want to require all the rest of LuCI r9411 as well. If that works you can just grab the linkmeter package there and be good to go. If not, it is probably easier to just back up your config using the web interface and flash the new snapshot then restore your config.

This adds script support for alarms via /usr/share/linkmeter/alarm*
  • /usr/share/linkmeter/alarm = This script is called when an alarm begins ringing. The environment is set with every piece of HeaterMeter configuration available at the time, as well as which alarm triggered the call. You probably do not want to change it. It calls other executables.
  • /usr/share/linkmeter/alarm-(probeindex)(alarmtype) = e.g. alarm-0H is probe 0 (pit) high alarm. Whichever alarm is ringing calls the file specific to that alarm. This can be any linux executable, a shell script, or a lua script. It inherits the environment of the main alarm script.
  • /usr/share/linkmeter/alarm-all = The default script called if no alarm-specific script is available. This will be renamed to alarm-default because I just realized while typing this that that's a much better name for it. But for now, alarm-all
Remember, that all alarm* files MUST BE EXECUTABLE. That is, they much be chmod +x.

What variables are available? Well, all of them!
Code:
al_probe - Probe that caused the alarm
al_type - Type of alarm L or H
al_thresh - The alarm threshold trigger value
sp - Setpoint
pcurr* - Current probe temperatures of all probes
pname* - Probe names
ucid - HeaterMeter version
the list goes on and on. Do a `set` (shell script) or `nixio.getenv()` (lua) to dump them all.
 
BTW, after installing the new linkmeter package, upon reboot of the AVR (which happened automatically) the LCD screen displayed the ip address for the RPi. I liked that, but is there a way to get it back? After hitting a button it went away.
That would be nice wouldn't it? No, once it is gone it is gone. It is something sort of on my todo list though to have it available in the menus, but it isn't now. It only happens once after the IP address of the rPi changes.
 

 

Back
Top