Removing a device involves decommissioning it from the structure. A user can do this using the Google Home app (GHA) , and an app can programmatically decommission a smart home device. There are limitations as to which devices can be removed. Also, removing a device can affect your structure and user experiences for your app.
আপনি কী সরাতে পারেন
আপনি হোম এপিআই-এর মাধ্যমে নিম্নলিখিত ডিভাইসগুলি প্রোগ্রাম্যাটিকভাবে সরাতে পারেন:
- আপনার অ্যাপের যেসব ডিভাইসের অনুমতি আছে, সেগুলো Matter ।
- Matter ব্রিজ, যদি আপনার অ্যাপটি ব্রিজের মাধ্যমে সংযুক্ত সমস্ত ডিভাইসে অ্যাক্সেস পায়। ব্রিজটি সরিয়ে ফেললে এর সাথে সংযুক্ত সমস্ত Matter ডিভাইস মুছে যাবে।
যা আপনি সরাতে পারবেন না
হোম এপিআই-এর মাধ্যমে নিম্নলিখিত ডিভাইসগুলি প্রোগ্রাম্যাটিকভাবে সরানো যাবে না:
- যেসব ডিভাইসের জন্য আপনার অ্যাপে ব্যবহারকারীর অনুমতি নেই, সেগুলো Matter ।
- একটি Matter ব্রিজের পিছনে সংযুক্ত পৃথক ডিভাইস।
- Cloud-to-cloud লিঙ্কযুক্ত ডিভাইস।
- ডুয়াল-পাথ ডিভাইস (যে ডিভাইসগুলি Matter এবং Cloud-to-cloud উভয়ই বাস্তবায়ন করে)।
ডিভাইস অপসারণের আগে গুরুত্বপূর্ণ বিবেচ্য বিষয়গুলি
When your app removes a device, it is removed from the entire structure, affecting all users and all apps, including the GHA . Depending on what type of device it is, there may be additional side effects of decommissioning a device:
- Devices implementing multiple device types: If a device has multiple functions - for example, a smart light that also acts as a hub, removing it also removes all associated devices. The app should inform the user if multiple device functions will be affected.
- ডিভাইসের ইতিহাস: একটি ডিভাইস মুছে ফেলার ফলে ডিভাইসের ইতিহাস মুছে ফেলা হতে পারে।
- শেয়ার করা সারফেস: শেয়ার করা সারফেস থেকে ডিভাইস মুছে ফেলার সময় সতর্ক থাকুন, কারণ এটি অন্যদের জন্য অপ্রত্যাশিত পরিণতি ডেকে আনতে পারে।
- Authentication: Device removal should only be performed on authenticated surfaces, such as a mobile phone, not on unauthenticated devices like TVs. Doing so violates the Google Home Developer Policies .
একটি ডিভাইস সরান
কোনও ডিভাইস অপসারণের যোগ্য কিনা তা পরীক্ষা করা ব্যয়বহুল এবং শুধুমাত্র প্রয়োজনে এটি করা উচিত। কোনও ডিভাইস অপসারণের যোগ্য কিনা তা পরীক্ষা করতে, নিম্নলিখিত কমান্ডটি ব্যবহার করুন:
swift let eligibility = try await device.decommissionEligibilityম্যাটার ডিভাইস
যদি ডিভাইসটি Matter ব্রিজের পিছনে না থাকে, তাহলে আপনি প্রোগ্রাম্যাটিকভাবে একটি Matter ডিভাইস সরাতে পারেন।
একটি Matter ডিভাইস অপসারণ করতে, এতে decommission() কল করুন:
swift let decommissionedDeviceIDs = try await device.decommission()যদি কলটি কোনও ত্রুটি না করে, তাহলে এটি সফল হয়েছে।
আপনি পরীক্ষা করে দেখতে পারেন যে ডিভাইসের আইডিটি decommission() দ্বারা ফেরত পাঠানো আইডিগুলির মধ্যে আছে কিনা:
swift do { let decommissionedDeviceIDs = try await device.decommission() print("The following devices were decommissioned: \(decommissionedDeviceIDs)") } catch { print("An error occurred: \(error)") }অ-বিষয়বস্তু ডিভাইস
Non- Matter devices cannot be removed programmatically. To remove a non- Matter device, you can issue a Sync request (see Request Sync ), or delete the Cloud-to-cloud integration (see Delete a launched Cloud-to-cloud integration ).
যদি আপনি একটি নন- Matter ডিভাইসে decommission() কল করেন, তাহলে একটি HomeError নিক্ষেপ করা হবে।
একবার আপনি একটি নন- Matter ডিভাইস অপসারণ করলে, ডিভাইসটির উপস্থিতি পরীক্ষা করে দেখুন যে এটি সফলভাবে সরানো হয়েছে কিনা:
swift guard try await !self.context.devices().list().contains(where: { $0.id == deviceID }) else { // The device still exists in Home APIs }