public final class CommissioningResult
- Object
- CommissioningResult
What came of a commissioning attempt.
Success does not mean you got a device
This is the type that has to carry the least comfortable fact in the whole API. Commissioning adds an accessory to the user’s ecosystem, and whether your app can then see or control it is a separate question with a different answer per backend:
- iOS, MatterSupport – the accessory joins the user’s HomeKit home and
appears in your graph on the next refresh, where you can control it like
any other. This result carries no id: Apple’s sheet reports that the
flow finished and does not say what was added or which home it went to,
and the user is free to pick a different home than the one you asked
for. Call
com.codename1.home.SmartHome#refresh()and look at what is new.wasCommissionedToThisApp()isfalseunless the build asked for a fabric of its own – seeCommissioningRequest.setCommissionToThisApp(boolean)– in which case a successful flow means the accessory joined it, because the extension’s commissioning step failing is what would have failed the flow. - Android, Google Home APIs – the accessory joins the user’s Google Home and, if the user granted your app access to that structure, appears in your graph. You get an id and it works.
- Android, Play services commissioning alone – the accessory joins the
user’s Google Home and your app is told nothing more. There is no id,
and there is no graph to look it up in; see
com.codename1.home.HomeAvailability#COMMISSIONING_ONLY.
wasCommissionedToThisApp() is that distinction, made explicit so it
cannot be missed. An app that assumes it got a device shows a “your new
device” screen with nothing on it – and on two of these three backends
that is what it would get.
Constructors
public CommissioningResult(String accessoryId, String accessoryName, String structureId, boolean commissionedToThisApp) | Creates a result. |
Methods
public boolean wasCommissionedToThisApp() | Whether this app can address the new accessory. |
public String getAccessoryId() | The new accessory’s identifier. |
public String getAccessoryName() | The name the accessory ended up with, which is the user’s choice rather than the one suggested. |
public String getStructureId() | The home the accessory joined. |
public String toString() | Returns a string representation of the object. |
Inherited methods
Constructor details
CommissioningResult
public CommissioningResult(String accessoryId, String accessoryName, String structureId, boolean commissionedToThisApp)Parameters
accessoryIdString- the new accessory, or
nullwhen the backend did not say accessoryNameString- the name the accessory ended up with, or
null structureIdString- the home it joined, or
null commissionedToThisAppboolean- whether this app can address the accessory
Method details
wasCommissionedToThisApp
public boolean wasCommissionedToThisApp()Whether this app can address the new accessory.
When false, the accessory was added to the user’s home successfully
and there is nothing more you can do with it from here – tell the user
it worked and send them to their ecosystem app, rather than showing an
empty device screen. See the class note.
Returns
true when getAccessoryId() is usablegetAccessoryId
public String getAccessoryId()Returns
getAccessoryName
public String getAccessoryName()Returns
null; empty when the backend did not saygetStructureId
public String getStructureId()The home the accessory joined.
The user can pick a different home than the one requested, so this is worth reading rather than assuming.
Returns
null when the backend did not saytoString
public String toString()