added sensor.on('change') event using the new averageValue code