SpoturDeal / MMM-Domoticz

Read data from you Domoticz system
MIT License
8 stars 2 forks source link

Add support for voltage and current #3

Closed offgridonrocker closed 5 years ago

offgridonrocker commented 5 years ago

Could you add support for these? Thanks { "AddjMulti" : 1.0, "AddjMulti2" : 1.0, "AddjValue" : 0.0, "AddjValue2" : 0.0, "BatteryLevel" : 255, "CustomImage" : 0, "Data" : "51.300 V", "Description" : "", "Favorite" : 1, "HardwareID" : 2, "HardwareName" : "virtual", "HardwareType" : "Dummy (Does nothing, use for virtual switches only)", "HardwareTypeVal" : 15, "HaveTimeout" : false, "ID" : "00082001", "LastUpdate" : "2018-10-23 22:57:53", "Name" : "Battery Voltage", "Notifications" : "false", "PlanID" : "0", "PlanIDs" : [ 0 ], "Protected" : false, "ShowNotifications" : true, "SignalLevel" : "-", "SubType" : "Voltage", "Timers" : "false", "Type" : "General", "TypeImg" : "current", "Unit" : 1, "Used" : 1, "Voltage" : 51.299999999999997, "XOffset" : "0", "YOffset" : "0", "idx" : "2" }, { "AddjMulti" : 1.0, "AddjMulti2" : 1.0, "AddjValue" : 0.0, "AddjValue2" : 0.0, "BatteryLevel" : 255, "Current" : 0.029999999999999999, "CustomImage" : 0, "Data" : "0.030 A", "Description" : "", "Favorite" : 1, "HardwareID" : 2, "HardwareName" : "virtual", "HardwareType" : "Dummy (Does nothing, use for virtual switches only)", "HardwareTypeVal" : 15, "HaveTimeout" : false, "ID" : "00082004", "LastUpdate" : "2018-10-23 22:57:54", "Name" : "Solar Amps", "Notifications" : "false", "PlanID" : "0", "PlanIDs" : [ 0 ], "Protected" : false, "ShowNotifications" : true, "SignalLevel" : "-", "SubType" : "Current", "Timers" : "false", "Type" : "General", "TypeImg" : "current", "Unit" : 1, "Used" : 1, "XOffset" : "0", "YOffset" : "0", "idx" : "5" },

SpoturDeal commented 5 years ago

Support added today

offgridonrocker commented 5 years ago

Carl, Thank you for adding these but Voltage/Current do not work for me.{I am trying to figure it out!} If I change line 151 of MMM-Domoticz.js to if (dev.Type == "General"){ it picks them up but I believe this is just using what you had for the Air Quality / co sensor. I like that I can change the threshold and it will display voltage in red. It would be great if it could have high and low parameters. I am trying to wrap my head around this but I am not a coder. At least not since the early 1980's when I dabbled with BASIC. Thanks again

SpoturDeal commented 5 years ago

Hello offgridonrocker,

I had a mistake in the code it had to be dev.SubType (two capitals) instead of dev.subType This is two parts one with threshold and one without threshold. Just use one of those i update the second version today.

ONE:

 if (dev.Type == "General"  && dev.SubType=="Voltage"){
              pts=dev.Data.split(' ');
              if (pts[0] > 48){
                 // add to make sure voltage is added for display
                 voltageCount++;
                 // if level is 48 above thresholt then color ppm in red
                 alarmLvl=48;
                 voltage += '<tr><td class="small">' + dev.Name  +'</td><td class="small '+(pts[0] > alarmLvl?'red':'')+'">' + dev.Data + '</td></tr>';
              }
          }

TWO


          if (dev.SubType == "Voltage" || dev.SubType == "Current"){
              // For both current and voltage */
              voltageCount++;
              voltage += '<tr><td class="small">' + dev.Name  +'</td><td class="small ' + dev.Data+'"></td></tr>';
          }

I myself started coding in Machine Language in 1978 also did Basic (several form) now mainly C++ and Java

Just found out the dev.SubType makes the module stop. However dev.subType works