Java NestDK不能初始化&;更新手臂对象

Java NestDK不能初始化&;更新手臂对象,java,android,nest-api,Java,Android,Nest Api,我尝试了相同的初始化和更新方法,在恒温器对象中使用smokecolarm对象,但不起作用 有人知道如何初始化和更新对象吗? 或者Nest还没有为访问对象打开SmokeCOAlarmobject 以下是我的代码: public class COSmokeAlarm extends Activity implements NestAPI.AuthenticationListener, Listener.SmokeCOAlarmListener, Listener.Thermo

我尝试了相同的初始化和更新方法,在
恒温器
对象中使用
smokecolarm
对象,但不起作用

有人知道如何初始化和更新对象吗? 或者Nest还没有为访问对象打开
SmokeCOAlarm
object

以下是我的代码:

public class COSmokeAlarm extends Activity implements
        NestAPI.AuthenticationListener, Listener.SmokeCOAlarmListener,     Listener.ThermostatListener  {

private Listener mUpdateListener;
private NestAPI mNestApi;
private SmokeCOAlarm mSmokeCOAlarm;
private Thermostat mThermostat;
private AccessToken mToken;

TextView txvBattery;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_co_smoke_alarm);

    txvBattery = (TextView)findViewById(R.id.txvBattery);

    mNestApi = NestAPI.getInstance();//Initial NestAPI, connect Firebase
    mToken = Settings.loadAuthToken(this);//Loade AccessToken
    authenticate(mToken);
}

private void updateBatteryTextView() {
    if (mSmokeCOAlarm != null) {
        txvBattery.setText(mSmokeCOAlarm.getBatteryHealth());
    }
}

private void authenticate(AccessToken token) {
    Log.v("COSmokeAlarm", "Authenticating...");
    NestAPI.getInstance().authenticate(token, this);
}

@Override
public void onAuthenticationSuccess() {
    Log.v("COSmokeAlarm", "Authentication succeeded.");
    fetchData();
}

@Override
public void onAuthenticationFailure(int errorCode) {
    Log.v("COSmokeAlarm", "Authentication failed with error: " + errorCode);
}

private void fetchData() {
    Log.v("COSmokeAlarm", "Fetching data...");

    mUpdateListener = new Listener.Builder()
            .setSmokeCOAlarmListener(this)
            .setThermostatListener(this)
            .build();
    mNestApi.addUpdateListener(mUpdateListener);
    Toast.makeText(COSmokeAlarm.this, "Success fetching data.", Toast.LENGTH_SHORT).show();
}

@Override
public void onSmokeCOAlarmUpdated(@NonNull SmokeCOAlarm smokeCOAlarm) {
    Log.v("COSmokeAlarm", String.format("COSmoke Alarm (%s) updated.", smokeCOAlarm.getDeviceID()));
    this.mSmokeCOAlarm = smokeCOAlarm;
    updateBatteryTextView();
}

@Override
public void onThermostatUpdated(@NonNull Thermostat thermostat) {
    Log.v("COSmokeAlarm", String.format("Thermostat (%s) updated.", thermostat.getDeviceID()));
    mThermostat = thermostat;
}
}

转到Nest帐户并添加权限“烟雾+CO报警读取v4”

然后我们可以访问
SmokeCOAlarm
信息。