Having not found any LED information searching here, I am looking for any information on using the LEDs when creating a dashboard in Emoncms (being fed from an Emonpi and IotaWatt system). It seems the LED colors trigger at some unexpected wattage values (like 0.01W will turn the LED green, while 2.0W will leave the LED black) so I wondered if there are instructions somewhere on the best way to incorporate the LEDs?
One issue I have to work around is that when my heat pump is not operating, I can see a fractional wattage value on the sensor, ranging from 0.01 to 0.04 watts. These values if fed directly to an LED will turn it green, even though I would prefer it to be red. The heat pump draws approx. 2230 watts when running, so I would like to make the LED green if the sensor goes above, say, 0.5 watts and stay red if below 0.5 watts. I’ve been playing with experimental values and calculations but there doesn’t seem to be a simple way to achieve my goal.
I’ve learned the LEDs change to 6 different colors (if you include black) over a range of 0 to 5 watts. Anything over 5 watts stays black. So getting the heat pump to do a “simple” red for off and green for on LED is going to require some clever calculations I’ve not yet figured out, using the very limited modifiers available on the Inputs page. If there are explanations or guidelines for each of those process modifiers, that would be helpful. Some of them I don’t understand.
That sounds like an ideal solution! Thanks! But I can’t seem to find a /Modules directory on my PiTop notebook, running a downloaded image of emonpi. Can you tell me how to find it?
When I try cd/Modules from the pi@emonpi:~$ prompt I get “No such file or directory”.
“no such file or directory”. Do I need to be logging in as pi or as something else? When I do ls -a from pi the list of available directories is quite short. Only readme.md is there not prefixed with s period. The other names are .bash_history .bash_logout .bashrc .gnupg .local .profile .wget-hsts
OK, Thanks! I’ve opened the js file with nano. But I’m not sure which values I need to change? There seem to be a lot of references to the LED colors. Can you give me an example of how to change one, so I can see what to look for in the file?
Well, I don’t know JavaScript, so sadly I don’t have any idea what to do with your example. I was hoping it would be at least a little intuitive. Sorry. I do appreciate your efforts though! Thanks!!
A note for future, I would expect that changing this file will block future updates of this Module. You will need to manually stash the file, and then pull in any new version.
Hmm. I don’t know how often these files would update, but that sounds like something I would prefer to avoid.
However, thanks to Michael’s valiant efforts to clarify how the colors are assigned, I now see that they are not as cryptic as I had thought. The default values are:
0W = Red
>0W thru <=1W = Green
>1W thru <=2W = Gray
>2W thru <=3W = Blue
>3W thru <=4W = Purple
>4W thru <=5W = Yellow
>5W = Black
What threw me originally is that Gray is represented by a very subtle gradient overlay on Black, and it was not even noticed at first. This caused me to think that values of 1-2W were also Black, so didn’t make sense. Now that I understand the default color layout, I should be able to make use of it within the Input process operations, and simply avoid using Gray so I don’t mistake it for being Black.
I just today realized there is a potential for problems in the way the led_render.js file is coded for the LED colors. The assigned values “overlap”, and this tripped me up in my efforts to code a process list to get desired results. I had set a value of 4 because I wanted the yellow LED (seeing that 4W-5W = Yellow in my list, above) but had never even noticed that Purple is assigned “3W-4W”, and Purple is exactly what I got (because it comes first in the code, I imagine).
I think it would be better to have the colors assigned with an increment of 1 between them, making 0-1 Red, 2-3 Green, etc. This would also solve an issue I am working around where I have my heat pump being “off”, and yet its 220V power leads are sometimes showing 0.1W on the CT feed coming from my IotaWatt. So I am having to code the process list for that input to remain showing a Red LED even if the value exceeds 0W by some fraction of a watt.
Just thought I’d mention this in case someone wants to address it in a future update of EmonPi. For now I’ll use the middle of each assigned value, such as 0.5W if I want Green. But I think using whole numbers would be easier in the long run.
[Lawrence hadn’t noticed that in the original code, the ranges don’t overlap, see below - Moderator (RW)]
I don’t think that problem existed in the original code. As I read it, the use of “greater than” for the lower bound and “less than or equal to” for the upper bound:
else if (status>3000 && status <=4000) { // Purple