LowPowerLab Forum

Software support => Pi Gateway => Topic started by: tunkmountainman on June 24, 2020, 11:39:15 AM

Title: Gateway v9.1.0 custom metric error [solved]
Post by: tunkmountainman on June 24, 2020, 11:39:15 AM
After I switched to the latest gateway and updated my "userMetrics" to individual metrics, two of the four metric files load properly but two do not. gateway system log indicates a couple of different reasons for the failures. I have completely reworked these two with the same results. I will post a metric that works correctly and one who fails. The more I look at this the more confused I become. I would really appreciate a "New" set of eyes on this...Thanks ahead of time....Dennis
This metric works fine

exports.metrics = {
    Temp: {name:'Temp',regexp: /9954\:(-?\d+\.\d+)/i,value: '',duplicateInterval: 3600,unit: '0',pin: 1,graph: 1,graphValSuffix: 'F',graphOptions: {legendLbl: 'Temp',lines: {lineWidth: 1 }}}}


However this one will fail attempting to load

exports.metrics = {
Volts: {name:'Volts',regexp: /9950\:([\d\.]+)/i,value: '',duplicateInterval: 3600,unit: 'volts',pin: 1,graph: 1,graphOptions: {legendLbl: 'Volts',lines: {lineWidth: 1},grid: backgroundColor: {colors: ['#000', '#03c', '#08c']}}yaxis: {min: 0,autoscaleMargin: 0.25,autoscaleBottom: false}}}


[06-24-20_08:27:09.421] [INFO]   LOADING METRICS MODULE [/home/pi/gateway/metrics/Dennis2Metrics/Volts.js]
[06-24-20_08:27:09.432] [ERROR]  FAIL LOADING METRICS MODULE [/home/pi/gateway/metrics/Dennis2Metrics/Volts.js]: Unexpected token :
/home/pi/gateway/metrics/Dennis2Metrics/Volts.js:4
   volts:{ name:'volts',regexp:/9950\:([\d\.]+)/,value: '',duplicateInterval:3600,unit:'Volts',pin:1,graph:1,graphValSuffix:V,graphOptions:{legendLl:'Volts',lines:{lineWidth: 1},grid:backgroundColor:{colors:['#000','#03c','#08c']}}yaxis:{min:0,autoscaleMargin:0.25, autoscaleBottom:false}}}
                                                                                                               


Thanks for your time
Title: Re: Gateway v9.1.0 problem
Post by: Felix on July 13, 2020, 09:29:19 AM
Looks like a syntax error, i think you're missing a comma before the "yaxis:".
Title: Re: Gateway v9.1.0 problem
Post by: tunkmountainman on August 14, 2020, 01:18:59 PM
Thank you Felix. The comma was the correct solution. It is a huge value to have someone with fresh eyes and knowledge to help us little people out here scratching our way to gain our own knowledge. Thanks for all of us.  Dennis...