Rainmeter scripts

Hi all,

I used to have conky scripts doing real-time graphing of my house power draw. I have recently acquired a Windows machine and am interested in getting similar functionality. I've started to use RainMeter, but before I write my own scripts I thought I should check if anyone has got any RainMeter scripts ready to roll.

P.S. My conky scripts basically make use of wget to hit the flukso device to get a dump of the last minute. I use the array of values as a source of graphing data.

P.P.S. I've already googled site:flukso.net rainmeter and come up with nothing, so anything from you guys and gals would be much appreciated.

Kind Regards,
JasonP

Fluc's picture

I'm Sorry, I can"t help you with the Rainmeter scripts, but I’m very interesting in your Conky scripts to show real-time graphing of the Fukso outputs :D

jasonp's picture

OK. Here are the conky scripts.

Note that each conky window calls a script, which returns a number that is used to indicate how much power is being used right now. Additionally it writes a number to a file that can be used to create a graph. (You'll see that in "flukso-usage.sh")

The only bits other fluksonians will have to update is the flukso-device-ID, the IP of their flukso box, and perhaps the color1, color2 and color3 variables in the conkyrc* files to suit ones own desktop. Good luck!

The first one just kicks off a few conky instances:
conky-start is triggered when I log on to the box, it simply kicks off a few instances of conky:

  1. #!/bin/bash
  2. #http://crunchbanglinux.org/wiki/howto/howto_setup_multiple_conky_sessions
  3. sleep 2
  4. conky -c ~/scripts/conky/conkyrc_normal &
  5. conky -c ~/scripts/conky/conkyrc_bigflukso &
  6. conky -c ~/scripts/conky/conky_ups

And here is the first conky-script - conkyrc_normal. It is a fairly standard conky window. Down near the bottom is the flukso portion:

  1. use_xft yes
  2. override_utf8_locale yes
  3. xftfont Terminus:size=10
  4. xftalpha 0.8
  5. update_interval 5.0
  6. total_run_times 0
  7. own_window yes
  8. own_window_transparent yes
  9. own_window_argb_visual yes
  10. #own_window_type normal
  11. #own_window_type override
  12. own_window_class conky-semi
  13. own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
  14. background no
  15. double_buffer yes
  16. minimum_size 300 200
  17. draw_shades no
  18. draw_outline no
  19. draw_borders no
  20. draw_graph_borders yes
  21. default_shade_color black
  22. default_outline_color white
  23. default_bar_size 150 5
  24. default_gauge_size 100 100
  25. default_graph_size 350 100
  26. imlib_cache_size 0
  27. draw_shades no
  28. alignment top_right
  29. gap_x 1695
  30. gap_y 35
  31. #no_buffers yes
  32. uppercase no
  33. cpu_avg_samples 2
  34. override_utf8_locale no
  35. #default_color ECEAE4
  36. default_color black
  37. color1 FAD210
  38. color2 FA970E
  39. #color3 563D27
  40. color3 white
  41.  
  42. TEXT
  43. ${font AvantGardeLTMedium:bold:size=10}${color3}Info ${hr 2}${font}
  44. Date                    ${alignr}${time %a} ${time %e %B %G}
  45. Time                    ${alignr}${time %T}
  46.  
  47. ${font AvantGardeLTMedium:bold:size=10}${color3}System ${hr 2}${font}
  48. Hostname                ${alignr}${nodename}
  49. ${sysname}              ${alignr}${kernel}-${machine}
  50. CPU                             ${alignr}${freq_g}GHz
  51. Uptime                  ${alignr}${uptime}
  52. SDA     ${alignr}${hddtemp /dev/sda}${iconv_start UTF-8 ISO_8859-1}°${iconv_stop}C
  53. SDB     ${alignr}${hddtemp /dev/sdb}${iconv_start UTF-8 ISO_8859-1}°${iconv_stop}C
  54. SDC     ${alignr}${hddtemp /dev/sdc}${iconv_start UTF-8 ISO_8859-1}°${iconv_stop}C
  55.  
  56. ${font AvantGardeLTMedium:bold:size=10}${color3}Processors ${hr 2}${font}
  57. Core 1  ${exec sensors | grep 'Core 0' | cut -c16-19}${iconv_start UTF-8 ISO_8859-1}°${iconv_stop}C    ${alignr} Usage ${cpu cpu1}%  ${cpubar cpu1}
  58. Core 2  ${exec sensors | grep 'Core 1' | cut -c16-19}${iconv_start UTF-8 ISO_8859-1}°${iconv_stop}C    ${alignr} Usage ${cpu cpu2}%  ${cpubar cpu2}
  59.  
  60. ${font AvantGardeLTMedium:bold:size=10}${color3}Memory ${hr 2}${font}
  61. Free: ${memeasyfree}    ${alignr}Total: ${memmax}
  62. Currently using:                ${alignr}${memperc}%   ${membar}
  63.  
  64. ${font AvantGardeLTMedium:bold:size=10}${color3}Networking ${hr 2}${font}
  65. ${if_existing /proc/net/route wlan0}wlan0 IP            ${alignr}${addr wlan0}
  66. AP                              ${alignr}${wireless_essid wlan0}
  67. Signal                  ${alignr}${wireless_link_qual_perc wlan0}${wireless_link_bar 10,100 wlan0}
  68. Download                ${alignr}${downspeed wlan0}${downspeedgraph wlan0 10,100}
  69. Upload                  ${alignr}${upspeed wlan0}${upspeedgraph wlan0 10,100}
  70. Total Down/Up   ${alignr}${totaldown wlan0}/${color}${totalup wlan0}
  71. ${else}${if_existing /proc/net/route eth0}eth0 IP               ${alignr}${addr eth0}
  72. Download                ${alignr}${downspeed eth0}${downspeedgraph eth0 10,100}
  73. Upload                  ${alignr}${upspeed eth0}${upspeedgraph eth0 10,100}
  74. Total Down/Up   ${alignr}${totaldown eth0}/${totalup eth0}${endif}${endif}
  75.  
  76. ${font AvantGardeLTMedium:bold:size=10}${color3}Flukso House Power Draw ${hr 2}${font}
  77. Watts Now: ${exec ~/scripts/flukso-usage.sh 691b92f72245f9d2b9dee655c4bb7c61} ${alignr}${execbar cat ~/.config/flukso/691b92f72245f9d2b9dee655c4bb7c61/cache/decawatts-now.txt}
  78. #${execgraph -t -l cat ~/.config/flukso/691b92f72245f9d2b9dee655c4bb7c61/cache/decawatts-now.txt}
  79. ${execgraph -t cat ~/.config/flukso/691b92f72245f9d2b9dee655c4bb7c61/cache/decawatts-now.txt}
  80.  
  81. ${font AvantGardeLTMedium:bold:size=10}${color3}Top Processes ${hr 2}${font}
  82. Process         ${alignr}CPU  Mem
  83. ---------------------   ${alignr}--------   ------
  84. ${top name 1}   ${alignr}${top cpu 1} ${top mem 1}
  85. ${top name 2}   ${alignr}${top cpu 2} ${top mem 2}
  86. ${top name 3}   ${alignr}${top cpu 3} ${top mem 3}
  87. ${top name 4}   ${alignr}${top cpu 4} ${top mem 4}
  88. ${top name 5}   ${alignr}${top cpu 5} ${top mem 5}
  89. ${top name 6}   ${alignr}${top cpu 6} ${top mem 6}
  90. ${top name 7}   ${alignr}${top cpu 7} ${top mem 7}

The following is conkyrc_bigflukso. It creates a long graph that is a representation of the last 24 hours of power draw:

  1. use_xft yes
  2. override_utf8_locale yes
  3. xftfont Terminus:size=10
  4. xftalpha 0.8
  5. update_interval 60.0
  6. total_run_times 0
  7. own_window yes
  8. own_window_transparent yes
  9. own_window_argb_visual yes
  10. #own_window_type normal
  11. #own_window_type override
  12. own_window_class conky-semi
  13. own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
  14. background no
  15. double_buffer yes
  16. minimum_size 300 200
  17. draw_shades no
  18. draw_outline no
  19. draw_borders no
  20. draw_graph_borders yes
  21. default_shade_color black
  22. default_outline_color white
  23. default_bar_size 150 5
  24. default_gauge_size 100 100
  25. default_graph_size 1440 100
  26. imlib_cache_size 0
  27. draw_shades no
  28. alignment top_right
  29. gap_x 30
  30. gap_y 30
  31. #no_buffers yes
  32. uppercase no
  33. cpu_avg_samples 2
  34. override_utf8_locale no
  35. #default_color ECEAE4
  36. default_color black
  37. color1 FAD210
  38. color2 FA970E
  39. #color3 563D27
  40. color3 white
  41.  
  42. TEXT
  43. ${font AvantGardeLTMedium:bold:size=10}${color3}Flukso House Power Draw - Last 24 Hours (Watts Now: ${exec ~/scripts/flukso-usage.sh 691b92f72245f9d2b9dee655c4bb7c61}) ${hr 2}${font}
  44. #${execgraph -t cat ~/.config/flukso/691b92f72245f9d2b9dee655c4bb7c61/cache/decawatts-now.txt}
  45. ${execgraph -t ~/scripts/flukso-usage-minute.sh}
  46. |24hrs ago             |22hrs ago             |20hrs ago             |18hrs ago             |16hrs ago             |14hrs ago             |12hrs ago             |10hrs ago             |8hrs ago              |6hrs ago                |4hrs ago          ${alignr}|       ${time %a} ${time %T} |

Here is the script that the first conky window relies on: flukso-usage.sh

  1. #!/bin/bash
  2. ## flukso-usage.sh
  3. ## Author:
  4. ## Jason Pluis <jason@pluis.com.au> <a href="http://blog.pluis.com.au<br />
  5. ##" title="http://blog.pluis.com.au<br />
  6. ##">http://blog.pluis.com.au<br />
  7. ##</a> Created on 11th October 2012.
  8. ## Licensed under the GPL version 3.
  9. ##
  10. ## Get power usage information from ones internal fluksometer.
  11. ## requires: curl and gawk
  12. ##
  13. ## Call this script using the sensor ID as the first and only parameter
  14. ## i.e. ./flukso-usage.sh 691b92f72245f9d2b9dee655c4bb7c61
  15. ## note that the flukso ID is not mine it is made up in the above example
  16.  
  17. ver=0.0.1
  18. fluksoIP=10.10.0.16
  19.  
  20. #for testing raw output
  21. #curl "http://10.10.0.16:8080/sensor/$1?version=1.0&interval=minute&unit=watt&callback=realtime"
  22.  
  23. if [ -n $1 ]; then
  24.     #echo "Using account: $1"
  25.     conf_dir="$HOME/.config/flukso/$1"
  26.     HOME=$conf_dir
  27. fi
  28.  
  29. cache_dir=$conf_dir/cache
  30. tmp_dir=$conf_dir/tmp
  31. log=$conf_dir/node-usage.logd
  32. url="http://$fluksoIP:8080/sensor/$1?version=1.0&interval=minute&unit=watt&callback=realtime"
  33. curl="`which curl` -s -A \"Flukso\ Usage\ for\ Conky\ $ver\" -e <a href="http://pluis.com.au/pub/flukso-usage/"</p>
  34. <p>#" title="http://pluis.com.au/pub/flukso-usage/"</p>
  35. <p>#">http://pluis.com.au/pub/flukso-usage/"</p>
  36. <p>#</a> Create and check for working directories
  37. if [ ! -d $cache_dir ]; then
  38.         mkdir -p $cache_dir
  39. fi
  40.  
  41. if [ ! -d $tmp_dir ]; then
  42.         mkdir -p $tmp_dir
  43. fi
  44.  
  45. # Grab the details
  46. #$curl $url > $tmp_dir/realtime
  47. /usr/bin/curl -s $url > $tmp_dir/realtime
  48. sleep 1
  49.  
  50. wattsnow=$(cat $tmp_dir/realtime | cut -d"(" -f2 | cut -d"]" -f60 | cut -d"," -f3)
  51. echo "$wattsnow" > $cache_dir/watts-now.txt
  52. echo "$wattsnow/100" | bc -l | cut -d "." -f1 > $cache_dir/decawatts-now.txt
  53. echo "$wattsnow"
  54.  
  55. exit

Finally, here is the bash script that the large graph conky window relies upon: flukso-usage-minute.sh

  1. #!/bin/bash
  2. ## flukso-usage-minute.sh
  3. ## Author:
  4. ## Jason Pluis <jason@pluis.com.au> <a href="http://blog.pluis.com.au<br />
  5. ##" title="http://blog.pluis.com.au<br />
  6. ##">http://blog.pluis.com.au<br />
  7. ##</a> Created on 6th April 2014.
  8. ## Licensed under the GPL version 3.
  9. ##
  10. ## Get last minute avg power draw from fluksometer.
  11. ## requires: curl and gawk
  12. ##
  13.  
  14. url="http://10.10.0.16:8080/sensor/691b92f72245f9d2b9dee655c4bb7c61?version=1.0&interval=minute&unit=watt&callback=realtime"
  15.  
  16. # remove extraneous text at beginning and end
  17. fluksodump=`/usr/bin/curl -s $url | cut -d"(" -f2 | cut -d")" -f1`
  18. #remove square brackets
  19. fluksodump=${fluksodump//[/}
  20. fluksodump=${fluksodump//]/}
  21. #replace commas with spaces
  22. fluksodump=${fluksodump//,/ }
  23. #get as array, noting that the array consists of tuples where the array is
  24. #time watts time watts time watts time watts ...
  25. #so we only want every second element (watts) to be summed and averaged to get a 1 minute avg
  26. numbers=($fluksodump)
  27. sum=0;
  28. for ((i=1; i<${#numbers[@]}; i=$i+2));
  29. do
  30.         #echo $i ": " ${numbers[$i]};
  31.         sum=$(expr $sum + ${numbers[$i]})
  32. done
  33.  
  34. #average to powerdraw for one minute
  35. sum=$(expr $sum / 60)
  36.  
  37. #conky graphs stuff in percentage format and will only accept values
  38. #in the range 0:100, so divide by another 100 will ensure anything up 10kW
  39. #will be graphed approporately. ie 10kW = 100. If we start consistently
  40. # pulling more than 10kW will have to increase divisor...
  41. echo $(expr $sum / 100)
  42. exit

The code is quite ordinary. I am aware that I didn't follow a few basic code principles, but it works for me. Hopefully it works for you to :-)

I was going to attach pics of the output but I can't see a way to upload pics to forum posts.

Cheers,
JasonP

Fluc's picture

Waaaaaaaw, thanks for the Conky scripts Jason :))
I use Ubuntu and Linux Mint, so i am very very happy with this.
If i find the time, in a few days, i shall try it.

Fluc's picture

Jason,
You can put a link to a photo hosting site, like photobucket.com, and many others ;)