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

@param {object} message the received mqtt message
@param {number} message[].pm10
@param {string} row the current data row
@param {object} device the device object the data is valid for
createPM10 creates the data fields for the values itself and the index if the device has a PM 10 sensor @param { object } message the received mqtt message @param { number } message [] . pm10 @param { string } row the current data row @param { object } device the device object the data is valid for
createPM10(message, row, device) {
        let PM10Index = 0;
        if (message[row].pm10 < 51) {
            PM10Index = 0;
        } else if (message[row].pm10 >= 51 && message[row].pm10 <= 75) {
            PM10Index = 1;
        } else if (message[row].pm10 >= 76 && message[row].pm10 <= 100) {
            PM10Index = 2;
        } else if (message[row].pm10 >= 101 && message[row].pm10 <= 350) {
            PM10Index = 3;
        } else if (message[row].pm10 >= 351 && message[row].pm10 <= 420) {
            PM10Index = 4;
        } else if (message[row].pm10 >= 421) {
            PM10Index = 5;
        }
        this.createOrExtendObject(device.Serial + '.Sensor.PM10Index', {
            type: 'state',
            common: {
                name: 'PM10 QualityIndex. 0-50: Good, 51-75: Medium, 76-100, Bad, 101-350: very Bad, 351-420: extremely Bad, >421 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: {}
        }, PM10Index);
        PM10 = PM10Index;
        this.subscribeStates(device.Serial + '.Sensor.PM10Index' );
    }
createPM10 ( message , row , device ) { let PM10Index = 0 ; if ( message [ row ] . pm10 < 51 ) { PM10Index = 0 ; } else if ( message [ row ] . pm10 >= 51 && message [ row ] . pm10 <= 75 ) { PM10Index = 1 ; } else if ( message [ row ] . pm10 >= 76 && message [ row ] . pm10 <= 100 ) { PM10Index = 2 ; } else if ( message [ row ] . pm10 >= 101 && message [ row ] . pm10 <= 350 ) { PM10Index = 3 ; } else if ( message [ row ] . pm10 >= 351 && message [ row ] . pm10 <= 420 ) { PM10Index = 4 ; } else if ( message [ row ] . pm10 >= 421 ) { PM10Index = 5 ; } this . createOrExtendObject ( device . Serial + '.Sensor.PM10Index' , { type : 'state' , common : { name : 'PM10 QualityIndex. 0-50: Good, 51-75: Medium, 76-100, Bad, 101-350: very Bad, 351-420: extremely Bad, >421 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 : { } } , PM10Index ) ; PM10 = PM10Index ; this . subscribeStates ( device . Serial + '.Sensor.PM10Index' ) ; }
createPM10
 creates the data fields for the values itself and the index if the device has a PM 10 sensor
createPM10 creates the data fields for the values itself and the index if the device has a PM 10 sensor
// PM10 QualityIndex // 0-50: Good, 51-75: Medium, 76-100, Bad, 101-350: very Bad, 351-420: extremely Bad, >421 worrying