SOURCE

var msg = {
  "topic": "tele/sensor_electricity/SENSOR",
  "payload": {
    "TotalStartTime": "2018-12-22T06:53:46",
    "Total": 50.048,
    "Yesterday": 19.217,
    "Today": 5.268,
    "Period": 5,
    "Power": 1643,
    "ApparentPower": 1666,
    "ReactivePower": 274,
    "Factor": 0.99,
    "Voltage": 235,
    "Current": 7.1,
    "Time": "2018-12-25T14:58:46"
  },
  "qos": 0,
  "retain": false,
  "_msgid": "f7f61810.3c3428",
  "UsedTotal": 4838.048
};
var SENSOR_PAY = {
  "1": {
    "end_kWh": 2160,
    "rmb": 0.558
  },
  "2": {
    "end_kWh": 4800,
    "rmb": 0.608
  },
  "3": {
    "end_kWh": 999999,
    "rmb": 0.858
  },
  "UsedTotal": 4788
}
var sensor = msg.payload;
var result={},key,value;

for(key in SENSOR_PAY){
  value = SENSOR_PAY[key];
  
  if (key == 'UsedTotal'){
    continue;
  }
  
  //如果总还在自己阶梯内
  if ((value.end_kWh - sensor.UsedTotal) < 1){
    re
  }
}



console 命令行工具 X clear

                    
>
console