@Override
 public void onUpdateDevice(StateDevice stateDevice) {
   if (stateDevice.getType() == StateDeviceProtos.StateDeviceMessage.Type.DOORBELL) {
     // If the state is set to inactive by the client
     Log.i(TAG, "Device updated");
     if (stateDevice.getState() == StateDeviceProtos.StateDeviceMessage.State.INACTIVE) {
       StateDeviceProtos.StateDeviceMessage msg =
           StateDeviceProtos.StateDeviceMessage.newBuilder()
               .setId(stateDevice.getId())
               .setName(stateDevice.getName())
               .setState(stateDevice.getState())
               .setType(stateDevice.getType())
               .build();
       // Send the message
       try {
         Log.i(TAG, "Sending message: \n" + msg.toString());
         OutputStream out = Client.getConnection().getOutputStream();
         msg.writeDelimitedTo(out);
       } catch (IOException e) {
         Client.removeConnection();
         Log.e(TAG, "unable to write to output stream", e);
       }
     }
   }
 }
 @Override
 public void onRemoveDevice(StateDevice stateDevice) {
   if (stateDevice.getType() == StateDeviceProtos.StateDeviceMessage.Type.DOORBELL) {
     Log.i(TAG, "Device removed");
   }
 }
 @Override
 public void onAddDevice(StateDevice stateDevice) {
   if (stateDevice.getType() == StateDeviceProtos.StateDeviceMessage.Type.DOORBELL) {
     Log.i(TAG, "Device added: " + stateDevice.toString());
   }
 }