homebridge-am43-blinds-bluez
Version:
A homebridge plugin to control AM43 based shade motors in HomeKit. These include the A OK and Zemismart bluetooth based motors. This plugin requires a Homebridge host that supports Bluetooth 4.0
20 lines (19 loc) • 670 B
JavaScript
import React, { useEffect, useState } from "react";
export const WaitForDevice = ({ deviceId, children }) => {
const [device, setDevice] = useState(null);
useEffect(() => {
homebridge.showSpinner();
homebridge
.request("/connect_to_device", { device_id: deviceId })
.then((deviceResult) => {
homebridge.hideSpinner();
setDevice(deviceResult);
});
return () => {
homebridge.request("/disconnect_from_device", { device_id: deviceId });
};
}, []);
if (!device)
return null;
return React.createElement(React.Fragment, null, children(device));
};