Author Topic: Gateway v9.1.0 custom metric error [solved]  (Read 858 times)

tunkmountainman

  • NewMember
  • *
  • Posts: 10
  • Country: us
Gateway v9.1.0 custom metric error [solved]
« 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

Code: [Select]
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

Code: [Select]
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}}}

Code: [Select]
[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
« Last Edit: August 15, 2020, 12:01:33 PM by Felix »

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Gateway v9.1.0 problem
« Reply #1 on: July 13, 2020, 09:29:19 AM »
Looks like a syntax error, i think you're missing a comma before the "yaxis:".

tunkmountainman

  • NewMember
  • *
  • Posts: 10
  • Country: us
Re: Gateway v9.1.0 problem
« Reply #2 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...