قالب وردپرس درنا توس
Home / IOS Development / # 297: Simulate HomeKit Accessories 💡🤖 – Little Bites of Cocoa

# 297: Simulate HomeKit Accessories 💡🤖 – Little Bites of Cocoa



"Home Automation" may be one of the hottest topics in technology these days.

While there is still an emerging market, many iOS unit owners also own at least one or two "smart home" devices.

Today, we start looking at HomeKit, Apple's framework for communicating with and controlling these devices from the inside of our apps.

Before you can dive in, there are some tools we need to learn about first. In particular, we need to learn to simulate HomeKit devices.

For example, we can not own any HomeKit devices yourself. Even if we do, we will not need to change things about our home to test our app.

Do not worry, Apple provides a good solution to this challenge in the form of a HomeKit Accessories Simulator app for macOS .

In this we can set up and configure a "simulated" set of devices in any kind of home layout we want.

Unfortunately, though, it does not. Do not ship with Xcode .

We need to go over to Apple's "More Developer Downloads" page here and search for "Hardware IO Tools for Xcode" . We download the latest release, and then install the HomeKit Accessory Simulator app .

Now let's open it and simulate our first accessory.

We click + button at the bottom left and select New accessories …

We fill in the fields with someone examples of information. The values ​​are not super important, they just need to be unique and somewhat realistic.

Neat. We have now received a (late) lamp. 💡

Well, kind of. It's actually an even important step and it speaks to the heart of how HomeKit works.

So far, HomeKit does not know anything about our new lamp. "Lamp" is just the name we gave it.

For HomeKit to do something useful with our device, we must add a HomeKit Service to it. HomeKit Services describes the features and of a device

We click the Add Service … button on our new device and select Lightbulb from the drop-down menu.

We can leave the rest of the fields alone.

Tidy! Not only do we now have a full-color, color switching bulb, we are also equipped with some great sliders and controls to read from and write to the current state of the device.

] It was all for today. We learn more about HomeKit Accessory Simulator as we continue to explore HomeKit . Next time we learn how to change the color of the light in code! 🌈💡

Source link