main.js
/**
     * createPM25
     *
     * creates the data fields for the values itself and the index if the device has a PM 2,5 sensor
     *
     * @param message {object} the received mqtt message
     * @param {number} message[].pm25
     * @param row     {string} the current data row
     * @param device  {object} the device object the data is valid for
     */
createPM25
creates the data fields for the values itself and the index if the device has a PM 2,5 sensor

@param message {object} the received mqtt message
@param {number} message[].pm25
@param row     {string} the current data row
@param device  {object} the device object the data is valid for
createPM25 creates the data fields for the values itself and the index if the device has a PM 2 5 sensor @param message { object } the received mqtt message @param { number } message [] . pm25 @param row { string } the current data row @param device { object } the device object the data is valid for
createPM25(message, row, device) {
        let PM25Index = 0;
        if (message[row].pm25 < 36) {
            PM25Index = 0;
        } else if (message[row].pm25 >= 36 && message[row].pm25 <= 53) {
            PM25Index = 1;
        } else if (message[row].pm25 >= 54 && message[row].pm25 <= 70) {
            PM25Index = 2;
        } else if (message[row].pm25 >= 71 && message[row].pm25 <= 150) {
            PM25Index = 3;
        } else if (message[row].pm25 >= 151 && message[row].pm25 <= 250) {
            PM25Index = 4;
        } else if (message[row].pm25 >= 251) {
            PM25Index = 5;
        }
        this.createOrExtendObject(device.Serial + '.Sensor.PM25Index', {
            type: 'state',
            common: {
                name: 'PM2.5 QualityIndex. 0-35: Good, 36-53: Medium, 54-70: Bad, 71-150: very Bad, 151-250: extremely Bad, >251 worrying',
                'read': true,
                'write': false,
                'role': 'value',
                'type': 'number',
                'states' : {0:'Good', 1:'Medium', 2:'Bad', 3:'very Bad', 4:'extremely Bad', 5:'worrying'}
            },
            native: {}
        }, PM25Index);
        PM25 = PM25Index;
        this.subscribeStates(device.Serial + '.Sensor.PM25Index' );
    }
createPM25 ( message , row , device ) { let PM25Index = 0 ; if ( message [ row ] . pm25 < 36 ) { PM25Index = 0 ; } else if ( message [ row ] . pm25 >= 36 && message [ row ] . pm25 <= 53 ) { PM25Index = 1 ; } else if ( message [ row ] . pm25 >= 54 && message [ row ] . pm25 <= 70 ) { PM25Index = 2 ; } else if ( message [ row ] . pm25 >= 71 && message [ row ] . pm25 <= 150 ) { PM25Index = 3 ; } else if ( message [ row ] . pm25 >= 151 && message [ row ] . pm25 <= 250 ) { PM25Index = 4 ; } else if ( message [ row ] . pm25 >= 251 ) { PM25Index = 5 ; } this . createOrExtendObject ( device . Serial + '.Sensor.PM25Index' , { type : 'state' , common : { name : 'PM2.5 QualityIndex. 0-35: Good, 36-53: Medium, 54-70: Bad, 71-150: very Bad, 151-250: extremely Bad, >251 worrying' , 'read' : true , 'write' : false , 'role' : 'value' , 'type' : 'number' , 'states' : { 0 : 'Good' , 1 : 'Medium' , 2 : 'Bad' , 3 : 'very Bad' , 4 : 'extremely Bad' , 5 : 'worrying' } } , native : { } } , PM25Index ) ; PM25 = PM25Index ; this . subscribeStates ( device . Serial + '.Sensor.PM25Index' ) ; }
createPM25
 creates the data fields for the values itself and the index if the device has a PM 2,5 sensor
createPM25 creates the data fields for the values itself and the index if the device has a PM 2 5 sensor
// PM2.5 QualityIndex // 0-35: Good, 36-53: Medium, 54-70: Bad, 71-150: very Bad, 151-250: extremely Bad, >251 worrying